diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-01-04 03:06:08 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@gmail.com> | 2018-01-04 03:06:08 +0800 |
commit | a6f062a6865d3e1e5ceb98885ab4b38713e4293d (patch) | |
tree | ea379a341cc19f8942536b1800c309f7d79b3583 /ui/app/components/send/currency-toggle.js | |
parent | 313b3c087a09bcc4462da15ff3caeac515967cf5 (diff) | |
parent | dfb22471087f040d8345a5a17321e1462842045c (diff) | |
download | tangerine-wallet-browser-a6f062a6865d3e1e5ceb98885ab4b38713e4293d.tar tangerine-wallet-browser-a6f062a6865d3e1e5ceb98885ab4b38713e4293d.tar.gz tangerine-wallet-browser-a6f062a6865d3e1e5ceb98885ab4b38713e4293d.tar.bz2 tangerine-wallet-browser-a6f062a6865d3e1e5ceb98885ab4b38713e4293d.tar.lz tangerine-wallet-browser-a6f062a6865d3e1e5ceb98885ab4b38713e4293d.tar.xz tangerine-wallet-browser-a6f062a6865d3e1e5ceb98885ab4b38713e4293d.tar.zst tangerine-wallet-browser-a6f062a6865d3e1e5ceb98885ab4b38713e4293d.zip |
Merge branch 'NewUI-flat' into NewUI-flat-4.0.5c
Diffstat (limited to 'ui/app/components/send/currency-toggle.js')
-rw-r--r-- | ui/app/components/send/currency-toggle.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/ui/app/components/send/currency-toggle.js b/ui/app/components/send/currency-toggle.js new file mode 100644 index 000000000..7aaccd490 --- /dev/null +++ b/ui/app/components/send/currency-toggle.js @@ -0,0 +1,44 @@ +const Component = require('react').Component +const h = require('react-hyperscript') +const inherits = require('util').inherits +const classnames = require('classnames') + +module.exports = CurrencyToggle + +inherits(CurrencyToggle, Component) +function CurrencyToggle () { + Component.call(this) +} + +const defaultCurrencies = [ 'ETH', 'USD' ] + +CurrencyToggle.prototype.renderToggles = function () { + const { onClick, activeCurrency } = this.props + const [currencyA, currencyB] = this.props.currencies || defaultCurrencies + + return [ + h('span', { + className: classnames('currency-toggle__item', { + 'currency-toggle__item--selected': currencyA === activeCurrency, + }), + onClick: () => onClick(currencyA), + }, [ currencyA ]), + '<>', + h('span', { + className: classnames('currency-toggle__item', { + 'currency-toggle__item--selected': currencyB === activeCurrency, + }), + onClick: () => onClick(currencyB), + }, [ currencyB ]), + ] +} + +CurrencyToggle.prototype.render = function () { + const currencies = this.props.currencies || defaultCurrencies + + return h('span.currency-toggle', currencies.length + ? this.renderToggles() + : [] + ) +} + |