diff options
author | Kevin Serrano <kevgagser@gmail.com> | 2016-07-09 08:27:13 +0800 |
---|---|---|
committer | Kevin Serrano <kevgagser@gmail.com> | 2016-07-09 08:27:13 +0800 |
commit | 20bfb60fd2ef84630a6f653b5f360c96d924b004 (patch) | |
tree | 565e51e113b30498884c2ba9197b5ae5f77c1057 /ui/app/components | |
parent | 58ee3e122749b56a1b723bdf5612414f09b37f22 (diff) | |
download | tangerine-wallet-browser-20bfb60fd2ef84630a6f653b5f360c96d924b004.tar tangerine-wallet-browser-20bfb60fd2ef84630a6f653b5f360c96d924b004.tar.gz tangerine-wallet-browser-20bfb60fd2ef84630a6f653b5f360c96d924b004.tar.bz2 tangerine-wallet-browser-20bfb60fd2ef84630a6f653b5f360c96d924b004.tar.lz tangerine-wallet-browser-20bfb60fd2ef84630a6f653b5f360c96d924b004.tar.xz tangerine-wallet-browser-20bfb60fd2ef84630a6f653b5f360c96d924b004.tar.zst tangerine-wallet-browser-20bfb60fd2ef84630a6f653b5f360c96d924b004.zip |
Implement alternate shortening scheme.
Diffstat (limited to 'ui/app/components')
-rw-r--r-- | ui/app/components/eth-balance-tx-history.js | 29 | ||||
-rw-r--r-- | ui/app/components/transaction-list-item.js | 2 |
2 files changed, 25 insertions, 6 deletions
diff --git a/ui/app/components/eth-balance-tx-history.js b/ui/app/components/eth-balance-tx-history.js index 81166bb45..ca065416a 100644 --- a/ui/app/components/eth-balance-tx-history.js +++ b/ui/app/components/eth-balance-tx-history.js @@ -15,6 +15,7 @@ EthBalanceComponent.prototype.render = function () { var state = this.props var style = state.style var value = formatBalance(state.value) + var maxWidth = state.maxWidth return ( h('.ether-balance', { @@ -23,19 +24,23 @@ EthBalanceComponent.prototype.render = function () { h('.ether-balance-amount', { style: { display: 'inline', - width: '55px', - overflow: 'hidden', + maxWidth: maxWidth, }, - }, this.renderBalance(value)), + }, this.renderBalance(value,state)), ]) ) } -EthBalanceComponent.prototype.renderBalance = function (value) { +EthBalanceComponent.prototype.renderBalance = function (value,state) { if (value === 'None') return value var balanceObj = generateBalanceObject(value) var balance = balanceObj.balance + + if (state.shorten) { + balance = shortenBalance(balance) + } + var label = balanceObj.label return ( @@ -54,8 +59,6 @@ EthBalanceComponent.prototype.renderBalance = function (value) { h('div', { style: { width: '100%', - overflow: 'hidden', - textOverflow: 'ellipsis', }, }, balance), h('div', { @@ -68,3 +71,17 @@ EthBalanceComponent.prototype.renderBalance = function (value) { ]) ) } + +function shortenBalance(balance) { + var truncatedValue + var convertedBalance = parseFloat(balance) + if (convertedBalance > 1000000) { + truncatedValue = (balance/1000000).toFixed(1) + return `${truncatedValue}m` + } else if (convertedBalance > 1000) { + truncatedValue = (balance/1000).toFixed(1) + return `${truncatedValue}k` + } else { + return balance + } +} diff --git a/ui/app/components/transaction-list-item.js b/ui/app/components/transaction-list-item.js index a41226343..4fa7b897c 100644 --- a/ui/app/components/transaction-list-item.js +++ b/ui/app/components/transaction-list-item.js @@ -73,6 +73,8 @@ TransactionListItem.prototype.render = function () { isTx ? h(EtherBalance, { value: txParams.value, + maxWidth: '55px', + shorten: true, }) : h('.flex-column'), ]) ) |