diff options
author | Francesco Agosti <francesco.agosti93@gmail.com> | 2018-07-07 06:38:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-07 06:38:51 +0800 |
commit | 269b56b907f8af49e5d92bdcf3aedbc9af03e368 (patch) | |
tree | 8edcdaab384b8808f8f8520347e5cf6929f0c57e /packages/website/ts/components/ui | |
parent | e929fb4337b227bae55b1b8456b5035f7df5eb4f (diff) | |
parent | 60ebfcf36df3d2e4f15142823fb5821d8d65937e (diff) | |
download | dexon-0x-contracts-269b56b907f8af49e5d92bdcf3aedbc9af03e368.tar.gz dexon-0x-contracts-269b56b907f8af49e5d92bdcf3aedbc9af03e368.tar.zst dexon-0x-contracts-269b56b907f8af49e5d92bdcf3aedbc9af03e368.zip |
Merge pull request #838 from 0xProject/feature/website/portal-final-touches
Some final polish touches for portal!
Diffstat (limited to 'packages/website/ts/components/ui')
-rw-r--r-- | packages/website/ts/components/ui/balance.tsx | 27 | ||||
-rw-r--r-- | packages/website/ts/components/ui/container.tsx | 14 |
2 files changed, 38 insertions, 3 deletions
diff --git a/packages/website/ts/components/ui/balance.tsx b/packages/website/ts/components/ui/balance.tsx new file mode 100644 index 000000000..9e5a256b6 --- /dev/null +++ b/packages/website/ts/components/ui/balance.tsx @@ -0,0 +1,27 @@ +import { BigNumber } from '@0xproject/utils'; +import * as React from 'react'; +import { Container } from 'ts/components/ui/container'; +import { Text } from 'ts/components/ui/text'; +import { utils } from 'ts/utils/utils'; + +export interface BalanceProps { + amount: BigNumber; + decimals: number; + symbol: string; +} + +export const Balance: React.StatelessComponent<BalanceProps> = ({ amount, decimals, symbol }) => { + const formattedAmout = utils.getFormattedAmount(amount, decimals); + return ( + <span> + <Text Tag="span" fontSize="16px" fontWeight="700" lineHeight="1em"> + {formattedAmout} + </Text> + <Container marginLeft="0.3em" Tag="span"> + <Text Tag="span" fontSize="12px" fontWeight="700" lineHeight="1em"> + {symbol} + </Text> + </Container> + </span> + ); +}; diff --git a/packages/website/ts/components/ui/container.tsx b/packages/website/ts/components/ui/container.tsx index edbf8814b..427cc6cc7 100644 --- a/packages/website/ts/components/ui/container.tsx +++ b/packages/website/ts/components/ui/container.tsx @@ -2,6 +2,8 @@ import * as React from 'react'; type StringOrNum = string | number; +export type ContainerTag = 'div' | 'span'; + export interface ContainerProps { marginTop?: StringOrNum; marginBottom?: StringOrNum; @@ -28,15 +30,21 @@ export interface ContainerProps { right?: string; bottom?: string; zIndex?: number; + Tag?: ContainerTag; } -export const Container: React.StatelessComponent<ContainerProps> = ({ children, className, isHidden, ...style }) => { +export const Container: React.StatelessComponent<ContainerProps> = props => { + const { children, className, Tag, isHidden, ...style } = props; const visibility = isHidden ? 'hidden' : undefined; return ( - <div style={{ ...style, visibility }} className={className}> + <Tag style={{ ...style, visibility }} className={className}> {children} - </div> + </Tag> ); }; +Container.defaultProps = { + Tag: 'div', +}; + Container.displayName = 'Container'; |