/** * 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 ``. The page's CSS * uses `var(--cc-font-body, )`, `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 ``: the pairing (only when the church picked one) and the corners (`soft` by default). */ export function brandAttributes(style: BrandStyle): Record { const out: Record = { "data-cc-corners": style?.corners || "soft" }; if (style?.fontPairing) out["data-cc-fonts"] = style.fontPairing; return out; } const DAYS: Record = { monday: "Mondays", tuesday: "Tuesdays", wednesday: "Wednesdays", thursday: "Thursdays", friday: "Fridays", saturday: "Saturdays", sunday: "Sundays" }; const NETWORKS: Record = { 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; `bottom` goes after the copyright line (a * product's own links, such as its terms and cookie settings). */ export function ChurchFooter({ church, current, privacyUrl, className, bottom }: { church: FooterChurch; current: FooterProduct; privacyUrl?: string | null; className?: string; bottom?: React.ReactNode }) { 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 ( ); }