/** * @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 (
{branding.logoUrl ? : } {branding.name} {aside &&
{aside}
}
{children}
); } export function Card({ children, className }: { children: React.ReactNode; className?: string }) { return
{children}
; } export function Heading({ children, sub }: { children: React.ReactNode; sub?: React.ReactNode }) { return (

{children}

{sub &&

{sub}

}
); } type ButtonProps = React.ButtonHTMLAttributes & { 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 ( ); } type FieldProps = React.InputHTMLAttributes & { 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 (
{hint && !error &&

{hint}

} {error &&

{error}

}
); } export function Checkbox({ label, hint, ...rest }: React.InputHTMLAttributes & { label: React.ReactNode; hint?: React.ReactNode }) { return ( ); } 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
{children}
; }