diff --git a/src/components/Icon.tsx b/src/components/Icon.tsx index 6f5c676e..90e43d70 100644 --- a/src/components/Icon.tsx +++ b/src/components/Icon.tsx @@ -5,6 +5,7 @@ export enum Icons { BOOKMARK = "bookmark", BOOKMARK_OUTLINE = "bookmark_outline", CLOCK = "clock", + EYE = "eye", EYE_SLASH = "eyeSlash", ARROW_LEFT = "arrowLeft", ARROW_RIGHT = "arrowRight", @@ -73,6 +74,7 @@ const iconList: Record = { search: ``, bookmark: ``, clock: ``, + eye: ``, eyeSlash: ``, arrowLeft: ``, chevronDown: ``, diff --git a/src/components/text-inputs/AuthInputBox.tsx b/src/components/text-inputs/AuthInputBox.tsx index 8ff9553e..c79c079d 100644 --- a/src/components/text-inputs/AuthInputBox.tsx +++ b/src/components/text-inputs/AuthInputBox.tsx @@ -7,6 +7,7 @@ export function AuthInputBox(props: { autoComplete?: string; placeholder?: string; onChange?: (data: string) => void; + passwordToggleable?: boolean; }) { return (
@@ -19,6 +20,7 @@ export function AuthInputBox(props: { autoComplete={props.autoComplete} onChange={props.onChange} placeholder={props.placeholder} + passwordToggleable={props.passwordToggleable} className="w-full flex-1 bg-authentication-inputBg px-4 py-3 text-search-text focus:outline-none rounded-lg placeholder:text-gray-700" />
diff --git a/src/components/text-inputs/TextInputControl.tsx b/src/components/text-inputs/TextInputControl.tsx index b555c4f8..91d20c3a 100644 --- a/src/components/text-inputs/TextInputControl.tsx +++ b/src/components/text-inputs/TextInputControl.tsx @@ -1,4 +1,7 @@ -import { forwardRef } from "react"; +import classNames from "classnames"; +import { forwardRef, useState } from "react"; + +import { Icon, Icons } from "../Icon"; export interface TextInputControlPropsNoLabel { onChange?: (data: string) => void; @@ -9,6 +12,7 @@ export interface TextInputControlPropsNoLabel { autoComplete?: string; placeholder?: string; className?: string; + passwordToggleable?: boolean; } export interface TextInputControlProps extends TextInputControlPropsNoLabel { @@ -30,25 +34,41 @@ export const TextInputControl = forwardRef< className, placeholder, onFocus, + passwordToggleable, }, ref ) => { + let inputType = "text"; + const [showPassword, setShowPassword] = useState(true); + if (passwordToggleable) inputType = showPassword ? "password" : "text"; + const input = ( - onChange && onChange(e.target.value)} - value={value} - name={name} - autoComplete={autoComplete} - onBlur={() => onUnFocus && onUnFocus()} - onFocus={() => onFocus?.()} - onKeyDown={(e) => - e.key === "Enter" ? (e.target as HTMLInputElement).blur() : null - } - /> +
+ onChange && onChange(e.target.value)} + value={value} + name={name} + autoComplete={autoComplete} + onBlur={() => onUnFocus && onUnFocus()} + onFocus={() => onFocus?.()} + onKeyDown={(e) => + e.key === "Enter" ? (e.target as HTMLInputElement).blur() : null + } + /> + {passwordToggleable ? ( + + ) : null} +
); if (label) { diff --git a/src/pages/parts/auth/LoginFormPart.tsx b/src/pages/parts/auth/LoginFormPart.tsx index 1ff43422..39b81b96 100644 --- a/src/pages/parts/auth/LoginFormPart.tsx +++ b/src/pages/parts/auth/LoginFormPart.tsx @@ -74,6 +74,7 @@ export function LoginFormPart(props: LoginFormPartProps) { name="username" onChange={setMnemonic} placeholder={t("auth.login.passphrasePlaceholder") ?? undefined} + passwordToggleable /> {result.error ? (