diff options
author | Dan Finlay <flyswatter@users.noreply.github.com> | 2017-07-21 05:05:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-21 05:05:12 +0800 |
commit | 6553c9c64b82a9a26a973f05b5fe7f29a6371828 (patch) | |
tree | 8f2433bb8dd30e5eaba1fdec7271744323dea46d /ui/app/components/qr-code.js | |
parent | 199587383b022a17d56adcb56d6a99ceba71fec7 (diff) | |
parent | 38dccab12e4140bb085f3ea17e642e55f54d68a1 (diff) | |
download | tangerine-wallet-browser-6553c9c64b82a9a26a973f05b5fe7f29a6371828.tar tangerine-wallet-browser-6553c9c64b82a9a26a973f05b5fe7f29a6371828.tar.gz tangerine-wallet-browser-6553c9c64b82a9a26a973f05b5fe7f29a6371828.tar.bz2 tangerine-wallet-browser-6553c9c64b82a9a26a973f05b5fe7f29a6371828.tar.lz tangerine-wallet-browser-6553c9c64b82a9a26a973f05b5fe7f29a6371828.tar.xz tangerine-wallet-browser-6553c9c64b82a9a26a973f05b5fe7f29a6371828.tar.zst tangerine-wallet-browser-6553c9c64b82a9a26a973f05b5fe7f29a6371828.zip |
Merge pull request #1802 from MetaMask/RestructureNewUI
Restructure new ui branch folders
Diffstat (limited to 'ui/app/components/qr-code.js')
-rw-r--r-- | ui/app/components/qr-code.js | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/ui/app/components/qr-code.js b/ui/app/components/qr-code.js new file mode 100644 index 000000000..06b9aed9b --- /dev/null +++ b/ui/app/components/qr-code.js @@ -0,0 +1,79 @@ +const Component = require('react').Component +const h = require('react-hyperscript') +const qrCode = require('qrcode-npm').qrcode +const inherits = require('util').inherits +const connect = require('react-redux').connect +const isHexPrefixed = require('ethereumjs-util').isHexPrefixed +const CopyButton = require('./copyButton') + +module.exports = connect(mapStateToProps)(QrCodeView) + +function mapStateToProps (state) { + return { + Qr: state.appState.Qr, + buyView: state.appState.buyView, + warning: state.appState.warning, + } +} + +inherits(QrCodeView, Component) + +function QrCodeView () { + Component.call(this) +} + +QrCodeView.prototype.render = function () { + const props = this.props + const Qr = props.Qr + const address = `${isHexPrefixed(Qr.data) ? 'ethereum:' : ''}${Qr.data}` + const qrImage = qrCode(4, 'M') + qrImage.addData(address) + qrImage.make() + return h('.main-container.flex-column', { + key: 'qr', + style: { + justifyContent: 'center', + paddingBottom: '45px', + paddingLeft: '45px', + paddingRight: '45px', + alignItems: 'center', + }, + }, [ + Array.isArray(Qr.message) ? h('.message-container', this.renderMultiMessage()) : h('.qr-header', Qr.message), + + this.props.warning ? this.props.warning && h('span.error.flex-center', { + style: { + textAlign: 'center', + width: '229px', + height: '82px', + }, + }, + this.props.warning) : null, + + h('#qr-container.flex-column', { + style: { + marginTop: '25px', + marginBottom: '15px', + }, + dangerouslySetInnerHTML: { + __html: qrImage.createTableTag(4), + }, + }), + h('.flex-row', [ + h('h3.ellip-address', { + style: { + width: '247px', + }, + }, Qr.data), + h(CopyButton, { + value: Qr.data, + }), + ]), + ]) +} + +QrCodeView.prototype.renderMultiMessage = function () { + var Qr = this.props.Qr + var multiMessage = Qr.message.map((message) => h('.qr-message', message)) + return multiMessage +} |