Commit cb480706 authored by cartcrom's avatar cartcrom Committed by GitHub

fix: display 0 instead of '-' on explore table (#4892)

* fixed table display
* updated test
parent 4f742671
...@@ -190,7 +190,7 @@ const DataCell = styled(Cell)<{ sortable: boolean }>` ...@@ -190,7 +190,7 @@ const DataCell = styled(Cell)<{ sortable: boolean }>`
}, },
}) => css`background-color ${duration.medium} ${timing.ease}`}; }) => css`background-color ${duration.medium} ${timing.ease}`};
` `
const MarketCapCell = styled(DataCell)` const TvlCell = styled(DataCell)`
padding-right: 8px; padding-right: 8px;
@media only screen and (max-width: ${MEDIUM_MEDIA_BREAKPOINT}) { @media only screen and (max-width: ${MEDIUM_MEDIA_BREAKPOINT}) {
display: none; display: none;
...@@ -383,7 +383,7 @@ export function TokenRow({ ...@@ -383,7 +383,7 @@ export function TokenRow({
tokenInfo, tokenInfo,
price, price,
percentChange, percentChange,
marketCap, tvl,
volume, volume,
sparkLine, sparkLine,
...rest ...rest
...@@ -393,7 +393,7 @@ export function TokenRow({ ...@@ -393,7 +393,7 @@ export function TokenRow({
header: boolean header: boolean
listNumber: ReactNode listNumber: ReactNode
loading?: boolean loading?: boolean
marketCap: ReactNode tvl: ReactNode
price: ReactNode price: ReactNode
percentChange: ReactNode percentChange: ReactNode
sparkLine?: ReactNode sparkLine?: ReactNode
...@@ -409,7 +409,7 @@ export function TokenRow({ ...@@ -409,7 +409,7 @@ export function TokenRow({
<NameCell>{tokenInfo}</NameCell> <NameCell>{tokenInfo}</NameCell>
<PriceCell sortable={header}>{price}</PriceCell> <PriceCell sortable={header}>{price}</PriceCell>
<PercentChangeCell sortable={header}>{percentChange}</PercentChangeCell> <PercentChangeCell sortable={header}>{percentChange}</PercentChangeCell>
<MarketCapCell sortable={header}>{marketCap}</MarketCapCell> <TvlCell sortable={header}>{tvl}</TvlCell>
<VolumeCell sortable={header}>{volume}</VolumeCell> <VolumeCell sortable={header}>{volume}</VolumeCell>
<SparkLineCell>{sparkLine}</SparkLineCell> <SparkLineCell>{sparkLine}</SparkLineCell>
{favoriteTokensEnabled && <FavoriteCell>{favorited}</FavoriteCell>} {favoriteTokensEnabled && <FavoriteCell>{favorited}</FavoriteCell>}
...@@ -433,7 +433,7 @@ export function HeaderRow() { ...@@ -433,7 +433,7 @@ export function HeaderRow() {
tokenInfo={<Trans>Token name</Trans>} tokenInfo={<Trans>Token name</Trans>}
price={<HeaderCell category={TokenSortMethod.PRICE} sortable />} price={<HeaderCell category={TokenSortMethod.PRICE} sortable />}
percentChange={<HeaderCell category={TokenSortMethod.PERCENT_CHANGE} sortable />} percentChange={<HeaderCell category={TokenSortMethod.PERCENT_CHANGE} sortable />}
marketCap={<HeaderCell category={TokenSortMethod.TOTAL_VALUE_LOCKED} sortable />} tvl={<HeaderCell category={TokenSortMethod.TOTAL_VALUE_LOCKED} sortable />}
volume={<HeaderCell category={TokenSortMethod.VOLUME} sortable />} volume={<HeaderCell category={TokenSortMethod.VOLUME} sortable />}
sparkLine={null} sparkLine={null}
/> />
...@@ -456,7 +456,7 @@ export function LoadingRow() { ...@@ -456,7 +456,7 @@ export function LoadingRow() {
} }
price={<MediumLoadingBubble />} price={<MediumLoadingBubble />}
percentChange={<LoadingBubble />} percentChange={<LoadingBubble />}
marketCap={<LoadingBubble />} tvl={<LoadingBubble />}
volume={<LoadingBubble />} volume={<LoadingBubble />}
sparkLine={<SparkLineLoadingBubble />} sparkLine={<SparkLineLoadingBubble />}
/> />
...@@ -536,9 +536,7 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT ...@@ -536,9 +536,7 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT
price={ price={
<ClickableContent> <ClickableContent>
<PriceInfoCell> <PriceInfoCell>
{token.market?.price?.value {formatDollar({ num: token.market?.price?.value, isPrice: true, lessPreciseStablecoinValues: true })}
? formatDollar({ num: token.market.price.value, isPrice: true, lessPreciseStablecoinValues: true })
: '-'}
<PercentChangeInfoCell> <PercentChangeInfoCell>
{formattedDelta} {formattedDelta}
{arrow} {arrow}
...@@ -552,16 +550,8 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT ...@@ -552,16 +550,8 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT
{arrow} {arrow}
</ClickableContent> </ClickableContent>
} }
marketCap={ tvl={<ClickableContent>{formatDollar({ num: token.market?.totalValueLocked?.value })}</ClickableContent>}
<ClickableContent> volume={<ClickableContent>{formatDollar({ num: token.market?.volume?.value })}</ClickableContent>}
{token.market?.totalValueLocked?.value ? formatDollar({ num: token.market.totalValueLocked.value }) : '-'}
</ClickableContent>
}
volume={
<ClickableContent>
{token.market?.volume?.value ? formatDollar({ num: token.market.volume.value }) : '-'}
</ClickableContent>
}
sparkLine={ sparkLine={
<SparkLine> <SparkLine>
<ParentSize> <ParentSize>
......
...@@ -136,7 +136,7 @@ describe('formatDollar for a non-price amount', () => { ...@@ -136,7 +136,7 @@ describe('formatDollar for a non-price amount', () => {
expect(formatDollar({ num: null })).toEqual('-') expect(formatDollar({ num: null })).toEqual('-')
}) })
it('0', () => { it('0', () => {
expect(formatDollar({ num: 0 })).toEqual('0') expect(formatDollar({ num: 0 })).toEqual('$0.00')
}) })
it('< 0.000001', () => { it('< 0.000001', () => {
expect(formatDollar({ num: 0.0000000001 })).toEqual('$<0.000001') expect(formatDollar({ num: 0.0000000001 })).toEqual('$<0.000001')
......
...@@ -70,7 +70,7 @@ export const formatDollar = ({ ...@@ -70,7 +70,7 @@ export const formatDollar = ({
} }
// For volume dollar amounts, like market cap, total value locked, etc. // For volume dollar amounts, like market cap, total value locked, etc.
else { else {
if (num === 0) return '0' if (num === 0) return '$0.00'
if (!num) return '-' if (!num) return '-'
if (num < 0.000001) { if (num < 0.000001) {
return '$<0.000001' return '$<0.000001'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment