diff options
author | Kevin Serrano <kevgagser@gmail.com> | 2016-07-12 07:31:12 +0800 |
---|---|---|
committer | Kevin Serrano <kevgagser@gmail.com> | 2016-07-12 07:31:12 +0800 |
commit | 6a61591dad48f20502a64ad22a8d54e18a0a1d21 (patch) | |
tree | bb162c0070201350ac98af1f2d9d7d46d1f08634 /ui/app/components | |
parent | 37f21cf18f3495b255d25cfe57c2cbf495ba6b69 (diff) | |
download | tangerine-wallet-browser-6a61591dad48f20502a64ad22a8d54e18a0a1d21.tar tangerine-wallet-browser-6a61591dad48f20502a64ad22a8d54e18a0a1d21.tar.gz tangerine-wallet-browser-6a61591dad48f20502a64ad22a8d54e18a0a1d21.tar.bz2 tangerine-wallet-browser-6a61591dad48f20502a64ad22a8d54e18a0a1d21.tar.lz tangerine-wallet-browser-6a61591dad48f20502a64ad22a8d54e18a0a1d21.tar.xz tangerine-wallet-browser-6a61591dad48f20502a64ad22a8d54e18a0a1d21.tar.zst tangerine-wallet-browser-6a61591dad48f20502a64ad22a8d54e18a0a1d21.zip |
Move shorten balance to util. Add as property of generateBalance object output.
Diffstat (limited to 'ui/app/components')
-rw-r--r-- | ui/app/components/eth-balance-tx-history.js | 30 | ||||
-rw-r--r-- | ui/app/components/transaction-list-item.js | 2 |
2 files changed, 11 insertions, 21 deletions
diff --git a/ui/app/components/eth-balance-tx-history.js b/ui/app/components/eth-balance-tx-history.js index c3bdc2878..de64dd694 100644 --- a/ui/app/components/eth-balance-tx-history.js +++ b/ui/app/components/eth-balance-tx-history.js @@ -14,8 +14,10 @@ function EthBalanceComponent () { EthBalanceComponent.prototype.render = function () { var state = this.props var style = state.style - var value = formatBalance(state.value) - var maxWidth = state.maxWidth + + const value = formatBalance(state.value) + var width = state.width + return ( h('.ether-balance', { @@ -24,7 +26,7 @@ EthBalanceComponent.prototype.render = function () { h('.ether-balance-amount', { style: { display: 'inline', - maxWidth: maxWidth, + width: width, }, }, this.renderBalance(value, state)), ]) @@ -34,11 +36,12 @@ EthBalanceComponent.prototype.render = function () { EthBalanceComponent.prototype.renderBalance = function (value, state) { if (value === 'None') return value var balanceObj = generateBalanceObject(value) - - var balance = balanceObj.balance + var balance if (state.shorten) { - balance = shortenBalance(balance) + balance = balanceObj.shortBalance + } else { + balance = balanceObj.balance } var label = balanceObj.label @@ -59,6 +62,7 @@ EthBalanceComponent.prototype.renderBalance = function (value, state) { h('div', { style: { width: '100%', + textAlign: 'right', }, }, balance), h('div', { @@ -71,17 +75,3 @@ EthBalanceComponent.prototype.renderBalance = function (value, state) { ]) ) } - -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 4fa7b897c..d4207b3ba 100644 --- a/ui/app/components/transaction-list-item.js +++ b/ui/app/components/transaction-list-item.js @@ -73,7 +73,7 @@ TransactionListItem.prototype.render = function () { isTx ? h(EtherBalance, { value: txParams.value, - maxWidth: '55px', + width: '55px', shorten: true, }) : h('.flex-column'), ]) |