William O'Beirne de7d4fbaa2 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 14:52:01 -05:00

76 lines
2.0 KiB
JavaScript

// @flow
import React from 'react';
import { Identicon } from 'components/ui';
import { getEnsAddress } from 'selectors/ens';
import { connect } from 'react-redux';
import type { State } from 'reducers';
import { isValidENSorEtherAddress, isValidENSAddress } from 'libs/validators';
import { resolveEnsName } from 'actions/ens';
import translate from 'translations';
type PublicProps = {
placeholder: string,
value: string,
onChange?: (value: string) => void
};
export class AddressField extends React.Component {
props: PublicProps & {
ensAddress: ?string,
resolveEnsName: typeof resolveEnsName
};
render() {
const { placeholder, value, ensAddress } = this.props;
const isReadonly = !this.props.onChange;
return (
<div className="row form-group">
<div className="col-xs-11">
<label>
{translate('SEND_addr')}:
</label>
<input
className={`form-control ${isValidENSorEtherAddress(value)
? 'is-valid'
: 'is-invalid'}`}
type="text"
value={value}
placeholder={placeholder}
onChange={this.onChange}
disabled={isReadonly}
/>
{!!ensAddress &&
<p className="ens-response">
<span className="mono">{ensAddress}</span>
</p>}
</div>
<div className="col-xs-1" style={{ padding: 0 }}>
<Identicon address={ensAddress || value} />
</div>
</div>
);
}
onChange = (e: SyntheticInputEvent) => {
const newValue = e.target.value;
const { onChange } = this.props;
if (!onChange) {
return;
}
// FIXME debounce?
if (isValidENSAddress(newValue)) {
this.props.resolveEnsName(newValue);
}
onChange(newValue);
};
}
function mapStateToProps(state: State, props: PublicProps) {
return {
ensAddress: getEnsAddress(state, props.value)
};
}
export default connect(mapStateToProps, { resolveEnsName })(AddressField);