Add show/hide password toggle to login page
The login page's password field had no reveal toggle at all — it was always plain type="password" with no button, unlike the register page which already had one. Added the same eye-icon toggle used on register, verified in a real browser with Playwright: click toggles password<->text and back, value is preserved throughout.
This commit is contained in:
parent
4e9d9e6048
commit
96f5e7e3b0
@ -34,6 +34,7 @@ function LoginForm() {
|
||||
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
const [staySignedIn, setStaySignedIn] = useState(true);
|
||||
const [totpToken, setTotpToken] = useState("");
|
||||
const [requiresTwoFactor, setRequiresTwoFactor] = useState(false);
|
||||
@ -155,12 +156,29 @@ function LoginForm() {
|
||||
<label htmlFor="password" className="block text-sm font-medium text-foreground">
|
||||
Password
|
||||
</label>
|
||||
<div className="mt-1">
|
||||
<div className="relative mt-1">
|
||||
<input
|
||||
id="password" name="password" type="password" autoComplete="current-password" required
|
||||
id="password" name="password" type={showPassword ? "text" : "password"} autoComplete="current-password" required
|
||||
value={password} onChange={(e) => setPassword(e.target.value)}
|
||||
className="block w-full appearance-none rounded-lg border border-border bg-background/50 px-3 py-2 text-foreground placeholder-muted-foreground shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20 sm:text-sm transition-all"
|
||||
className="block w-full appearance-none rounded-lg border border-border bg-background/50 px-3 py-2 pr-11 text-foreground placeholder-muted-foreground shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20 sm:text-sm transition-all"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowPassword(!showPassword)}
|
||||
className="absolute right-3 top-1/2 -translate-y-1/2 p-1.5 text-muted-foreground hover:text-foreground rounded-lg hover:bg-secondary/50 transition-colors"
|
||||
aria-label={showPassword ? "Hide password" : "Show password"}
|
||||
>
|
||||
{showPassword ? (
|
||||
<svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878a4.5 4.5 0 106.262 6.262M4 4l16 16" />
|
||||
</svg>
|
||||
) : (
|
||||
<svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
|
||||
</svg>
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user