Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
cb480706
Unverified
Commit
cb480706
authored
Oct 13, 2022
by
cartcrom
Committed by
GitHub
Oct 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: display 0 instead of '-' on explore table (#4892)
* fixed table display * updated test
parent
4f742671
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
21 deletions
+11
-21
TokenRow.tsx
src/components/Tokens/TokenTable/TokenRow.tsx
+9
-19
formatNumbers.test.ts
src/utils/formatNumbers.test.ts
+1
-1
formatNumbers.ts
src/utils/formatNumbers.ts
+1
-1
No files found.
src/components/Tokens/TokenTable/TokenRow.tsx
View file @
cb480706
...
@@ -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
MarketCap
Cell
=
styled
(
DataCell
)
`
const
Tvl
Cell
=
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}</MarketCap
Cell>
<
TvlCell sortable={header}>{tvl}</Tvl
Cell>
<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>
...
...
src/utils/formatNumbers.test.ts
View file @
cb480706
...
@@ -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.0
0
'
)
})
})
it
(
'
< 0.000001
'
,
()
=>
{
it
(
'
< 0.000001
'
,
()
=>
{
expect
(
formatDollar
({
num
:
0.0000000001
})).
toEqual
(
'
$<0.000001
'
)
expect
(
formatDollar
({
num
:
0.0000000001
})).
toEqual
(
'
$<0.000001
'
)
...
...
src/utils/formatNumbers.ts
View file @
cb480706
...
@@ -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.0
0
'
if
(
!
num
)
return
'
-
'
if
(
!
num
)
return
'
-
'
if
(
num
<
0.000001
)
{
if
(
num
<
0.000001
)
{
return
'
$<0.000001
'
return
'
$<0.000001
'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment