forked from pancakeswap/pancake-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPairPriceDisplay.tsx
56 lines (50 loc) · 1.39 KB
/
PairPriceDisplay.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { Flex, Skeleton, Text } from '@pancakeswap/uikit'
import { FC } from 'react'
import styled from 'styled-components'
import { formatAmount, formatAmountNotation } from 'utils/formatInfoNumbers'
import { FlexGap, FlexGapProps } from './Layout/Flex'
const formatOptions = {
notation: 'standard' as formatAmountNotation,
displayThreshold: 0.001,
tokenPrecision: true,
}
interface TokenDisplayProps extends FlexGapProps {
value?: number | string
inputSymbol?: string
outputSymbol?: string
format?: boolean
}
const TextLabel = styled(Text)`
font-size: 32px;
line-height: 1.1;
${({ theme }) => theme.mediaQueries.lg} {
font-size: 40px;
}
`
const PairPriceDisplay: FC<TokenDisplayProps> = ({
value,
inputSymbol,
outputSymbol,
children,
format = true,
...props
}) => {
return value ? (
<FlexGap alignItems="baseline" {...props}>
<Flex alignItems="inherit">
<TextLabel mr="8px" bold>
{format ? formatAmount(typeof value === 'string' ? parseFloat(value) : value, formatOptions) : value}
</TextLabel>
{inputSymbol && outputSymbol && (
<Text color="textSubtle" fontSize="20px" bold lineHeight={1.1}>
{`${inputSymbol}/${outputSymbol}`}
</Text>
)}
</Flex>
{children}
</FlexGap>
) : (
<Skeleton height="36px" width="128px" {...props} />
)
}
export default PairPriceDisplay