Author SHA1 Message Date
ahp ea821ff70b feat(web): show/hide toggle on the login password field
- an eye button inside the password field switches it between hidden
  and plain text; it is labelled for screen readers, exposes its state
  with aria-pressed and resets when the sign-in mode changes
- the field stays LTR, so the button sits at its right edge in both
  languages
2026-11-26 17:58:21 +03:30
4 changed files with 41 additions and 15 deletions

No files matched your search

+1
View File
@@ -51,6 +51,7 @@ The format follows [Keep a Changelog](https://keepachangelog.com/) and the proje
worker with timestamp-midpoint trimming, enabling the progress stream
and duration caps: 30 min on WebGPU, 10 min on WASM, 60 MB per file —
no input can wedge the demo at an eternal "processing" state anymore.
- A show/hide toggle (eye icon) on the login page's password field.
### Changed
+2
View File
@@ -53,6 +53,8 @@
"emailPlaceholder": "you@example.com",
"passwordLabel": "Password",
"passwordPlaceholder": "••••••••",
"showPassword": "Show password",
"hidePassword": "Hide password",
"codeLabel": "Connect code",
"codePlaceholder": "Enter your connect code",
"codeHint": "Have a connect code? No email or password needed.",
+2
View File
@@ -53,6 +53,8 @@
"emailPlaceholder": "you@example.com",
"passwordLabel": "رمز عبور",
"passwordPlaceholder": "••••••••",
"showPassword": "نمایش رمز عبور",
"hidePassword": "پنهان کردن رمز عبور",
"codeLabel": "کد اتصال",
"codePlaceholder": "کد اتصال را وارد کن",
"codeHint": "اگر کد اتصال داری، لازم نیست ایمیل و رمز عبور وارد کنی.",
+36 -15
View File
@@ -2,6 +2,7 @@
import { useState, type FormEvent } from "react";
import { useTranslations } from "next-intl";
import { Eye, EyeOff } from "lucide-react";
import { useRouter } from "@/i18n/navigation";
import { ApiError, login, register, setToken, tokenLogin } from "@/lib/api";
@@ -17,6 +18,7 @@ export default function LoginPage() {
const [mode, setMode] = useState<Mode>("login");
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [showPassword, setShowPassword] = useState(false);
const [code, setCode] = useState("");
const [emailError, setEmailError] = useState<string | null>(null);
const [passwordError, setPasswordError] = useState<string | null>(null);
@@ -27,6 +29,7 @@ export default function LoginPage() {
function switchMode(next: Mode) {
if (next === mode) return;
setMode(next);
setShowPassword(false);
setEmailError(null);
setPasswordError(null);
setCodeError(null);
@@ -176,21 +179,39 @@ export default function LoginPage() {
>
{t("passwordLabel")}
</label>
<input
id="login-password"
name="password"
type="password"
dir="ltr"
autoComplete={mode === "register" ? "new-password" : "current-password"}
value={password}
onChange={(event) => {
setPassword(event.target.value);
if (passwordError) setPasswordError(null);
}}
placeholder={t("passwordPlaceholder")}
aria-invalid={passwordError ? true : undefined}
className={inputClasses}
/>
{/* The field is always LTR, so the toggle sits at its physical right. */}
<div className="relative" dir="ltr">
<input
id="login-password"
name="password"
type={showPassword ? "text" : "password"}
dir="ltr"
autoComplete={mode === "register" ? "new-password" : "current-password"}
value={password}
onChange={(event) => {
setPassword(event.target.value);
if (passwordError) setPasswordError(null);
}}
placeholder={t("passwordPlaceholder")}
aria-invalid={passwordError ? true : undefined}
className={`${inputClasses} pr-11`}
/>
<button
type="button"
onClick={() => setShowPassword((shown) => !shown)}
aria-label={showPassword ? t("hidePassword") : t("showPassword")}
aria-pressed={showPassword}
aria-controls="login-password"
title={showPassword ? t("hidePassword") : t("showPassword")}
className="absolute inset-y-0 right-0 flex w-11 items-center justify-center rounded-e-lg text-stone-500 transition-colors hover:text-stone-800 focus-visible:ring-2 focus-visible:ring-teal-700"
>
{showPassword ? (
<EyeOff className="h-5 w-5" aria-hidden="true" />
) : (
<Eye className="h-5 w-5" aria-hidden="true" />
)}
</button>
</div>
{passwordError ? (
<p className="mt-1.5 text-sm text-red-700">{passwordError}</p>
) : mode === "register" ? (