Display less than for low balances (#485)

* Display less than for short balances.

* show 4 decimals places for short value
This commit is contained in:
William O'Beirne 2017-11-28 19:28:30 -05:00 committed by Daniel Ternyak
parent 1221a73a46
commit 2451f817d4
1 changed files with 10 additions and 4 deletions

View File

@ -58,10 +58,16 @@ const UnitDisplay: React.SFC<EthProps | TokenProps> = params => {
if (displayShortBalance) {
const digits =
typeof displayShortBalance === 'number' && displayShortBalance;
formattedValue = digits
? format(convertedValue, digits)
: format(convertedValue);
typeof displayShortBalance === 'number' ? displayShortBalance : 4;
formattedValue = format(convertedValue, digits);
// If the formatted value was too low, display something like < 0.01
if (
parseFloat(formattedValue) === 0 &&
parseFloat(convertedValue) !== 0
) {
const padding = digits !== 0 ? `.${'0'.repeat(digits - 1)}1` : '';
formattedValue = `< 0${padding}`;
}
} else {
formattedValue = convertedValue;
}