diff --git a/web/account/log-in-form.react.js b/web/account/log-in-form.react.js --- a/web/account/log-in-form.react.js +++ b/web/account/log-in-form.react.js @@ -26,6 +26,7 @@ import { useSelector } from '../redux/redux-utils'; import { webLogInExtraInfoSelector } from '../selectors/account-selectors'; import css from './log-in-form.css'; +import PasswordInput from './password-input.react'; const loadingStatusSelector = createLoadingStatusSelector(logInActionTypes); function LoginForm(): React.Node { @@ -139,9 +140,7 @@
Password
- ( + 'password', + ); + + const onToggleShowPassword = React.useCallback(() => { + setHtmlInputType(oldType => (oldType === 'password' ? 'text' : 'password')); + }, []); + + const icon: Icon = htmlInputType === 'password' ? 'eye-open' : 'eye-closed'; + + return ( +
+ + +
+ ); +} + +const ForwardedPasswordInput: React.AbstractComponent< + PasswordInputProps, + HTMLInputElement, +> = React.forwardRef(PasswordInput); + +export default ForwardedPasswordInput; diff --git a/web/modals/input.react.js b/web/modals/input.react.js --- a/web/modals/input.react.js +++ b/web/modals/input.react.js @@ -1,22 +1,34 @@ // @flow +import classNames from 'classnames'; import * as React from 'react'; import css from './input.css'; -type Props = { - +type: string, - +placeholder: string, +export type BaseInputProps = { +value: string, +onChange: (value: SyntheticEvent) => mixed, +onBlur?: (value: SyntheticEvent) => mixed, +disabled?: boolean, +label?: string, +id?: string, + +className?: string, }; -function Input(props: Props, ref): React.Node { - const { label: labelProp, disabled = false, id, ...rest } = props; +export type InputProps = { + ...BaseInputProps, + +type: string, + +placeholder: string, +}; + +function Input(props: InputProps, ref): React.Node { + const { + label: labelProp, + disabled = false, + className = '', + id, + ...rest + } = props; let label; if (labelProp) { @@ -27,11 +39,13 @@ ); } + const inputClassName = classNames(css.input, className); + return ( <> {label} = React.forwardRef(Input); +> = React.forwardRef(Input); export default ForwardedInput; diff --git a/web/theme.css b/web/theme.css --- a/web/theme.css +++ b/web/theme.css @@ -180,4 +180,5 @@ --compose-subchannel-label-color: var(--shades-black-60); --compose-subchannel-mark-color: var(--violet-light-100); --enum-option-icon-color: var(--violet-dark-100); + --show-password-bg-hover: var(--shades-black-70); }