feat(auth): unify and polish login, register and homepage auth UI
Login and register each carried their own copy of the promo panel and the error banner, so the two pages drifted apart and every caller had to wire role="alert" by hand. Extract a shared AuthPromoCard and AuthAlert, use them in both forms and for the login notices, and link errors to their fields via aria-invalid / aria-describedby. Focus now lands on the 2FA code field the moment it appears, the credential fields lock while a request is in flight, and invalid inputs get a danger tint. The homepage top bar was a byte-for-byte duplicate of AuthTopBar; it now renders the shared component, and the compact homepage login uses the tighter spacing its comment already promised.
This commit is contained in:
1 parent
2249303dbd
commit
c6e5e0b1a9
8 files changed
+215
-296
No files matched your search
@@ -0,0 +1,38 @@
|
||||
"use client";
|
||||
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
interface AuthAlertProps {
|
||||
children: ReactNode;
|
||||
/** Tint of the box: red for errors, green for confirmations. */
|
||||
variant?: "error" | "success";
|
||||
/** Extra classes, e.g. spacing (`mb-4`) or entrance animation. */
|
||||
className?: string;
|
||||
/** Optional id so inputs can point at the message via `aria-describedby`. */
|
||||
id?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The single status/error banner for the auth forms. Uses `role="alert"` for
|
||||
* failures (screen readers announce them immediately) and `role="status"` for
|
||||
* confirmations, so the two are wired correctly instead of every caller
|
||||
* repeating the markup and risking an unannounced message.
|
||||
*/
|
||||
export function AuthAlert({
|
||||
children,
|
||||
variant = "error",
|
||||
className = "",
|
||||
id,
|
||||
}: AuthAlertProps) {
|
||||
return (
|
||||
<p
|
||||
id={id}
|
||||
role={variant === "error" ? "alert" : "status"}
|
||||
className={`auth-alert animate-fade-in-up m-0 ${
|
||||
variant === "success" ? "auth-alert--success" : ""
|
||||
} ${className}`}
|
||||
>
|
||||
{children}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -18,6 +18,7 @@ import {
|
||||
type RegisterState,
|
||||
register,
|
||||
} from "@/actions/register";
|
||||
import { AuthAlert } from "@/components/auth/auth-alert";
|
||||
import { PasswordToggle } from "@/components/auth/password-toggle";
|
||||
import Link from "@/components/link";
|
||||
import { signInWithTransientRetry } from "@/lib/auth/sign-in-retry";
|
||||
@@ -183,15 +184,7 @@ export function RegisterForm({
|
||||
}}
|
||||
className="flex flex-col gap-6"
|
||||
>
|
||||
{errorMessage && (
|
||||
<p
|
||||
role="alert"
|
||||
aria-live="polite"
|
||||
className="auth-alert animate-fade-in-up m-0"
|
||||
>
|
||||
{errorMessage}
|
||||
</p>
|
||||
)}
|
||||
{errorMessage && <AuthAlert>{errorMessage}</AuthAlert>}
|
||||
|
||||
{referralCode && (
|
||||
<div
|
||||
|
||||
Reference in new issue
Block a user