Accounts 1.0.0 frontend and @crosscode/ui

Sign-in steps (password, sign-up, email code, two-step sign-in and its
setup with recovery codes, privacy notice, news question), forgot and
reset password, the account page, admin (people, deletions, church
profile, linked products, settings, notice, licence, audit) and setup.
Strict CSP with a nonce per page; church colours from the profile.
@crosscode/ui gets its first components (shell, card, fields, buttons).
Plan: roles stay in each product (asked 2026-11-18).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 13:42:45 +02:00
co-authored by Claude Opus 5.5
parent a888260f01
commit f202a5a88e
36 changed files with 1521 additions and 5 deletions
+91
View File
@@ -0,0 +1,91 @@
/**
* @crosscode/ui — the branded shell, cards, buttons, fields and notices shared by Accounts, the
* Church Website and the Church App. Colours come from `--brand` (see README).
*/
import React from "react";
const cx = (...c: (string | false | null | undefined)[]) => c.filter(Boolean).join(" ");
export type Branding = { name: string; shortName?: string | null; logoUrl?: string | null };
/** The page frame: the church's logo and name, then the content in a centred column. */
export function Shell({ branding, children, wide = false, aside }: { branding: Branding; children: React.ReactNode; wide?: boolean; aside?: React.ReactNode }) {
return (
<div className="min-h-screen flex flex-col">
<header className="bg-white border-b">
<div className={cx("mx-auto flex items-center gap-3 px-4 py-3", wide ? "max-w-5xl" : "max-w-md")}>
{branding.logoUrl ? <img src={branding.logoUrl} alt="" className="h-9 w-auto rounded" /> : <span className="h-9 w-9 rounded-lg bg-brand" aria-hidden />}
<span className="font-semibold text-gray-900">{branding.name}</span>
{aside && <div className="ml-auto">{aside}</div>}
</div>
</header>
<main className={cx("mx-auto w-full flex-1 px-4 py-8", wide ? "max-w-5xl" : "max-w-md")}>{children}</main>
</div>
);
}
export function Card({ children, className }: { children: React.ReactNode; className?: string }) {
return <div className={cx("rounded-2xl border bg-white p-6 shadow-sm", className)}>{children}</div>;
}
export function Heading({ children, sub }: { children: React.ReactNode; sub?: React.ReactNode }) {
return (
<div className="mb-5">
<h1 className="text-xl font-semibold text-gray-900">{children}</h1>
{sub && <p className="mt-1 text-sm text-gray-600">{sub}</p>}
</div>
);
}
type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & { variant?: "primary" | "secondary" | "danger" | "link"; busy?: boolean };
export function Button({ variant = "primary", busy, className, children, disabled, ...rest }: ButtonProps) {
const styles = {
primary: "bg-brand text-white hover:bg-brand-dark",
secondary: "border bg-white text-gray-800 hover:bg-gray-50",
danger: "bg-red-600 text-white hover:bg-red-700",
link: "text-brand underline px-0 py-0",
}[variant];
return (
<button {...rest} disabled={disabled || busy} className={cx("rounded-lg px-4 py-2.5 text-sm font-medium transition disabled:opacity-50", styles, className)}>
{busy ? "Please wait…" : children}
</button>
);
}
type FieldProps = React.InputHTMLAttributes<HTMLInputElement> & { label: string; error?: string | null; hint?: React.ReactNode };
export function Field({ label, error, hint, id, className, ...rest }: FieldProps) {
const fieldId = id ?? `f-${label.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`;
return (
<div className={cx("mb-4", className)}>
<label htmlFor={fieldId} className="mb-1 block text-sm font-medium text-gray-800">{label}</label>
<input
id={fieldId}
aria-invalid={!!error}
aria-describedby={error ? `${fieldId}-error` : undefined}
className={cx("w-full rounded-lg border px-3 py-2.5 text-base focus:outline-none focus:ring-2 focus:ring-brand/50", error ? "border-red-500" : "border-gray-300")}
{...rest}
/>
{hint && !error && <p className="mt-1 text-xs text-gray-500">{hint}</p>}
{error && <p id={`${fieldId}-error`} className="mt-1 text-sm text-red-700">{error}</p>}
</div>
);
}
export function Checkbox({ label, hint, ...rest }: React.InputHTMLAttributes<HTMLInputElement> & { label: React.ReactNode; hint?: React.ReactNode }) {
return (
<label className="mb-3 flex items-start gap-3 text-sm">
<input type="checkbox" className="mt-0.5 h-4 w-4 accent-[rgb(var(--brand))]" {...rest} />
<span>
<span className="text-gray-900">{label}</span>
{hint && <span className="block text-gray-500">{hint}</span>}
</span>
</label>
);
}
export function Notice({ tone = "info", children }: { tone?: "info" | "error" | "success" | "warning"; children: React.ReactNode }) {
const styles = { info: "bg-blue-50 text-blue-900 border-blue-200", error: "bg-red-50 text-red-800 border-red-200", success: "bg-green-50 text-green-800 border-green-200", warning: "bg-amber-50 text-amber-900 border-amber-200" }[tone];
return <div role={tone === "error" ? "alert" : "status"} className={cx("mb-4 rounded-lg border px-4 py-3 text-sm", styles)}>{children}</div>;
}