2017-06-26 22:27:55 +00:00
|
|
|
// @flow
|
2017-08-23 06:57:18 +00:00
|
|
|
import React from 'react';
|
2017-08-28 18:05:38 +00:00
|
|
|
import translate, { translateRaw } from 'translations';
|
2017-08-23 06:57:18 +00:00
|
|
|
import UnitDropdown from './UnitDropdown';
|
2017-06-26 22:27:55 +00:00
|
|
|
|
|
|
|
type Props = {
|
2017-07-02 05:49:06 +00:00
|
|
|
value: string,
|
|
|
|
unit: string,
|
2017-07-15 23:05:57 +00:00
|
|
|
tokens: string[],
|
2017-07-02 05:49:06 +00:00
|
|
|
onChange?: (value: string, unit: string) => void
|
2017-06-26 22:27:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default class AmountField extends React.Component {
|
2017-07-02 05:49:06 +00:00
|
|
|
props: Props;
|
2017-06-26 22:27:55 +00:00
|
|
|
|
2017-07-02 05:49:06 +00:00
|
|
|
render() {
|
|
|
|
const { value, unit, onChange } = this.props;
|
|
|
|
const isReadonly = !onChange;
|
|
|
|
return (
|
v3 Style Import (#151)
* Convert bootstrap to sass instead of checked in and less
* Darken body, adjust header.
* First pass at tab styles, each tab will need a lot of individual love tho.
* Update footer to main site content, improve responsiveness.
* Missing key added.
* Fix dropdowns.
* Convert GenerateWallet HTML over, still needs styling.
* Send form.
* Current rates styled.
* CurrencySwap form styles.
* SwapInfoHeader styled.
* Finish up swap restyling, minor usability improvements for mobile.
* Fix up notifications / alert customizations
* Import v3 variables.
* Fix notification spacing.
* Align input height base with buttons.
* Revert height base, add additional bootstrap overrides.
* Grid overrides.
* Move overrides to their own folder. Adjust naming.
* Fix inconsistencies.
* Style generate wallet pt 1.
* Style generate wallet pt 2
* Style generate wallet pt 3
* Fix swap
* Added some missing overries, fixed the fallout.
* Remove header text, indicate alpha version.
* Fix radio / checkbox weights.
* Bind => arrow
* Convert simpledropdown to proper form select, instead of weirdly implemented nonfuncitoning dropdown.
* Fix token balances buttons, footr icons.
2017-09-05 19:52:01 +00:00
|
|
|
<div className="row form-group">
|
|
|
|
<div className="col-xs-11">
|
|
|
|
<label>
|
|
|
|
{translate('SEND_amount')}
|
|
|
|
</label>
|
|
|
|
<div className="input-group">
|
|
|
|
<input
|
|
|
|
className={`form-control ${isFinite(Number(value)) &&
|
|
|
|
Number(value) > 0
|
|
|
|
? 'is-valid'
|
|
|
|
: 'is-invalid'}`}
|
|
|
|
type="text"
|
|
|
|
placeholder={translateRaw('SEND_amount_short')}
|
|
|
|
value={value}
|
|
|
|
disabled={isReadonly}
|
|
|
|
onChange={isReadonly ? void 0 : this.onValueChange}
|
|
|
|
/>
|
|
|
|
<UnitDropdown
|
|
|
|
value={unit}
|
|
|
|
options={['ether'].concat(this.props.tokens)}
|
|
|
|
onChange={isReadonly ? void 0 : this.onUnitChange}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
{!isReadonly &&
|
|
|
|
<span className="help-block">
|
|
|
|
<a onClick={this.onSendEverything}>
|
|
|
|
<span className="strong">
|
|
|
|
{translate('SEND_TransferTotal')}
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</span>}
|
2017-07-02 05:49:06 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-06-26 22:27:55 +00:00
|
|
|
|
2017-07-02 05:49:06 +00:00
|
|
|
onUnitChange = (unit: string) => {
|
|
|
|
if (this.props.onChange) {
|
|
|
|
this.props.onChange(this.props.value, unit);
|
|
|
|
}
|
|
|
|
};
|
2017-06-26 22:27:55 +00:00
|
|
|
|
2017-07-02 05:49:06 +00:00
|
|
|
onValueChange = (e: SyntheticInputEvent) => {
|
|
|
|
if (this.props.onChange) {
|
|
|
|
this.props.onChange(e.target.value, this.props.unit);
|
|
|
|
}
|
|
|
|
};
|
2017-06-26 22:27:55 +00:00
|
|
|
|
2017-07-02 05:49:06 +00:00
|
|
|
onSendEverything = () => {
|
|
|
|
if (this.props.onChange) {
|
2017-08-23 06:57:18 +00:00
|
|
|
this.props.onChange('everything', this.props.unit);
|
2017-07-02 05:49:06 +00:00
|
|
|
}
|
|
|
|
};
|
2017-06-26 22:27:55 +00:00
|
|
|
}
|