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
- ; + +function PasswordInput(props: PasswordInputProps, ref): React.Node { + const [htmlInputType, setHtmlInputType] = React.useState('password'); + + const onToggleShowPassword = React.useCallback(() => { + setHtmlInputType(oldType => (oldType === 'password' ? 'text' : 'password')); + }, [setHtmlInputType]); + + const icon: Icon = React.useMemo( + () => (htmlInputType === 'password' ? 'eye-open' : 'eye-closed'), + [htmlInputType], + ); + + return ( +
+ +
+ +
+
+ ); +} + +const ForwardedPasswordInput: React.AbstractComponent< + PasswordInputProps, + HTMLInputElement, +> = React.forwardRef(PasswordInput); + +export default ForwardedPasswordInput; diff --git a/web/modals/input.css b/web/modals/input.css --- a/web/modals/input.css +++ b/web/modals/input.css @@ -20,4 +20,5 @@ line-height: var(--line-height-text); color: var(--fg); border-radius: 4px; + padding-right: 50px; } 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 @@ -4,7 +4,7 @@ import css from './input.css'; -type Props = { +export type InputProps = { +type: string, +placeholder: string, +value: string, @@ -15,7 +15,7 @@ +id?: string, }; -function Input(props: Props, ref): React.Node { +function Input(props: InputProps, ref): React.Node { const { label: labelProp, disabled = false, id, ...rest } = props; let label; @@ -42,8 +42,8 @@ } const ForwardedInput: React.AbstractComponent< - Props, + InputProps, HTMLInputElement, -> = 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); }