Skip to content

Commit 79befc4

Browse files
committed
Increase fraction digits for small values
1 parent 42568e7 commit 79befc4

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/app/components/PercentageValue/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { FC } from 'react'
22
import { useTranslation } from 'react-i18next'
33

44
type PercentageValueProps = {
5+
adaptMaximumFractionDigits?: boolean
56
total: number | undefined
67
value: number | undefined
78
}
89

9-
export const PercentageValue: FC<PercentageValueProps> = ({ value, total }) => {
10+
export const PercentageValue: FC<PercentageValueProps> = ({ adaptMaximumFractionDigits, value, total }) => {
1011
const { t } = useTranslation()
1112

1213
if (typeof value !== 'number' || typeof total !== 'number' || total <= 0) {
@@ -22,7 +23,7 @@ export const PercentageValue: FC<PercentageValueProps> = ({ value, total }) => {
2223
formatParams: {
2324
value: {
2425
style: 'percent',
25-
maximumFractionDigits: 2,
26+
maximumFractionDigits: adaptMaximumFractionDigits && percentageValue < 0.001 ? 3 : 2,
2627
} satisfies Intl.NumberFormatOptions,
2728
},
2829
})}

src/app/components/Validators/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ export const Validators: FC<ValidatorsProps> = ({ isLoading, limit, pagination,
7676
},
7777
{
7878
align: TableCellAlign.Right,
79-
content: <PercentageValue value={validator.voting_power} total={stats?.total_voting_power} />,
79+
content: (
80+
<PercentageValue
81+
value={validator.voting_power}
82+
total={stats?.total_voting_power}
83+
adaptMaximumFractionDigits
84+
/>
85+
),
8086

8187
key: 'voting',
8288
},

0 commit comments

Comments
 (0)