Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions frontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,47 @@
.rule--pass .rule-icon { color: var(--green); }
.rule--fail .rule-icon { color: #d1d5db; }

/* ─── Password Toggle Button ────────────────────────────── */
.password-input-wrapper {
position: relative;
width: 100%;
}

.password-input-wrapper .field-input {
padding-right: 42px; /* Ensure input text doesn't overlap the eye button */
}

.password-toggle-btn {
position: absolute;
right: 12px;
top: 50%;
transform: translateY(-50%);
background: none;
border: none;
padding: 4px;
cursor: pointer;
color: var(--text-muted);
display: flex;
align-items: center;
justify-content: center;
transition: color 0.15s, opacity 0.15s;
border-radius: 4px;
}

.password-toggle-btn:hover:not(:disabled) {
color: var(--text);
}

.password-toggle-btn:focus-visible {
outline: 2px solid var(--green);
outline-offset: -2px;
}

.password-toggle-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 600px) {
.header { padding: 20px 16px; }
Expand Down
44 changes: 34 additions & 10 deletions frontend/src/pages/LoginPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const isValidEmail = (v) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v.trim());
export default function LoginPage() {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [showPassword, setShowPassword] = useState(false);
const [errors, setErrors] = useState({});
const [apiError, setApiError] = useState('');
const [loading, setLoading] = useState(false);
Expand Down Expand Up @@ -82,16 +83,39 @@ export default function LoginPage() {

<div className="field-group">
<label className="field-label" htmlFor="login-password">Password</label>
<input
id="login-password"
type="password"
className={`field-input ${errors.password ? 'field-input--err' : ''}`}
placeholder="Minimum 8 characters"
value={password}
onChange={(e) => { setPassword(e.target.value); clear('password'); }}
disabled={loading}
autoComplete="current-password"
/>
<div className="password-input-wrapper">
<input
id="login-password"
type={showPassword ? 'text' : 'password'}
className={`field-input ${errors.password ? 'field-input--err' : ''}`}
placeholder="Minimum 8 characters"
value={password}
onChange={(e) => { setPassword(e.target.value); clear('password'); }}
disabled={loading}
autoComplete="current-password"
/>
<button
type="button"
className="password-toggle-btn"
onClick={() => setShowPassword(!showPassword)}
disabled={loading}
aria-label={showPassword ? 'Hide password' : 'Show password'}
>
{showPassword ? (
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/>
<path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/>
<path d="M6.61 6.61A13.52 13.52 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/>
<line x1="2" y1="2" x2="22" y2="22"/>
</svg>
) : (
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0z"/>
<circle cx="12" cy="12" r="3"/>
</svg>
)}
</button>
</div>
{errors.password && <p className="field-error">✗ {errors.password}</p>}
</div>

Expand Down
96 changes: 72 additions & 24 deletions frontend/src/pages/RegisterPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default function RegisterPage() {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [confirm, setConfirm] = useState('');
const [showPassword, setShowPassword] = useState(false);
const [showConfirm, setShowConfirm] = useState(false);
const [errors, setErrors] = useState({});
const [apiError, setApiError] = useState('');
const [loading, setLoading] = useState(false);
Expand Down Expand Up @@ -129,20 +131,43 @@ export default function RegisterPage() {
{/* Password */}
<div className="field-group">
<label className="field-label" htmlFor="reg-password">Password</label>
<input
id="reg-password"
type="password"
className={`field-input ${errors.password ? 'field-input--err' : ''}`}
placeholder="Create a strong password"
value={password}
onChange={(e) => {
setPassword(e.target.value);
setTouched(p => ({ ...p, password: true }));
clear('password');
}}
disabled={loading}
autoComplete="new-password"
/>
<div className="password-input-wrapper">
<input
id="reg-password"
type={showPassword ? 'text' : 'password'}
className={`field-input ${errors.password ? 'field-input--err' : ''}`}
placeholder="Create a strong password"
value={password}
onChange={(e) => {
setPassword(e.target.value);
setTouched(p => ({ ...p, password: true }));
clear('password');
}}
disabled={loading}
autoComplete="new-password"
/>
<button
type="button"
className="password-toggle-btn"
onClick={() => setShowPassword(!showPassword)}
disabled={loading}
aria-label={showPassword ? 'Hide password' : 'Show password'}
>
{showPassword ? (
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/>
<path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/>
<path d="M6.61 6.61A13.52 13.52 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/>
<line x1="2" y1="2" x2="22" y2="22"/>
</svg>
) : (
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0z"/>
<circle cx="12" cy="12" r="3"/>
</svg>
)}
</button>
</div>
{errors.password && <p className="field-error">✗ {errors.password}</p>}

{/* Strength bar — shown as soon as user starts typing */}
Expand Down Expand Up @@ -179,16 +204,39 @@ export default function RegisterPage() {
{/* Confirm password */}
<div className="field-group">
<label className="field-label" htmlFor="reg-confirm">Confirm password</label>
<input
id="reg-confirm"
type="password"
className={`field-input ${errors.confirm ? 'field-input--err' : ''}`}
placeholder="Re-enter your password"
value={confirm}
onChange={(e) => { setConfirm(e.target.value); clear('confirm'); }}
disabled={loading}
autoComplete="new-password"
/>
<div className="password-input-wrapper">
<input
id="reg-confirm"
type={showConfirm ? 'text' : 'password'}
className={`field-input ${errors.confirm ? 'field-input--err' : ''}`}
placeholder="Re-enter your password"
value={confirm}
onChange={(e) => { setConfirm(e.target.value); clear('confirm'); }}
disabled={loading}
autoComplete="new-password"
/>
<button
type="button"
className="password-toggle-btn"
onClick={() => setShowConfirm(!showConfirm)}
disabled={loading}
aria-label={showConfirm ? 'Hide password' : 'Show password'}
>
{showConfirm ? (
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/>
<path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/>
<path d="M6.61 6.61A13.52 13.52 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/>
<line x1="2" y1="2" x2="22" y2="22"/>
</svg>
) : (
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0z"/>
<circle cx="12" cy="12" r="3"/>
</svg>
)}
</button>
</div>
{errors.confirm && <p className="field-error">✗ {errors.confirm}</p>}
</div>

Expand Down
41 changes: 41 additions & 0 deletions todo-frontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,47 @@
.rule--pass .rule-icon { color: var(--green); }
.rule--fail .rule-icon { color: #d1d5db; }

/* ─── Password Toggle Button ────────────────────────────── */
.password-input-wrapper {
position: relative;
width: 100%;
}

.password-input-wrapper .field-input {
padding-right: 42px; /* Ensure input text doesn't overlap the eye button */
}

.password-toggle-btn {
position: absolute;
right: 12px;
top: 50%;
transform: translateY(-50%);
background: none;
border: none;
padding: 4px;
cursor: pointer;
color: var(--text-muted);
display: flex;
align-items: center;
justify-content: center;
transition: color 0.15s, opacity 0.15s;
border-radius: 4px;
}

.password-toggle-btn:hover:not(:disabled) {
color: var(--text);
}

.password-toggle-btn:focus-visible {
outline: 2px solid var(--green);
outline-offset: -2px;
}

.password-toggle-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 600px) {
.header { padding: 20px 16px; }
Expand Down
44 changes: 34 additions & 10 deletions todo-frontend/src/pages/LoginPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const isValidEmail = (v) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v.trim());
export default function LoginPage() {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [showPassword, setShowPassword] = useState(false);
const [errors, setErrors] = useState({});
const [apiError, setApiError] = useState('');
const [loading, setLoading] = useState(false);
Expand Down Expand Up @@ -82,16 +83,39 @@ export default function LoginPage() {

<div className="field-group">
<label className="field-label" htmlFor="login-password">Password</label>
<input
id="login-password"
type="password"
className={`field-input ${errors.password ? 'field-input--err' : ''}`}
placeholder="Minimum 8 characters"
value={password}
onChange={(e) => { setPassword(e.target.value); clear('password'); }}
disabled={loading}
autoComplete="current-password"
/>
<div className="password-input-wrapper">
<input
id="login-password"
type={showPassword ? 'text' : 'password'}
className={`field-input ${errors.password ? 'field-input--err' : ''}`}
placeholder="Minimum 8 characters"
value={password}
onChange={(e) => { setPassword(e.target.value); clear('password'); }}
disabled={loading}
autoComplete="current-password"
/>
<button
type="button"
className="password-toggle-btn"
onClick={() => setShowPassword(!showPassword)}
disabled={loading}
aria-label={showPassword ? 'Hide password' : 'Show password'}
>
{showPassword ? (
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/>
<path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/>
<path d="M6.61 6.61A13.52 13.52 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/>
<line x1="2" y1="2" x2="22" y2="22"/>
</svg>
) : (
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0z"/>
<circle cx="12" cy="12" r="3"/>
</svg>
)}
</button>
</div>
{errors.password && <p className="field-error">✗ {errors.password}</p>}
</div>

Expand Down
Loading