diff options
author | Francesco Agosti <francesco.agosti93@gmail.com> | 2018-12-06 07:44:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-06 07:44:54 +0800 |
commit | 21122f0137c39835e5cf15e1a5c2bdbd20030611 (patch) | |
tree | b0b38b40bac88612a5dad019e37087e4a27ff054 /packages/website/ts/pages/instant/fee_percentage_slider.tsx | |
parent | e6acc0416a0de54d53c8f50e522ee2a952c58965 (diff) | |
parent | c282c2fcc40b6efbac7c91c3d17b204756359a26 (diff) | |
download | dexon-0x-contracts-21122f0137c39835e5cf15e1a5c2bdbd20030611.tar dexon-0x-contracts-21122f0137c39835e5cf15e1a5c2bdbd20030611.tar.gz dexon-0x-contracts-21122f0137c39835e5cf15e1a5c2bdbd20030611.tar.bz2 dexon-0x-contracts-21122f0137c39835e5cf15e1a5c2bdbd20030611.tar.lz dexon-0x-contracts-21122f0137c39835e5cf15e1a5c2bdbd20030611.tar.xz dexon-0x-contracts-21122f0137c39835e5cf15e1a5c2bdbd20030611.tar.zst dexon-0x-contracts-21122f0137c39835e5cf15e1a5c2bdbd20030611.zip |
Merge pull request #1369 from 0xProject/feature/website/instant-configurator
[website][instant] Instant configurator
Diffstat (limited to 'packages/website/ts/pages/instant/fee_percentage_slider.tsx')
-rw-r--r-- | packages/website/ts/pages/instant/fee_percentage_slider.tsx | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/packages/website/ts/pages/instant/fee_percentage_slider.tsx b/packages/website/ts/pages/instant/fee_percentage_slider.tsx new file mode 100644 index 000000000..4c92883cb --- /dev/null +++ b/packages/website/ts/pages/instant/fee_percentage_slider.tsx @@ -0,0 +1,72 @@ +import Slider from 'rc-slider'; +import 'rc-slider/assets/index.css'; +import * as React from 'react'; + +import { Text } from 'ts/components/ui/text'; +import { colors } from 'ts/style/colors'; +import { injectGlobal } from 'ts/style/theme'; + +const SliderWithTooltip = (Slider as any).createSliderWithTooltip(Slider); +// tslint:disable-next-line:no-unused-expression +injectGlobal` + .rc-slider-tooltip-inner { + box-shadow: none !important; + background-color: ${colors.white} !important; + border-radius: 4px !important; + padding: 3px 12px !important; + height: auto !important; + position: relative; + top: 7px; + &: after { + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; + pointer-events: none; + border-width: 6px; + bottom: 100%; + left: 100%; + border-bottom-color: ${colors.white}; + margin-left: -60%; + } + } +`; + +export interface FeePercentageSliderProps { + value: number; + onChange: (value: number) => void; +} + +export class FeePercentageSlider extends React.Component<FeePercentageSliderProps> { + public render(): React.ReactNode { + return ( + <SliderWithTooltip + min={0} + max={0.05} + step={0.0025} + value={this.props.value} + onChange={this.props.onChange} + tipFormatter={this._feePercentageSliderFormatter} + tipProps={{ placement: 'bottom' }} + trackStyle={{ + backgroundColor: '#b4b4b4', + }} + railStyle={{ + backgroundColor: '#696969', + }} + handleStyle={{ + border: 'none', + boxShadow: 'none', + }} + activeDotStyle={{ + boxShadow: 'none', + border: 'none', + }} + /> + ); + } + private readonly _feePercentageSliderFormatter = (value: number): React.ReactNode => { + return <Text fontColor={colors.black} fontSize="14px" fontWeight={700}>{`${(value * 100).toFixed(2)}%`}</Text>; + }; +} |