diff options
author | Frankie <frankie.pangilinan@consensys.net> | 2016-10-07 04:03:01 +0800 |
---|---|---|
committer | Frankie <frankie.pangilinan@consensys.net> | 2016-10-11 09:17:56 +0800 |
commit | e1b78da3e6b45037f8b9dacc4385c02c6c892f7c (patch) | |
tree | 0413e9df33ab994f9c015d6c462febd337081c1c /ui/app/components/range-slider.js | |
parent | a52c497ad10a980ec9e84e1a9dcc5122c236bcc2 (diff) | |
download | tangerine-wallet-browser-e1b78da3e6b45037f8b9dacc4385c02c6c892f7c.tar tangerine-wallet-browser-e1b78da3e6b45037f8b9dacc4385c02c6c892f7c.tar.gz tangerine-wallet-browser-e1b78da3e6b45037f8b9dacc4385c02c6c892f7c.tar.bz2 tangerine-wallet-browser-e1b78da3e6b45037f8b9dacc4385c02c6c892f7c.tar.lz tangerine-wallet-browser-e1b78da3e6b45037f8b9dacc4385c02c6c892f7c.tar.xz tangerine-wallet-browser-e1b78da3e6b45037f8b9dacc4385c02c6c892f7c.tar.zst tangerine-wallet-browser-e1b78da3e6b45037f8b9dacc4385c02c6c892f7c.zip |
Add custom gas field to send page
Diffstat (limited to 'ui/app/components/range-slider.js')
-rw-r--r-- | ui/app/components/range-slider.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/ui/app/components/range-slider.js b/ui/app/components/range-slider.js new file mode 100644 index 000000000..6ca6e434e --- /dev/null +++ b/ui/app/components/range-slider.js @@ -0,0 +1,63 @@ +const Component = require('react').Component +const h = require('react-hyperscript') +const inherits = require('util').inherits + +module.exports = RangeSlider + +inherits(RangeSlider, Component) +function RangeSlider () { + Component.call(this) +} + +RangeSlider.prototype.render = function () { + const props = this.props + const onChange = props.onChange || function () {} + const name = props.name + const { + min = 0, + max = 100, + increment = 1, + defaultValue = 50, + mirrorInput = false, + } = this.props.options + const {container, input, range} = props.style + + return ( + h('.flex-row', { + style: container, + }, [ + h('input', { + type: 'range', + name: name, + min: min, + max: max, + step: increment, + style: range, + defaultValue: defaultValue, + onChange: mirrorInput ? this.mirrorInputs.bind(this, name) : onChange, + }), + + // Mirrored input for range + mirrorInput ? h('input.large-input', { + type: 'number', + name: `${name}Mirror`, + min: min, + max: max, + defaultValue: defaultValue, + step: increment, + style: input, + onChange: this.mirrorInputs.bind(this, `${name}Mirror`), + }) : null, + ]) + ) +} + +RangeSlider.prototype.mirrorInputs = function (active) { + var range = document.querySelector(`input[name="${this.props.name}"]`) + var inputMirror = document.querySelector(`input[name="${this.props.name}Mirror"]`) + if (active === this.props.name) { + inputMirror.value = range.value + } else { + range.value = inputMirror.value + } +} |