Refactor gas-fee-display to include usd and eth fee displays as separate components.

feature/default_network_editable
Dan 7 years ago committed by Chi Kei Chan
parent 5a7e4c4e76
commit 3ea841e276
  1. 37
      ui/app/components/send/eth-fee-display.js
  2. 45
      ui/app/components/send/gas-fee-display.js
  3. 35
      ui/app/components/send/usd-fee-display.js

@ -0,0 +1,37 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
const EthBalance = require('../eth-balance')
const { getTxFeeBn } = require('../../util')
module.exports = EthFeeDisplay
inherits(EthFeeDisplay, Component)
function EthFeeDisplay () {
Component.call(this)
}
EthFeeDisplay.prototype.render = function () {
const {
currentCurrency,
conversionRate,
gas,
gasPrice,
blockGasLimit,
} = this.props
return h(EthBalance, {
value: getTxFeeBn(gas, gasPrice, blockGasLimit),
currentCurrency,
conversionRate,
showFiat: false,
hideTooltip: true,
styleOveride: {
color: '#5d5d5d',
fontSize: '16px',
fontFamily: 'DIN OT',
lineHeight: '22.4px'
}
})
}

@ -1,9 +1,8 @@
const Component = require('react').Component const Component = require('react').Component
const h = require('react-hyperscript') const h = require('react-hyperscript')
const inherits = require('util').inherits const inherits = require('util').inherits
const EthBalance = require('../eth-balance') const USDFeeDisplay = require('./usd-fee-display')
const FiatValue = require('../fiat-value') const EthFeeDisplay = require('./eth-fee-display')
const { getTxFeeBn } = require('../../util')
module.exports = GasFeeDisplay module.exports = GasFeeDisplay
@ -21,33 +20,25 @@ GasFeeDisplay.prototype.render = function () {
blockGasLimit, blockGasLimit,
} = this.props } = this.props
const renderableCurrencies = { switch (currentCurrency) {
USD: h(FiatValue, { case 'USD':
value: getTxFeeBn(gas, gasPrice, blockGasLimit), return h(USDFeeDisplay, {
conversionRate,
currentCurrency, currentCurrency,
style: { conversionRate,
color: '#5d5d5d', gas,
fontSize: '16px', gasPrice,
fontFamily: 'DIN OT', blockGasLimit,
lineHeight: '22.4px' })
} case 'ETH':
}), return h(EthFeeDisplay, {
ETH: h(EthBalance, {
value: getTxFeeBn(gas, gasPrice, blockGasLimit),
currentCurrency, currentCurrency,
conversionRate, conversionRate,
showFiat: false, gas,
hideTooltip: true, gasPrice,
styleOveride: { blockGasLimit,
color: '#5d5d5d', })
fontSize: '16px', default:
fontFamily: 'DIN OT', return h('noscript');
lineHeight: '22.4px'
}
}),
} }
return renderableCurrencies[currentCurrency];
} }

@ -0,0 +1,35 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
const FiatValue = require('../fiat-value')
const { getTxFeeBn } = require('../../util')
module.exports = USDFeeDisplay
inherits(USDFeeDisplay, Component)
function USDFeeDisplay () {
Component.call(this)
}
USDFeeDisplay.prototype.render = function () {
const {
currentCurrency,
conversionRate,
gas,
gasPrice,
blockGasLimit,
} = this.props
return h(FiatValue, {
value: getTxFeeBn(gas, gasPrice, blockGasLimit),
conversionRate,
currentCurrency,
style: {
color: '#5d5d5d',
fontSize: '16px',
fontFamily: 'DIN OT',
lineHeight: '22.4px'
}
})
}
Loading…
Cancel
Save