Skip to content

Commit 4255ff1

Browse files
feat: add password visibility toggle to login and signup page
1 parent aa6e2d4 commit 4255ff1

3 files changed

Lines changed: 55 additions & 15 deletions

File tree

app/docs/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ export default function DocsPage() {
313313
</div>
314314
<div className="flex flex-wrap gap-3">
315315
<Link
316-
href="https://github.com/aboderinsamuel/closedNote"
316+
href="https://github.com/aboderinsamuel/closedNote_v0.01"
317317
className="inline-flex items-center gap-2 px-4 py-2 rounded-full border border-neutral-200 dark:border-neutral-700 text-sm text-neutral-700 dark:text-neutral-300 hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors"
318318
>
319319
<svg className="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M12 0C5.374 0 0 5.373 0 12c0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23A11.509 11.509 0 0112 5.803c1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576C20.566 21.797 24 17.3 24 12c0-6.627-5.373-12-12-12z"/></svg>

app/login/page.tsx

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default function LoginPage() {
1616
const [password, setPassword] = useState("");
1717
const [error, setError] = useState<string | null>(null);
1818
const [loading, setLoading] = useState(false);
19+
const [showPassword, setShowPassword] = useState(false);
1920

2021
const handleSubmit = async (e: React.FormEvent) => {
2122
e.preventDefault();
@@ -57,13 +58,32 @@ export default function LoginPage() {
5758
</div>
5859
<div>
5960
<label className="block text-sm mb-1">Password</label>
60-
<input
61-
className="w-full px-3 py-2 rounded-md border border-neutral-300 dark:border-neutral-700 bg-white dark:bg-neutral-900"
62-
type="password"
63-
value={password}
64-
onChange={(e) => setPassword(e.target.value)}
65-
required
66-
/>
61+
<div className="relative">
62+
<input
63+
className="w-full px-3 py-2 pr-10 rounded-md border border-neutral-300 dark:border-neutral-700 bg-white dark:bg-neutral-900"
64+
type={showPassword ? "text" : "password"}
65+
value={password}
66+
onChange={(e) => setPassword(e.target.value)}
67+
required
68+
/>
69+
<button
70+
type="button"
71+
onClick={() => setShowPassword((v) => !v)}
72+
className="absolute right-3 top-1/2 -translate-y-1/2 text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-200 transition-colors"
73+
aria-label={showPassword ? "Hide password" : "Show password"}
74+
>
75+
{showPassword ? (
76+
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
77+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} 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.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21" />
78+
</svg>
79+
) : (
80+
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
81+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
82+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} 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" />
83+
</svg>
84+
)}
85+
</button>
86+
</div>
6787
</div>
6888
<button
6989
type="submit"

app/signup/page.tsx

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default function SignupPage() {
1818
const [error, setError] = useState<string | null>(null);
1919
const [loading, setLoading] = useState(false);
2020
const [showEmailConfirmation, setShowEmailConfirmation] = useState(false);
21+
const [showPassword, setShowPassword] = useState(false);
2122

2223
const handleSubmit = async (e: React.FormEvent) => {
2324
e.preventDefault();
@@ -137,13 +138,32 @@ export default function SignupPage() {
137138
</div>
138139
<div>
139140
<label className="block text-sm mb-1">Password</label>
140-
<input
141-
className="w-full px-3 py-2 rounded-md border border-neutral-300 dark:border-neutral-700 bg-white dark:bg-neutral-900"
142-
type="password"
143-
value={password}
144-
onChange={(e) => setPassword(e.target.value)}
145-
required
146-
/>
141+
<div className="relative">
142+
<input
143+
className="w-full px-3 py-2 pr-10 rounded-md border border-neutral-300 dark:border-neutral-700 bg-white dark:bg-neutral-900"
144+
type={showPassword ? "text" : "password"}
145+
value={password}
146+
onChange={(e) => setPassword(e.target.value)}
147+
required
148+
/>
149+
<button
150+
type="button"
151+
onClick={() => setShowPassword((v) => !v)}
152+
className="absolute right-2 top-1/2 -translate-y-1/2 text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-200"
153+
tabIndex={-1}
154+
>
155+
{showPassword ? (
156+
<svg xmlns="http://www.w3.org/2000/svg" className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
157+
<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.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21" />
158+
</svg>
159+
) : (
160+
<svg xmlns="http://www.w3.org/2000/svg" className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
161+
<path strokeLinecap="round" strokeLinejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
162+
<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" />
163+
</svg>
164+
)}
165+
</button>
166+
</div>
147167
</div>
148168
<button
149169
type="submit"

0 commit comments

Comments
 (0)