74 lines
4.2 KiB
TypeScript
74 lines
4.2 KiB
TypeScript
import { z } from "zod";
|
|
|
|
/**
|
|
* The church's brand style (contracts 1.17.0, WEBSITE-1.0-PLAN §3 "Font pairings", decision 15):
|
|
* a font pairing and a corner style, kept in the church profile (`branding.style`) and used by the
|
|
* Website, Accounts' pages, Cross Events' public pages and later the App, so they feel like one
|
|
* church. Colours are already in the profile.
|
|
*
|
|
* The ids are stored in every church's profile, so **an id never changes or goes away** once
|
|
* released. Names shown to churches, and the fonts behind an id, may.
|
|
*/
|
|
|
|
/** How a font falls back while it loads, and which metric-matched fallback `@crosscode/ui` uses. */
|
|
export const FONT_CATEGORIES = ["serif", "sans-serif"] as const;
|
|
export type FontCategory = (typeof FONT_CATEGORIES)[number];
|
|
|
|
export type FontFace = { family: string; category: FontCategory };
|
|
export type FontPairingInfo = { name: string; heading: FontFace; body: FontFace; feel: string };
|
|
|
|
const serif = (family: string): FontFace => ({ family, category: "serif" });
|
|
const sans = (family: string): FontFace => ({ family, category: "sans-serif" });
|
|
|
|
/** The 8 font pairings, all SIL Open Font License, variable and with Latin Extended. Self-hosted only. */
|
|
export const FONT_PAIRINGS = {
|
|
classic: { name: "Classic", heading: serif("Lora"), body: sans("Source Sans 3"), feel: "Traditional serif headings, a plain readable body" },
|
|
scholarly: { name: "Scholarly", heading: serif("EB Garamond"), body: serif("EB Garamond"), feel: "Old-style book type throughout; dignified" },
|
|
editorial: { name: "Editorial", heading: serif("Playfair Display"), body: sans("Inter"), feel: "High-contrast magazine headlines over a neutral body" },
|
|
impact: { name: "Impact", heading: sans("Oswald"), body: sans("Source Sans 3"), feel: "Tall condensed headlines; loud over photos" },
|
|
contemporary: { name: "Contemporary", heading: sans("Outfit"), body: sans("DM Sans"), feel: "Geometric, modern, light-handed" },
|
|
friendly: { name: "Friendly", heading: sans("Nunito"), body: sans("Nunito"), feel: "Rounded ends throughout; warm and informal" },
|
|
warm: { name: "Warm", heading: serif("Fraunces"), body: sans("Nunito Sans"), feel: "A soft, characterful serif with a gentle sans" },
|
|
modern: { name: "Modern", heading: sans("Inter"), body: sans("Inter"), feel: "One neutral sans; lets colour and photos lead" },
|
|
} as const satisfies Record<string, FontPairingInfo>;
|
|
|
|
export const FONT_PAIRING_IDS = Object.keys(FONT_PAIRINGS) as [keyof typeof FONT_PAIRINGS, ...(keyof typeof FONT_PAIRINGS)[]];
|
|
export const fontPairingSchema = z.enum(FONT_PAIRING_IDS);
|
|
export type FontPairing = z.infer<typeof fontPairingSchema>;
|
|
|
|
/** Corner style: the radius of cards, buttons, images and fields. */
|
|
export const CORNERS = ["sharp", "soft", "round"] as const;
|
|
export const cornersSchema = z.enum(CORNERS);
|
|
export type Corners = z.infer<typeof cornersSchema>;
|
|
/** What a profile without `corners` means. */
|
|
export const DEFAULT_CORNERS: Corners = "soft";
|
|
|
|
/** The Website's four templates (ROADMAP-v3 decision 19). */
|
|
export const WEBSITE_TEMPLATES = ["heritage", "bold", "community", "clean"] as const;
|
|
export const websiteTemplateSchema = z.enum(WEBSITE_TEMPLATES);
|
|
export type WebsiteTemplate = z.infer<typeof websiteTemplateSchema>;
|
|
|
|
/**
|
|
* The three pairings each template recommends; the first is its default. Every pairing works in
|
|
* every template: the others are shown under "More".
|
|
*/
|
|
export const TEMPLATE_FONT_PAIRINGS: Record<WebsiteTemplate, readonly [FontPairing, FontPairing, FontPairing]> = {
|
|
heritage: ["classic", "scholarly", "editorial"],
|
|
bold: ["impact", "contemporary", "editorial"],
|
|
community: ["friendly", "warm", "contemporary"],
|
|
clean: ["modern", "classic", "contemporary"],
|
|
};
|
|
|
|
/**
|
|
* `branding.style` in `crosscode.church/1`. Both fields are null until an admin picks one; then
|
|
* the Website uses its template's default pairing, and Events and Accounts keep their system fonts.
|
|
*
|
|
* An id this version doesn't know (from a newer Accounts) reads as null, so a profile with a newer
|
|
* pairing never fails to parse: the product just shows its default.
|
|
*/
|
|
export const brandStyleSchema = z.object({
|
|
fontPairing: fontPairingSchema.nullable().catch(null),
|
|
corners: cornersSchema.nullable().catch(null),
|
|
});
|
|
export type BrandStyle = z.infer<typeof brandStyleSchema>;
|