From d9c761143d5a819a99cda8f8dfa7b7e98661b565 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Sat, 25 Nov 2023 17:05:13 +0200 Subject: [PATCH 1/3] Hide 0% if balance equals balance changes --- src/components/AppSummary/AppSummary.columns.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/AppSummary/AppSummary.columns.js b/src/components/AppSummary/AppSummary.columns.js index fde23f3f2..319122109 100644 --- a/src/components/AppSummary/AppSummary.columns.js +++ b/src/components/AppSummary/AppSummary.columns.js @@ -141,17 +141,23 @@ export const getAssetColumns = ({ name: 'summary.by_asset.balance_change', width: 178, renderer: (rowIndex) => { - const { valueChange30dUsd, valueChange30dPerc } = preparedData[rowIndex] + const { balanceUsd, valueChange30dUsd, valueChange30dPerc } = preparedData[rowIndex] + const shouldShowPercentChange = balanceUsd !== valueChange30dUsd return ( <> {formatUsdValueChange(valueChange30dUsd)} -
- - {formatPercentValue(valueChange30dPerc)} - + {shouldShowPercentChange && ( + <> +
+ + {formatPercentValue(valueChange30dPerc)} + + + )} +
) From 538431b2e105dee06f0baf38a6ff61266d8586d1 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Sat, 25 Nov 2023 17:26:51 +0200 Subject: [PATCH 2/3] Implement unified show balance percent checker --- src/components/AppSummary/AppSummary.helpers.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/AppSummary/AppSummary.helpers.js b/src/components/AppSummary/AppSummary.helpers.js index 04bd90657..d024225fc 100644 --- a/src/components/AppSummary/AppSummary.helpers.js +++ b/src/components/AppSummary/AppSummary.helpers.js @@ -25,3 +25,11 @@ export const formatUsdValueChange = (value) => { if (val < 0) return {`-$${formatThousands(Math.abs(val))}`} return {`$${formatThousands(val)}`} } + +export const shouldShowPercentCheck = (balance, balanceChange) => { + const bal = prepareNumericValue(balance) + const balChange = prepareNumericValue(balanceChange) + if (balChange === 0) return true + if (bal === balChange) return false + return true +} From 30b95d0c6caec9bc4950e0e6d1e929fb7760ec2a Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Sat, 25 Nov 2023 17:27:49 +0200 Subject: [PATCH 3/3] Rework and improve balance change representation --- src/components/AppSummary/AppSummary.columns.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/AppSummary/AppSummary.columns.js b/src/components/AppSummary/AppSummary.columns.js index 319122109..bff710d41 100644 --- a/src/components/AppSummary/AppSummary.columns.js +++ b/src/components/AppSummary/AppSummary.columns.js @@ -8,6 +8,7 @@ import { formatUsdValue, formatPercentValue, formatUsdValueChange, + shouldShowPercentCheck, } from './AppSummary.helpers' export const getFeesColumns = ({ @@ -142,7 +143,7 @@ export const getAssetColumns = ({ width: 178, renderer: (rowIndex) => { const { balanceUsd, valueChange30dUsd, valueChange30dPerc } = preparedData[rowIndex] - const shouldShowPercentChange = balanceUsd !== valueChange30dUsd + const shouldShowPercentChange = shouldShowPercentCheck(balanceUsd, valueChange30dUsd) return ( <>