diff options
author | kumavis <kumavis@users.noreply.github.com> | 2016-07-09 12:37:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-09 12:37:06 +0800 |
commit | 5bb075a27810064b967dbee169f35abf449fd714 (patch) | |
tree | 52c584fedfa9b11825c4ab800b083d01d88ad26c /ui | |
parent | 6d44eaefcbfb860c0982225fb17227c73097e649 (diff) | |
parent | 40d2b7fe71b6e70e5f058aac4f6306ef005fd69b (diff) | |
download | tangerine-wallet-browser-5bb075a27810064b967dbee169f35abf449fd714.tar tangerine-wallet-browser-5bb075a27810064b967dbee169f35abf449fd714.tar.gz tangerine-wallet-browser-5bb075a27810064b967dbee169f35abf449fd714.tar.bz2 tangerine-wallet-browser-5bb075a27810064b967dbee169f35abf449fd714.tar.lz tangerine-wallet-browser-5bb075a27810064b967dbee169f35abf449fd714.tar.xz tangerine-wallet-browser-5bb075a27810064b967dbee169f35abf449fd714.tar.zst tangerine-wallet-browser-5bb075a27810064b967dbee169f35abf449fd714.zip |
Merge pull request #418 from MetaMask/ui-fixth-width-tx-history
Fixed width applied on transaction history components
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/components/eth-balance-tx-history.js | 87 | ||||
-rw-r--r-- | ui/app/components/transaction-list-item.js | 9 |
2 files changed, 94 insertions, 2 deletions
diff --git a/ui/app/components/eth-balance-tx-history.js b/ui/app/components/eth-balance-tx-history.js new file mode 100644 index 000000000..c3bdc2878 --- /dev/null +++ b/ui/app/components/eth-balance-tx-history.js @@ -0,0 +1,87 @@ +const Component = require('react').Component +const h = require('react-hyperscript') +const inherits = require('util').inherits +const formatBalance = require('../util').formatBalance +const generateBalanceObject = require('../util').generateBalanceObject +const Tooltip = require('./tooltip.js') +module.exports = EthBalanceComponent + +inherits(EthBalanceComponent, Component) +function EthBalanceComponent () { + Component.call(this) +} + +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', { + style: style, + }, [ + h('.ether-balance-amount', { + style: { + display: 'inline', + maxWidth: maxWidth, + }, + }, this.renderBalance(value, state)), + ]) + + ) +} +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 ( + h(Tooltip, { + position: 'bottom', + title: value.split(' ')[0], + }, [ + h('.flex-column', { + style: { + alignItems: 'flex-end', + lineHeight: '13px', + fontFamily: 'Montserrat Light', + textRendering: 'geometricPrecision', + }, + }, [ + h('div', { + style: { + width: '100%', + }, + }, balance), + h('div', { + style: { + color: ' #AEAEAE', + fontSize: '12px', + }, + }, label), + ]), + ]) + ) +} + +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 0cd2f32a7..4fa7b897c 100644 --- a/ui/app/components/transaction-list-item.js +++ b/ui/app/components/transaction-list-item.js @@ -2,7 +2,7 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits -const EtherBalance = require('./eth-balance') +const EtherBalance = require('./eth-balance-tx-history') const addressSummary = require('../util').addressSummary const explorerLink = require('../../lib/explorer-link') const CopyButton = require('./copyButton') @@ -62,7 +62,7 @@ TransactionListItem.prototype.render = function () { : h(TransactionIcon, { txParams, transaction, isTx, isMsg }), ]), - h('.flex-column', [ + h('.flex-column', {style: {width: '200px', overflow: 'hidden'}}, [ domainField(txParams), h('div', date), recipientField(txParams, transaction, isTx, isMsg), @@ -73,6 +73,8 @@ TransactionListItem.prototype.render = function () { isTx ? h(EtherBalance, { value: txParams.value, + maxWidth: '55px', + shorten: true, }) : h('.flex-column'), ]) ) @@ -83,6 +85,9 @@ function domainField (txParams) { style: { fontSize: 'x-small', color: '#ABA9AA', + overflow: 'hidden', + textOverflow: 'ellipsis', + width: '100%', }, }, [ txParams.origin, |