From d654b609497e73d9795748706eaf11f26f68a40d Mon Sep 17 00:00:00 2001 From: Daniel Ternyak Date: Thu, 7 Sep 2017 15:14:52 -0500 Subject: [PATCH] Fix Send Regressions (#170) --- common/components/ui/SimpleDropDown.jsx | 62 +++++++++++++++ .../{SimpleDropdown.jsx => SimpleSelect.jsx} | 12 +-- .../components/EnterPassword.jsx | 6 +- .../components/UnitDropdown.jsx | 76 ++++--------------- .../containers/Tabs/SendTransaction/index.jsx | 2 +- .../Tabs/Swap/components/CurrencySwap.jsx | 6 +- common/sass/styles/overrides.scss | 1 + common/sass/styles/overrides/dropdowns.scss | 33 ++++++++ .../sass/styles/overrides/input-groups.scss | 2 +- 9 files changed, 123 insertions(+), 77 deletions(-) create mode 100644 common/components/ui/SimpleDropDown.jsx rename common/components/ui/{SimpleDropdown.jsx => SimpleSelect.jsx} (73%) create mode 100644 common/sass/styles/overrides/dropdowns.scss diff --git a/common/components/ui/SimpleDropDown.jsx b/common/components/ui/SimpleDropDown.jsx new file mode 100644 index 00000000..fa951cb4 --- /dev/null +++ b/common/components/ui/SimpleDropDown.jsx @@ -0,0 +1,62 @@ +// @flow +import React, { Component } from 'react'; + +type Props = { + value?: string, + options: string[], + onChange: (value: string) => void +}; + +export default class SimpleDropDown extends Component { + props: Props; + state: { + expanded: boolean + } = { + expanded: false + }; + + toggleExpanded = () => { + this.setState(state => { + return { expanded: !state.expanded }; + }); + }; + + onClick = (event: SyntheticInputEvent) => { + const value = event.target.getAttribute('data-value') || ''; + this.props.onChange(value); + this.setState({ expanded: false }); + }; + + render() { + const { options, value } = this.props; + const { expanded } = this.state; + return ( +
+ + {value} + + + + {expanded && +
    + {options.map((option, i) => { + return ( +
  • + + {option} + +
  • + ); + })} +
} +
+ ); + } +} diff --git a/common/components/ui/SimpleDropdown.jsx b/common/components/ui/SimpleSelect.jsx similarity index 73% rename from common/components/ui/SimpleDropdown.jsx rename to common/components/ui/SimpleSelect.jsx index 10c5ccb2..49cca406 100644 --- a/common/components/ui/SimpleDropdown.jsx +++ b/common/components/ui/SimpleSelect.jsx @@ -1,20 +1,20 @@ // @flow import React, { Component } from 'react'; -type Props = { - value?: T, - options: Array, +type Props = { + value?: string, + options: string[], onChange: (event: SyntheticInputEvent) => void }; -export default class SimpleDropDown extends Component { - props: Props; +export default class SimpleSelect extends Component { + props: Props; render() { return (