From e2744a92b187ef5407676a7801537a0c936da58e Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 23 Mar 2020 14:38:49 +0100 Subject: [PATCH] Graphs avg. only on > 0 (#2443) --- packages/page-staking/src/Query/Validator.tsx | 6 +++--- packages/react-query/src/FormatBalance.tsx | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/page-staking/src/Query/Validator.tsx b/packages/page-staking/src/Query/Validator.tsx index 7083a62b92..cff49fc929 100644 --- a/packages/page-staking/src/Query/Validator.tsx +++ b/packages/page-staking/src/Query/Validator.tsx @@ -45,7 +45,7 @@ function extractPoints (points: DeriveStakerPoints[]): ChartInfo { total += points.toNumber(); labels.push(era.toHuman()); - if (total > 0) { + if (points.gtn(0)) { avgCount++; } @@ -79,7 +79,7 @@ function extractRewards (erasRewards: DeriveEraRewards[], ownSlashes: DeriveOwnS total += reward; - if (total > 0) { + if (reward > 0) { avgCount++; } @@ -109,7 +109,7 @@ function extractStake (exposures: DeriveOwnExposure[], divisor: BN): ChartInfo { total += cli; - if (total > 0) { + if (cli > 0) { avgCount++; } diff --git a/packages/react-query/src/FormatBalance.tsx b/packages/react-query/src/FormatBalance.tsx index 23684b43b5..3aeda58e69 100644 --- a/packages/react-query/src/FormatBalance.tsx +++ b/packages/react-query/src/FormatBalance.tsx @@ -32,7 +32,7 @@ function format (value: Compact | BN | string, currency: string, withSi?: b return formatBalance(value); } - return <>{prefix}{!isShort && (<>.{`000${postfix || ''}`.slice(-3)})} {currency}; + return <>{prefix}{!isShort && (<>.{`000${postfix || ''}`.slice(-3)})} {currency}; } // function formatSi (value: Compact | BN | string): React.ReactNode { @@ -53,13 +53,13 @@ function FormatBalance ({ children, className, label, value, withSi }: Props): R return (
- {label || ''}{ + {label || ''}{ value ? value === 'all' ? t('everything') : format(value, currency, withSi) : '-' - }{children} + }{children}
); } @@ -67,6 +67,7 @@ function FormatBalance ({ children, className, label, value, withSi }: Props): R export default React.memo(styled(FormatBalance)` display: inline-block; vertical-align: baseline; + white-space: nowrap; * { vertical-align: baseline !important; @@ -79,9 +80,13 @@ export default React.memo(styled(FormatBalance)` vertical-align: baseline; } - > .balance-postfix { - font-weight: 100; - opacity: 0.75; - vertical-align: baseline; + .ui--FormatBalance-value { + text-align: right; + + > .ui--FormatBalance-postfix { + font-weight: 100; + opacity: 0.75; + vertical-align: baseline; + } } `);