aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website
diff options
context:
space:
mode:
authorBrandon Millman <brandon@0xproject.com>2018-06-07 02:44:06 +0800
committerGitHub <noreply@github.com>2018-06-07 02:44:06 +0800
commitda3f783a9ff69b059b1a98f502d980660d6bacab (patch)
tree73704330b1c0f33473822f259e9fee15c39bf958 /packages/website
parentb1e8545981de55088abcdfa6273a3cc7bc338e77 (diff)
parentd75fec0ceeb420763aa8ec9fb645ba6f286f8672 (diff)
downloaddexon-sol-tools-da3f783a9ff69b059b1a98f502d980660d6bacab.tar
dexon-sol-tools-da3f783a9ff69b059b1a98f502d980660d6bacab.tar.gz
dexon-sol-tools-da3f783a9ff69b059b1a98f502d980660d6bacab.tar.bz2
dexon-sol-tools-da3f783a9ff69b059b1a98f502d980660d6bacab.tar.lz
dexon-sol-tools-da3f783a9ff69b059b1a98f502d980660d6bacab.tar.xz
dexon-sol-tools-da3f783a9ff69b059b1a98f502d980660d6bacab.tar.zst
dexon-sol-tools-da3f783a9ff69b059b1a98f502d980660d6bacab.zip
Merge pull request #669 from 0xProject/bug/website/fix-balance-rendering
Update balance amount rendering logic
Diffstat (limited to 'packages/website')
-rw-r--r--packages/website/ts/components/wallet/wallet.tsx23
1 files changed, 14 insertions, 9 deletions
diff --git a/packages/website/ts/components/wallet/wallet.tsx b/packages/website/ts/components/wallet/wallet.tsx
index 37233930e..43603bd75 100644
--- a/packages/website/ts/components/wallet/wallet.tsx
+++ b/packages/website/ts/components/wallet/wallet.tsx
@@ -135,7 +135,7 @@ const styles: Styles = {
const ETHER_ICON_PATH = '/images/ether.png';
const ICON_DIMENSION = 28;
-const TOKEN_AMOUNT_DISPLAY_PRECISION = 3;
+const TOKEN_AMOUNT_DISPLAY_PRECISION = 5;
const BODY_ITEM_KEY = 'BODY';
const HEADER_ITEM_KEY = 'HEADER';
const FOOTER_ITEM_KEY = 'FOOTER';
@@ -448,14 +448,19 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
symbol: string,
isLoading: boolean = false,
): React.ReactNode {
- const unitAmount = Web3Wrapper.toUnitAmount(amount, decimals);
- const formattedAmount = unitAmount.toPrecision(TOKEN_AMOUNT_DISPLAY_PRECISION);
- const result = `${formattedAmount} ${symbol}`;
- return (
- <PlaceHolder hideChildren={isLoading}>
- <div style={styles.amountLabel}>{result}</div>
- </PlaceHolder>
- );
+ if (isLoading) {
+ return (
+ <PlaceHolder hideChildren={isLoading}>
+ <div style={styles.amountLabel}>0.00 XXX</div>
+ </PlaceHolder>
+ );
+ } else {
+ const unitAmount = Web3Wrapper.toUnitAmount(amount, decimals);
+ const precision = Math.min(TOKEN_AMOUNT_DISPLAY_PRECISION, unitAmount.decimalPlaces());
+ const formattedAmount = unitAmount.toFixed(precision);
+ const result = `${formattedAmount} ${symbol}`;
+ return <div style={styles.amountLabel}>{result}</div>;
+ }
}
private _renderValue(
amount: BigNumber,