mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Nearly finished factoring fiat value into eth-balance
This commit is contained in:
parent
58a8f02294
commit
09dd854a96
@ -10,7 +10,7 @@ const ReactCSSTransitionGroup = require('react-addons-css-transition-group')
|
||||
const valuesFor = require('./util').valuesFor
|
||||
|
||||
const Identicon = require('./components/identicon')
|
||||
const AccountEtherBalance = require('./components/account-eth-balance')
|
||||
const EthBalance = require('./components/eth-balance')
|
||||
const TransactionList = require('./components/transaction-list')
|
||||
const ExportAccountView = require('./components/account-export')
|
||||
const ethUtil = require('ethereumjs-util')
|
||||
@ -168,7 +168,7 @@ AccountDetailScreen.prototype.render = function () {
|
||||
},
|
||||
}, [
|
||||
|
||||
h(AccountEtherBalance, {
|
||||
h(EthBalance, {
|
||||
value: account && account.balance,
|
||||
style: {
|
||||
lineHeight: '7px',
|
||||
|
@ -3,7 +3,7 @@ const h = require('react-hyperscript')
|
||||
const inherits = require('util').inherits
|
||||
const ethUtil = require('ethereumjs-util')
|
||||
|
||||
const AccountEtherBalance = require('../components/account-eth-balance')
|
||||
const EthBalance = require('../components/eth-balance')
|
||||
const CopyButton = require('../components/copyButton')
|
||||
const Identicon = require('../components/identicon')
|
||||
|
||||
@ -50,7 +50,7 @@ NewComponent.prototype.render = function () {
|
||||
textOverflow: 'ellipsis',
|
||||
},
|
||||
}, ethUtil.toChecksumAddress(identity.address)),
|
||||
h(AccountEtherBalance, {
|
||||
h(EthBalance, {
|
||||
value: account.balance,
|
||||
style: {
|
||||
lineHeight: '7px',
|
||||
|
@ -245,7 +245,7 @@ App.prototype.renderNetworkDropdown = function () {
|
||||
label: 'Localhost 8545',
|
||||
closeMenu: () => this.setState({ isNetworkMenuOpen: false }),
|
||||
action: () => props.dispatch(actions.setRpcTarget('http://localhost:8545')),
|
||||
icon: h('i.fa.fa-question-circle.fa-lg', { ariaHidden: true }),
|
||||
icon: h('i.fa.fa-question-circle.fa-lg'),
|
||||
activeNetworkRender: props.provider.rpcTarget,
|
||||
}),
|
||||
|
||||
@ -253,7 +253,7 @@ App.prototype.renderNetworkDropdown = function () {
|
||||
label: 'Custom RPC',
|
||||
closeMenu: () => this.setState({ isNetworkMenuOpen: false }),
|
||||
action: () => this.props.dispatch(actions.showConfigPage()),
|
||||
icon: h('i.fa.fa-question-circle.fa-lg', { ariaHidden: true }),
|
||||
icon: h('i.fa.fa-question-circle.fa-lg'),
|
||||
}),
|
||||
|
||||
this.renderCustomOption(props.provider.rpcTarget),
|
||||
@ -289,21 +289,21 @@ App.prototype.renderDropdown = function () {
|
||||
label: 'Settings',
|
||||
closeMenu: () => this.setState({ isMainMenuOpen: !isOpen }),
|
||||
action: () => this.props.dispatch(actions.showConfigPage()),
|
||||
icon: h('i.fa.fa-gear.fa-lg', { ariaHidden: true }),
|
||||
icon: h('i.fa.fa-gear.fa-lg'),
|
||||
}),
|
||||
|
||||
h(DropMenuItem, {
|
||||
label: 'Lock',
|
||||
closeMenu: () => this.setState({ isMainMenuOpen: !isOpen }),
|
||||
action: () => this.props.dispatch(actions.lockMetamask()),
|
||||
icon: h('i.fa.fa-lock.fa-lg', { ariaHidden: true }),
|
||||
icon: h('i.fa.fa-lock.fa-lg'),
|
||||
}),
|
||||
|
||||
h(DropMenuItem, {
|
||||
label: 'Help',
|
||||
closeMenu: () => this.setState({ isMainMenuOpen: !isOpen }),
|
||||
action: () => this.props.dispatch(actions.showInfoPage()),
|
||||
icon: h('i.fa.fa-question.fa-lg', { ariaHidden: true }),
|
||||
icon: h('i.fa.fa-question.fa-lg'),
|
||||
}),
|
||||
])
|
||||
}
|
||||
@ -312,7 +312,6 @@ App.prototype.renderBackButton = function (style, justArrow = false) {
|
||||
return (
|
||||
h('.flex-row', {
|
||||
key: 'leftArrow',
|
||||
transForward: false,
|
||||
style: style,
|
||||
onClick: () => props.dispatch(actions.goBackToInitView()),
|
||||
}, [
|
||||
@ -515,14 +514,14 @@ App.prototype.renderCustomOption = function (rpcTarget) {
|
||||
label: 'Custom RPC',
|
||||
closeMenu: () => this.setState({ isNetworkMenuOpen: false }),
|
||||
action: () => this.props.dispatch(actions.showConfigPage()),
|
||||
icon: h('i.fa.fa-question-circle.fa-lg', { ariaHidden: true }),
|
||||
icon: h('i.fa.fa-question-circle.fa-lg'),
|
||||
})
|
||||
|
||||
default:
|
||||
return h(DropMenuItem, {
|
||||
label: `${rpcTarget}`,
|
||||
closeMenu: () => this.setState({ isNetworkMenuOpen: false }),
|
||||
icon: h('i.fa.fa-question-circle.fa-lg', { ariaHidden: true }),
|
||||
icon: h('i.fa.fa-question-circle.fa-lg'),
|
||||
activeNetworkRender: 'custom',
|
||||
})
|
||||
}
|
||||
|
@ -1,89 +0,0 @@
|
||||
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')
|
||||
const FiatValue = require('./fiat-value')
|
||||
|
||||
module.exports = EthBalanceComponent
|
||||
|
||||
inherits(EthBalanceComponent, Component)
|
||||
function EthBalanceComponent () {
|
||||
Component.call(this)
|
||||
}
|
||||
|
||||
EthBalanceComponent.prototype.render = function () {
|
||||
var props = this.props
|
||||
var style = props.style
|
||||
|
||||
var width = props.width
|
||||
|
||||
return (
|
||||
|
||||
h('.ether-balance', {
|
||||
style: style,
|
||||
}, [
|
||||
h('.ether-balance-amount', {
|
||||
style: {
|
||||
display: 'inline',
|
||||
width: width,
|
||||
},
|
||||
}, this.renderBalance()),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
EthBalanceComponent.prototype.renderBalance = function () {
|
||||
const props = this.props
|
||||
const value = formatBalance(props.value, 6)
|
||||
|
||||
if (value === 'None') return value
|
||||
var balanceObj = generateBalanceObject(value, props.shorten ? 1 : 3)
|
||||
var balance
|
||||
var splitBalance = value.split(' ')
|
||||
var ethNumber = splitBalance[0]
|
||||
var ethSuffix = splitBalance[1]
|
||||
|
||||
if (props.shorten) {
|
||||
balance = balanceObj.shortBalance
|
||||
} else {
|
||||
balance = balanceObj.balance
|
||||
}
|
||||
|
||||
var label = balanceObj.label
|
||||
|
||||
return (
|
||||
h('.flex-column', [
|
||||
h(Tooltip, {
|
||||
position: 'bottom',
|
||||
title: `${ethNumber} ${ethSuffix}`,
|
||||
}, [
|
||||
h('.flex-row', {
|
||||
style: {
|
||||
alignItems: 'flex-end',
|
||||
lineHeight: '13px',
|
||||
fontFamily: 'Montserrat Light',
|
||||
textRendering: 'geometricPrecision',
|
||||
marginBottom: '5px',
|
||||
},
|
||||
}, [
|
||||
h('div', {
|
||||
style: {
|
||||
width: '100%',
|
||||
textAlign: 'right',
|
||||
},
|
||||
}, balance),
|
||||
h('div', {
|
||||
style: {
|
||||
color: '#AEAEAE',
|
||||
marginLeft: '5px',
|
||||
},
|
||||
}, label),
|
||||
]),
|
||||
]),
|
||||
h(FiatValue, { value: props.value }),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ EthBalanceComponent.prototype.render = function () {
|
||||
var needsParse = this.props.needsParse !== undefined ? this.props.needsParse : true
|
||||
const value = formatBalance(props.value, 6, needsParse)
|
||||
var width = props.width
|
||||
const showFiat = 'showFiat' in props ? props.showFiat : true
|
||||
|
||||
return (
|
||||
|
||||
@ -44,6 +43,7 @@ EthBalanceComponent.prototype.renderBalance = function (value) {
|
||||
var splitBalance = value.split(' ')
|
||||
var ethNumber = splitBalance[0]
|
||||
var ethSuffix = splitBalance[1]
|
||||
const showFiat = 'showFiat' in props ? props.showFiat : true
|
||||
|
||||
if (props.shorten) {
|
||||
balance = balanceObj.shortBalance
|
||||
@ -80,7 +80,7 @@ EthBalanceComponent.prototype.renderBalance = function (value) {
|
||||
}, label),
|
||||
]),
|
||||
|
||||
fiatValue ? h(FiatValue, { value: props.value }) : null,
|
||||
showFiat ? h(FiatValue, { value: props.value }) : null,
|
||||
])
|
||||
)
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ const inherits = require('util').inherits
|
||||
const connect = require('react-redux').connect
|
||||
const formatBalance = require('../util').formatBalance
|
||||
const generateBalanceObject = require('../util').generateBalanceObject
|
||||
const Tooltip = require('./tooltip.js')
|
||||
const Tooltip = require('./tooltip')
|
||||
|
||||
module.exports = connect(mapStateToProps)(FiatValue)
|
||||
|
||||
@ -25,7 +25,6 @@ FiatValue.prototype.render = function () {
|
||||
const value = formatBalance(props.value, 6)
|
||||
|
||||
if (value === 'None') return value
|
||||
var balanceObj = generateBalanceObject(value, props.shorten ? 1 : 3)
|
||||
var fiatDisplayNumber, fiatTooltipNumber
|
||||
var splitBalance = value.split(' ')
|
||||
|
||||
|
@ -75,7 +75,6 @@ Network.prototype.render = function () {
|
||||
default:
|
||||
return h('.network-indicator', [
|
||||
h('i.fa.fa-question-circle.fa-lg', {
|
||||
ariaHidden: true,
|
||||
style: {
|
||||
margin: '10px',
|
||||
color: 'rgb(125, 128, 130)',
|
||||
|
@ -12,11 +12,12 @@ function Tooltip () {
|
||||
|
||||
Tooltip.prototype.render = function () {
|
||||
const props = this.props
|
||||
const { position, title, children } = props
|
||||
|
||||
return h(ReactTooltip, {
|
||||
position: props.position ? props.position : 'left',
|
||||
title: props.title,
|
||||
position: position || 'left',
|
||||
title,
|
||||
fixed: false,
|
||||
}, props.children)
|
||||
}, children)
|
||||
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ TransactionListItem.prototype.render = function () {
|
||||
value: txParams.value,
|
||||
width: '55px',
|
||||
shorten: true,
|
||||
showFiat: false,
|
||||
style: {fontSize: '15px'},
|
||||
}) : h('.flex-column'),
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user