Skip to content

Commit

Permalink
feat(Voting UI): round numbers for yes/no bar
Browse files Browse the repository at this point in the history
  • Loading branch information
phonktown committed Oct 7, 2024
1 parent 1197749 commit 9b73927
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions modules/votes/ui/VoteYesNoBar/VoteYesNoBar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Text } from '@lidofinance/lido-ui'
import { Text, Tooltip } from '@lidofinance/lido-ui'
import {
VotesBarNay,
VotesBarWrap,
Expand Down Expand Up @@ -27,25 +27,31 @@ export function VoteYesNoBar({
showOnForeground,
showNumber,
}: Props) {
const roundDown = (n: number): number => Math.floor(n * 10) / 10

const nayInfo = showNumber
? `"No" — ${nayNum} (${nayPctOfTotalSupply}%)`
? `"No" — ${roundDown(nayNum)} (${nayPctOfTotalSupply}%)`
: `"No" — ${nayPctOfTotalSupply}%`

const yeaInfo = showNumber
? `"Yes" — ${yeaNum} (${yeaPctOfTotalSupply}%)`
? `"Yes" — ${roundDown(yeaNum)} (${yeaPctOfTotalSupply}%)`
: `"Yes" — ${yeaPctOfTotalSupply}%`

return (
<>
<VotesTitleWrap>
<Text size="xxs">
<Text as="span" size="xxs">
{nayInfo}
<Tooltip title={<span>{nayNum}</span>} placement="top">
<span>{nayInfo}</span>
</Tooltip>
</Text>
</Text>
<Text size="xxs" style={{ textAlign: 'right' }}>
<Text as="span" size="xxs">
{yeaInfo}
<Tooltip title={<span>{yeaNum}</span>} placement="top">
<span>{yeaInfo}</span>
</Tooltip>
</Text>
</Text>
</VotesTitleWrap>
Expand Down

0 comments on commit 9b73927

Please sign in to comment.