Accounts 1.7.0 + @crosscode/ui 0.2.0: brand style, the church's fonts and footer, church.update

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-24 17:02:16 +02:00
co-authored by Claude Opus 5.5
parent 0e3534f29f
commit 45a2edd4cc
65 changed files with 963 additions and 55 deletions
+116
View File
@@ -0,0 +1,116 @@
/**
* The church's brand style and footer, shared by Accounts, Cross Events' public pages, the Website
* and later the App (WEBSITE-1.0-PLAN §3 and §9, contracts 1.17.0).
*
* Fonts: import `@crosscode/ui/fonts.css` once (it holds every pairing's @font-face; a browser only
* downloads the files a page uses), then put `brandAttributes(style)` on `<html>`. The page's CSS
* uses `var(--cc-font-body, <its own font>)`, `var(--cc-font-heading, …)` and
* `font-variation-settings: var(--cc-heading-variation, normal)` on headings, and the components
* here use `--cc-radius`, so a church without a pairing keeps the app's own fonts.
*/
import React from "react";
const cx = (...c: (string | false | null | undefined)[]) => c.filter(Boolean).join(" ");
/** `branding.style` from `crosscode.church/1` (structural, so this package needn't depend on the contracts). */
export type BrandStyle = { fontPairing?: string | null; corners?: string | null } | null | undefined;
/** Attributes for `<html>`: the pairing (only when the church picked one) and the corners (`soft` by default). */
export function brandAttributes(style: BrandStyle): Record<string, string> {
const out: Record<string, string> = { "data-cc-corners": style?.corners || "soft" };
if (style?.fontPairing) out["data-cc-fonts"] = style.fontPairing;
return out;
}
const DAYS: Record<string, string> = { monday: "Mondays", tuesday: "Tuesdays", wednesday: "Wednesdays", thursday: "Thursdays", friday: "Fridays", saturday: "Saturdays", sunday: "Sundays" };
const NETWORKS: Record<string, string> = { facebook: "Facebook", instagram: "Instagram", youtube: "YouTube", tiktok: "TikTok", x: "X", spotify: "Spotify", "whatsapp-channel": "WhatsApp channel", other: "Link" };
/** What the footer needs from `crosscode.church/1`. */
export type FooterChurch = {
name: string;
branding: { logoUrl: string | null };
serviceTimes?: { day: string; time: string; label: string | null }[];
contact?: {
email: string | null;
phone: string | null;
whatsapp: string | null;
address: { line1: string; line2: string | null; suburb: string | null; city: string; postalCode: string | null } | null;
};
social?: { network: string; url: string }[];
links: { website: string | null; events: string | null; app: string | null; accounts: string };
};
export type FooterProduct = "website" | "events" | "app" | "accounts";
const PRODUCT_LINKS: { key: FooterProduct; label: string }[] = [
{ key: "website", label: "Website" },
{ key: "events", label: "Events" },
{ key: "app", label: "App" },
{ key: "accounts", label: "Your account" },
];
/** The church's other sites, for a product's header: each that exists except this one. */
export function productLinks(links: FooterChurch["links"], current: FooterProduct): { label: string; href: string }[] {
return PRODUCT_LINKS.filter((p) => p.key !== current && p.key !== "accounts" && links[p.key]).map((p) => ({ label: p.label, href: links[p.key]! }));
}
/**
* One footer for every product: the church's name and logo, service times, address and contact,
* social links, links to its other sites, and the privacy notice. Sections without data are left
* out. `className` lets a Website template restyle it.
*/
export function ChurchFooter({ church, current, privacyUrl, className }: { church: FooterChurch; current: FooterProduct; privacyUrl?: string | null; className?: string }) {
const times = church.serviceTimes ?? [];
const contact = church.contact;
const address = contact?.address;
const social = church.social ?? [];
const sites = PRODUCT_LINKS.filter((p) => p.key !== current && church.links[p.key]);
const tel = (n: string) => `tel:${n.replace(/\s+/g, "")}`;
const heading = "mb-2 text-sm font-semibold text-gray-900 [font-family:var(--cc-font-heading,inherit)] [font-variation-settings:var(--cc-heading-variation,normal)]";
return (
<footer className={cx("border-t border-brand/15 bg-white/80 text-sm text-gray-700", className)}>
<div className="mx-auto grid max-w-5xl gap-8 px-4 py-10 sm:grid-cols-2 lg:grid-cols-4">
<div>
{church.branding.logoUrl
? <img src={church.branding.logoUrl} alt={church.name} className="mb-3 h-10 w-auto max-w-[10rem] object-contain" />
: <p className={cx(heading, "text-base")}>{church.name}</p>}
{address && (
<address className="not-italic leading-relaxed">
{address.line1}{address.line2 && <>, {address.line2}</>}<br />
{[address.suburb, address.city, address.postalCode].filter(Boolean).join(", ")}
</address>
)}
</div>
{times.length > 0 && (
<div>
<h2 className={heading}>Service times</h2>
<ul className="space-y-1">
{times.map((t, i) => <li key={i}>{DAYS[t.day] ?? t.day} {t.time}{t.label && <span className="text-gray-500"> · {t.label}</span>}</li>)}
</ul>
</div>
)}
{contact && (contact.email || contact.phone || contact.whatsapp || social.length > 0) && (
<div>
<h2 className={heading}>Contact</h2>
<ul className="space-y-1">
{contact.phone && <li><a className="hover:text-brand hover:underline" href={tel(contact.phone)}>{contact.phone}</a></li>}
{contact.whatsapp && <li><a className="hover:text-brand hover:underline" href={`https://wa.me/${contact.whatsapp.replace(/\D/g, "")}`}>WhatsApp {contact.whatsapp}</a></li>}
{contact.email && <li><a className="break-all hover:text-brand hover:underline" href={`mailto:${contact.email}`}>{contact.email}</a></li>}
{social.map((s) => <li key={s.url}><a className="hover:text-brand hover:underline" href={s.url} rel="me noopener">{NETWORKS[s.network] ?? s.network}</a></li>)}
</ul>
</div>
)}
{(sites.length > 0 || privacyUrl) && (
<nav aria-label={`${church.name}'s sites`}>
<h2 className={heading}>Our sites</h2>
<ul className="space-y-1">
{sites.map((s) => <li key={s.key}><a className="hover:text-brand hover:underline" href={church.links[s.key]!}>{s.label}</a></li>)}
{privacyUrl && <li><a className="hover:text-brand hover:underline" href={privacyUrl}>Privacy notice</a></li>}
</ul>
</nav>
)}
</div>
<p className="px-4 pb-6 text-center text-xs text-gray-500">© {new Date().getFullYear()} {church.name}</p>
</footer>
);
}
+18 -13
View File
@@ -4,6 +4,8 @@
*/
import React from "react";
export * from "./brand";
const cx = (...c: (string | false | null | undefined)[]) => c.filter(Boolean).join(" ");
export type Branding = { name: string; shortName?: string | null; logoUrl?: string | null };
@@ -12,8 +14,8 @@ export type Branding = { name: string; shortName?: string | null; logoUrl?: stri
/** The church's logo, or its first letter on its colour while it has none. */
export function ChurchMark({ branding, size = "md" }: { branding: Branding; size?: "md" | "lg" }) {
const box = size === "lg" ? "h-14 w-14 text-2xl" : "h-10 w-10 text-lg";
if (branding.logoUrl) return <img src={branding.logoUrl} alt="" className={cx(size === "lg" ? "h-14" : "h-10", "w-auto max-w-[12rem] rounded-xl object-contain")} />;
return <span className={cx(box, "flex shrink-0 items-center justify-center rounded-xl bg-brand font-semibold text-white")} aria-hidden>{(branding.shortName || branding.name || "?").trim().charAt(0).toUpperCase()}</span>;
if (branding.logoUrl) return <img src={branding.logoUrl} alt="" className={cx(size === "lg" ? "h-14" : "h-10", "w-auto max-w-[12rem] rounded-[var(--cc-radius-sm,0.75rem)] object-contain")} />;
return <span className={cx(box, "flex shrink-0 items-center justify-center rounded-[var(--cc-radius-sm,0.75rem)] bg-brand font-semibold text-white")} aria-hidden>{(branding.shortName || branding.name || "?").trim().charAt(0).toUpperCase()}</span>;
}
/**
@@ -21,35 +23,38 @@ export function ChurchMark({ branding, size = "md" }: { branding: Branding; size
* name across the top, the content in a centred column, and a quiet footer. `wide` for the account
* and admin pages; otherwise a sign-in column.
*/
export function Shell({ branding, children, wide = false, aside }: { branding: Branding; children: React.ReactNode; wide?: boolean; aside?: React.ReactNode }) {
/** `footer` replaces the quiet line at the bottom (Accounts 1.7.0 passes the `ChurchFooter`). */
export function Shell({ branding, children, wide = false, aside, footer }: { branding: Branding; children: React.ReactNode; wide?: boolean; aside?: React.ReactNode; footer?: React.ReactNode }) {
return (
<div className="min-h-screen flex flex-col bg-gradient-to-br from-brand/10 via-white to-brand/5">
<header className="border-b border-brand/10 bg-white/90 backdrop-blur">
<div className="mx-auto flex max-w-5xl items-center gap-3 px-4 py-3">
<ChurchMark branding={branding} />
<span className="text-lg font-semibold text-brand-dark">{branding.name}</span>
<span className="text-lg font-semibold text-brand-dark [font-family:var(--cc-font-heading,inherit)] [font-variation-settings:var(--cc-heading-variation,normal)]">{branding.name}</span>
{aside && <div className="ml-auto">{aside}</div>}
</div>
</header>
<main className={cx("mx-auto w-full flex-1 px-4", wide ? "max-w-5xl py-8" : "max-w-md py-10 sm:py-16")}>{children}</main>
<footer className="px-4 py-6 text-center text-xs text-gray-500">
{branding.name} · your church account, for all its sites and apps
</footer>
{footer ?? (
<footer className="px-4 py-6 text-center text-xs text-gray-500">
{branding.name} · your church account, for all its sites and apps
</footer>
)}
</div>
);
}
export function Card({ children, className }: { children: React.ReactNode; className?: string }) {
return <div className={cx("rounded-2xl border border-gray-200 border-t-4 border-t-brand bg-white p-6 shadow-sm sm:p-8", className)}>{children}</div>;
return <div className={cx("rounded-[var(--cc-radius,1rem)] border border-gray-200 border-t-4 border-t-brand bg-white p-6 shadow-sm sm:p-8", className)}>{children}</div>;
}
/** A page's title, with an optional icon in a tile of the church's colour (as on the church's other sites). */
export function Heading({ children, sub, icon }: { children: React.ReactNode; sub?: React.ReactNode; icon?: React.ReactNode }) {
return (
<div className="mb-6 flex items-start gap-3">
{icon && <span className="flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-brand/10 text-brand" aria-hidden>{icon}</span>}
{icon && <span className="flex h-11 w-11 shrink-0 items-center justify-center rounded-[var(--cc-radius-sm,0.75rem)] bg-brand/10 text-brand" aria-hidden>{icon}</span>}
<div>
<h1 className="text-xl font-semibold text-gray-900">{children}</h1>
<h1 className="text-xl font-semibold text-gray-900 [font-family:var(--cc-font-heading,inherit)] [font-variation-settings:var(--cc-heading-variation,normal)]">{children}</h1>
{sub && <p className="mt-1 text-sm text-gray-600">{sub}</p>}
</div>
</div>
@@ -66,7 +71,7 @@ export function Button({ variant = "primary", busy, className, children, disable
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)}>
<button {...rest} disabled={disabled || busy} className={cx("rounded-[var(--cc-radius-button,0.5rem)] px-4 py-2.5 text-sm font-medium transition disabled:opacity-50", styles, className)}>
{busy ? "Please wait…" : children}
</button>
);
@@ -83,7 +88,7 @@ export function Field({ label, error, hint, id, className, ...rest }: FieldProps
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")}
className={cx("w-full rounded-[var(--cc-radius-sm,0.5rem)] 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>}
@@ -106,5 +111,5 @@ export function Checkbox({ label, hint, ...rest }: React.InputHTMLAttributes<HTM
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>;
return <div role={tone === "error" ? "alert" : "status"} className={cx("mb-4 rounded-[var(--cc-radius-sm,0.5rem)] border px-4 py-3 text-sm", styles)}>{children}</div>;
}