2017-09-25 02:06:28 +00:00
|
|
|
import { resolveEnsName } from 'actions/ens';
|
2017-06-26 22:27:55 +00:00
|
|
|
import { Identicon } from 'components/ui';
|
2017-09-25 02:06:28 +00:00
|
|
|
import { isValidENSAddress, isValidENSorEtherAddress } from 'libs/validators';
|
|
|
|
import React from 'react';
|
2017-06-26 22:27:55 +00:00
|
|
|
import { connect } from 'react-redux';
|
2017-09-25 02:06:28 +00:00
|
|
|
import { AppState } from 'reducers';
|
|
|
|
import { getEnsAddress } from 'selectors/ens';
|
2017-07-06 00:36:11 +00:00
|
|
|
import translate from 'translations';
|
2017-06-26 22:27:55 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
interface PublicProps {
|
|
|
|
placeholder: string;
|
|
|
|
value: string;
|
|
|
|
onChange: ((value: string) => void) | null;
|
|
|
|
}
|
2017-06-26 22:27:55 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
interface Props extends PublicProps {
|
|
|
|
ensAddress: string | null;
|
|
|
|
resolveEnsName: typeof resolveEnsName;
|
|
|
|
}
|
|
|
|
export class AddressField extends React.Component<Props> {
|
|
|
|
public render() {
|
2017-07-02 05:49:06 +00:00
|
|
|
const { placeholder, value, ensAddress } = this.props;
|
|
|
|
const isReadonly = !this.props.onChange;
|
|
|
|
return (
|
|
|
|
<div className="row form-group">
|
|
|
|
<div className="col-xs-11">
|
2017-08-31 04:00:31 +00:00
|
|
|
<label>
|
|
|
|
{translate('SEND_addr')}:
|
|
|
|
</label>
|
2017-07-02 05:49:06 +00:00
|
|
|
<input
|
|
|
|
className={`form-control ${isValidENSorEtherAddress(value)
|
|
|
|
? 'is-valid'
|
|
|
|
: 'is-invalid'}`}
|
|
|
|
type="text"
|
2017-08-31 04:00:31 +00:00
|
|
|
value={value}
|
2017-07-02 05:49:06 +00:00
|
|
|
placeholder={placeholder}
|
|
|
|
onChange={this.onChange}
|
|
|
|
disabled={isReadonly}
|
|
|
|
/>
|
|
|
|
{!!ensAddress &&
|
|
|
|
<p className="ens-response">
|
|
|
|
↳
|
2017-08-31 04:00:31 +00:00
|
|
|
<span className="mono">{ensAddress}</span>
|
2017-07-02 05:49:06 +00:00
|
|
|
</p>}
|
|
|
|
</div>
|
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="col-xs-1" style={{ padding: 0 }}>
|
2017-07-02 05:49:06 +00:00
|
|
|
<Identicon address={ensAddress || value} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-06-26 22:27:55 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
public onChange = (e: React.SyntheticEvent<HTMLInputElement>) => {
|
|
|
|
const newValue = (e.target as HTMLInputElement).value;
|
2017-07-02 05:49:06 +00:00
|
|
|
const { onChange } = this.props;
|
|
|
|
if (!onChange) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// FIXME debounce?
|
|
|
|
if (isValidENSAddress(newValue)) {
|
|
|
|
this.props.resolveEnsName(newValue);
|
|
|
|
}
|
|
|
|
onChange(newValue);
|
|
|
|
};
|
2017-06-26 22:27:55 +00:00
|
|
|
}
|
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
function mapStateToProps(state: AppState, props: PublicProps) {
|
2017-07-02 05:49:06 +00:00
|
|
|
return {
|
|
|
|
ensAddress: getEnsAddress(state, props.value)
|
|
|
|
};
|
2017-06-26 22:27:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, { resolveEnsName })(AddressField);
|