Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Make secondPassphraseInput type='password' - Closes #695 #696

Merged
merged 2 commits into from
Sep 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/components/secondPassphraseInput/secondPassphraseInput.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.wrapper {
position: relative;
}

.checkbox {
visibility: hidden;
position: hidden;
}

.label {
position: absolute;
right: 0;
bottom: 50%;
transform: translateY(50%);
line-height: 24px;
height: 24px;
cursor: pointer;
}
34 changes: 29 additions & 5 deletions src/components/secondPassphraseInput/secondPassphraseInput.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import React from 'react';
import FontIcon from 'react-toolbox/lib/font_icon';
import Input from 'react-toolbox/lib/input';
import { isValidPassphrase } from '../../utils/passphrase';
import styles from './secondPassphraseInput.css';

class SecondPassphraseInput extends React.Component {
constructor() {
super();
this.state = { inputType: 'password' };
}

componentDidMount() {
if (this.props.hasSecondPassphrase) {
this.props.onChange('');
Expand All @@ -19,13 +26,30 @@ class SecondPassphraseInput extends React.Component {
this.props.onChange(value, error);
}

setInputType(event) {
this.setState({ inputType: event.target.checked ? 'text' : 'password' });
}

render() {
return (this.props.hasSecondPassphrase ?
<Input label='Second Passphrase' required={true}
className='second-passphrase'
error={this.props.error}
value={this.props.value}
onChange={this.handleValueChange.bind(this)} /> :
<div className={styles.wrapper}>
<Input
label='Second Passphrase'
required={true}
type={this.state.inputType}
className='second-passphrase'
error={this.props.error}
value={this.props.value}
onChange={this.handleValueChange.bind(this)} />
<label htmlFor='input-type' className={styles.label}>
<FontIcon value='remove_red_eye' />
<input
id='input-type'
className={styles.checkbox}
type={'checkbox'}
onChange={this.setInputType.bind(this)} />
</label>
</div> :
null);
}
}
Expand Down