Fix Send Regressions (#170)

This commit is contained in:
Daniel Ternyak 2017-09-07 15:14:52 -05:00 committed by GitHub
parent e3d3b2c8e8
commit d654b60949
9 changed files with 123 additions and 77 deletions

View File

@ -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 (
<div className={`dropdown ${expanded ? 'open' : ''}`}>
<a
className="btn btn-default dropdown-toggle"
onClick={this.toggleExpanded}
>
{value}
<i className="caret" />
</a>
{expanded &&
<ul className="dropdown-menu dropdown-menu-right">
{options.map((option, i) => {
return (
<li key={i}>
<a
className={option === value ? 'active' : ''}
onClick={this.onClick}
data-value={option}
>
{option}
</a>
</li>
);
})}
</ul>}
</div>
);
}
}

View File

@ -1,20 +1,20 @@
// @flow // @flow
import React, { Component } from 'react'; import React, { Component } from 'react';
type Props<T> = { type Props = {
value?: T, value?: string,
options: Array<T>, options: string[],
onChange: (event: SyntheticInputEvent) => void onChange: (event: SyntheticInputEvent) => void
}; };
export default class SimpleDropDown<T: *> extends Component { export default class SimpleSelect extends Component {
props: Props<T>; props: Props;
render() { render() {
return ( return (
<select <select
value={this.props.value || this.props.options[0]} value={this.props.value || this.props.options[0]}
className="form-control" className={'form-control'}
onChange={this.props.onChange} onChange={this.props.onChange}
> >
{this.props.options.map((obj, i) => { {this.props.options.map((obj, i) => {

View File

@ -93,7 +93,7 @@ class EnterPassword extends Component {
<span> <span>
{' '}{translate('GEN_Help_2')} {' '}{translate('GEN_Help_2')}
</span> </span>
<span translate="GEN_Help_3" className="ng-scope"> <span>
{' '}{translate('GEN_Help_3')} {' '}{translate('GEN_Help_3')}
</span> </span>
</li> </li>
@ -129,9 +129,7 @@ class EnterPassword extends Component {
</li> </li>
</ul> </ul>
<h4 translate="GEN_Help_4" className="ng-scope"> <h4>Guides & FAQ</h4>
Guides & FAQ
</h4>
<ul> <ul>
<li> <li>
<strong> <strong>

View File

@ -1,34 +1,16 @@
// @flow // @flow
import React from 'react'; import React from 'react';
import SimpleDropDown from 'components/ui/SimpleDropDown';
class Option extends React.Component { type UnitDropdownProps = {
props: {
value: string,
active: boolean,
onChange: (value: string) => void
};
render() {
const { value, active } = this.props;
return (
<li>
<a className={active ? 'active' : ''} onClick={this.onChange}>
{value}
</a>
</li>
);
}
onChange = () => {
this.props.onChange(this.props.value);
};
}
export default class UnitDropdown extends React.Component {
props: {
value: string, value: string,
options: string[], options: string[],
onChange?: (value: string) => void onChange?: (value: string) => void
}; };
export default class UnitDropdown extends React.Component {
props: UnitDropdownProps;
state: { state: {
expanded: boolean expanded: boolean
} = { } = {
@ -36,50 +18,20 @@ export default class UnitDropdown extends React.Component {
}; };
render() { render() {
const { value, options, onChange } = this.props; const { value, options } = this.props;
const isReadonly = !onChange;
return ( return (
<div className="input-group-btn"> <div className="input-group-btn">
<a <SimpleDropDown
style={{ minWidth: 170 }} value={value}
className="btn btn-default dropdown-toggle"
onClick={this.onToggleExpand}
>
<strong>
{value}
<i className="caret" />
</strong>
</a>
{this.state.expanded &&
!isReadonly &&
<ul className="dropdown-menu dropdown-menu-right">
{options.map(o =>
<Option
key={o}
active={value === o}
value={o}
onChange={this.onChange} onChange={this.onChange}
options={options}
/> />
)}
</ul>}
</div> </div>
); );
} }
onToggleExpand = () => {
this.setState(state => {
return {
expanded: !state.expanded
};
});
};
onChange = (value: string) => { onChange = (value: string) => {
this.setState({
expanded: false
});
if (this.props.onChange) { if (this.props.onChange) {
this.props.onChange(value); this.props.onChange(value);
} }

View File

@ -412,7 +412,7 @@ export class SendTransaction extends React.Component {
const weiBalance = toWei(balance, 'ether'); const weiBalance = toWei(balance, 'ether');
value = getBalanceMinusGasCosts( value = getBalanceMinusGasCosts(
new Big(gasLimit), new Big(gasLimit),
gasPrice, new Big(gasPrice),
weiBalance weiBalance
); );
} else { } else {

View File

@ -2,7 +2,7 @@ import './CurrencySwap.scss';
import React, { Component } from 'react'; import React, { Component } from 'react';
import translate from 'translations'; import translate from 'translations';
import { combineAndUpper } from 'utils/formatters'; import { combineAndUpper } from 'utils/formatters';
import SimpleDropDown from 'components/ui/SimpleDropdown'; import SimpleSelect from 'components/ui/SimpleSelect';
import SimpleButton from 'components/ui/SimpleButton'; import SimpleButton from 'components/ui/SimpleButton';
import type { import type {
OriginKindSwapAction, OriginKindSwapAction,
@ -183,7 +183,7 @@ export default class CurrencySwap extends Component {
onChange={this.onChangeOriginAmount} onChange={this.onChangeOriginAmount}
/> />
<SimpleDropDown <SimpleSelect
value={originKind} value={originKind}
onChange={this.onChangeOriginKind.bind(this)} onChange={this.onChangeOriginKind.bind(this)}
options={originKindOptions} options={originKindOptions}
@ -208,7 +208,7 @@ export default class CurrencySwap extends Component {
onChange={this.onChangeDestinationAmount} onChange={this.onChangeDestinationAmount}
/> />
<SimpleDropDown <SimpleSelect
value={destinationKind} value={destinationKind}
onChange={this.onChangeDestinationKind} onChange={this.onChangeDestinationKind}
options={destinationKindOptions} options={destinationKindOptions}

View File

@ -3,6 +3,7 @@
@import "./overrides/alerts"; @import "./overrides/alerts";
@import "./overrides/buttons"; @import "./overrides/buttons";
@import "./overrides/button-groups"; @import "./overrides/button-groups";
@import "./overrides/dropdowns";
@import "./overrides/forms"; @import "./overrides/forms";
@import "./overrides/grid"; @import "./overrides/grid";
@import "./overrides/input-groups"; @import "./overrides/input-groups";

View File

@ -0,0 +1,33 @@
// Button overrides
@import "common/sass/variables";
.dropdown {
.caret {
margin-left: $space-sm;
}
}
.dropdown-menu {
padding: 0;
border: none;
> li {
margin: 0;
&:first-child {
padding-top: 4px;
}
&:last-child {
padding-bottom: 4px;
}
> a {
font-weight: 300;
&.active {
color: $link-color;
}
}
}
}

View File

@ -19,7 +19,7 @@
} }
.input-group-btn { .input-group-btn {
> .btn { .btn {
margin-bottom: 0; margin-bottom: 0;
margin-top: 0; margin-top: 0;
font-size: $font-size-base; font-size: $font-size-base;