2017-12-28 19:54:07 +00:00
|
|
|
import React from 'react';
|
|
|
|
import classnames from 'classnames';
|
|
|
|
import { translateRaw } from 'translations';
|
|
|
|
import './Word.scss';
|
2018-03-01 17:53:29 +00:00
|
|
|
import { Input } from 'components/ui';
|
2017-12-28 19:54:07 +00:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
index: number;
|
|
|
|
word: string;
|
|
|
|
value: string;
|
|
|
|
isReadOnly: boolean;
|
|
|
|
onChange(index: number, value: string): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface State {
|
|
|
|
isShowingWord: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default class MnemonicWord extends React.Component<Props, State> {
|
|
|
|
public state = {
|
|
|
|
isShowingWord: false
|
|
|
|
};
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
const { index, word, value, isReadOnly } = this.props;
|
|
|
|
const { isShowingWord } = this.state;
|
|
|
|
const readOnly = isReadOnly || isShowingWord;
|
|
|
|
|
|
|
|
return (
|
2018-03-01 17:53:29 +00:00
|
|
|
<div className="input-group-wrapper MnemonicWord">
|
2018-03-08 19:28:43 +00:00
|
|
|
<label className="input-group input-group-inline ENSInput-name">
|
2018-03-01 17:53:29 +00:00
|
|
|
<span className="input-group-addon input-group-addon--transparent">{index + 1}.</span>
|
|
|
|
<Input
|
2018-03-08 19:28:43 +00:00
|
|
|
className={`MnemonicWord-word-input ${!isReadOnly && 'border-rad-right-0'}`}
|
2017-12-28 19:54:07 +00:00
|
|
|
value={readOnly ? word : value}
|
|
|
|
onChange={this.handleChange}
|
|
|
|
readOnly={readOnly}
|
|
|
|
/>
|
|
|
|
{!isReadOnly && (
|
|
|
|
<span
|
|
|
|
onClick={this.toggleShow}
|
2018-03-22 03:50:25 +00:00
|
|
|
aria-label={translateRaw('GEN_ARIA_2')}
|
2017-12-28 19:54:07 +00:00
|
|
|
role="button"
|
|
|
|
className="MnemonicWord-word-toggle input-group-addon"
|
|
|
|
>
|
|
|
|
<i
|
|
|
|
className={classnames(
|
|
|
|
'fa',
|
|
|
|
isShowingWord && 'fa-eye-slash',
|
|
|
|
!isShowingWord && 'fa-eye'
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
)}
|
2018-03-01 17:53:29 +00:00
|
|
|
</label>
|
2017-12-28 19:54:07 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private handleChange = (ev: React.FormEvent<HTMLInputElement>) => {
|
|
|
|
this.props.onChange(this.props.index, ev.currentTarget.value);
|
|
|
|
};
|
|
|
|
|
|
|
|
private toggleShow = () => {
|
|
|
|
this.setState({ isShowingWord: !this.state.isShowingWord });
|
|
|
|
};
|
|
|
|
}
|