index.js 1 KB
Newer Older
zhanghaozhe committed
1 2
import React, { Component } from 'react';
import './password-input.scss'
3
import classnames from 'classnames'
zhanghaozhe committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

import Input from '../Input'

class PasswordInput extends Component {
    constructor(props) {
        super(props);
        this.state = {
            showPassword: false
        }
    }

    togglePasswordVisibility = () => {
        this.setState({showPassword: !this.state.showPassword})
    }

    render() {
        let {placeholder, onChange} = this.props
        return (
            <Input
                type={this.state.showPassword ? 'text' : 'password'}
                wrapperClass={'password-input'}
                placeholder={placeholder}
                onChange={onChange}
            >
28 29 30 31
                <i className={classnames('iconfont', {
                    'iconpwd-hidden': this.state.showPassword,
                    'iconyanjing': !this.state.showPassword
                })} onClick={this.togglePasswordVisibility}/>
zhanghaozhe committed
32 33 34 35 36 37
            </Input>
        );
    }
}

export default PasswordInput;