diff --git a/CHANGELOG.md b/CHANGELOG.md index 496516c..d910964 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,40 @@ Each package and app has its own section and its own tags (`contracts@1.0.0`, `accounts@1.0.0`, …). +## contracts@1.17.0 + accounts@1.7.0 + @crosscode/ui 0.2.0 - 2026-11-24 + +The first release of the Church Website 1.0.0 work (WEBSITE-1.0-PLAN §12). The contracts are +additive and optional: products on 1.16.0 keep working. Accounts 1.7.0 ships with them because it +answers the new `church.update` request. Details of Accounts in `apps/accounts/CHANGELOG.md`. + +- **Brand style** (`./style`): the 8 font pairings confirmed on 2026-11-24 (`FONT_PAIRINGS`: + `classic`, `scholarly`, `editorial`, `impact`, `contemporary`, `friendly`, `warm`, `modern`, each + with its heading and body font), the corner styles (`CORNERS`, `DEFAULT_CORNERS` = `soft`), the + Website's templates (`WEBSITE_TEMPLATES`) and the three pairings each recommends + (`TEMPLATE_FONT_PAIRINGS`, default first). The ids are stored in profiles and never change. +- **`crosscode.church/1`:** optional `branding.style` (`fontPairing`, `corners`, each nullable). An + id a product doesn't know yet reads as null, so a newer Accounts never breaks an older product. +- **`crosscode.church-export/1`:** an optional `website` part (template, first publish, style + settings, pages with their sections, messages, simple events, the publish history's notes and + the media library's alt text). New sample `church-export-website.json`. +- **`church.update`** (identity request, product → Accounts, signed with the link's secret): the + Website's admin changes shared profile facts (plan decision 10). The product checks the person's + role and sends them as `actor`; only the fields given change (`branding` field by field); live at + once, then `church.changed`. Optional `ifUpdatedAt` refuses with the new error code + `PROFILE_CHANGED` when someone saved in between. Reply: the profile (`churchUpdateReplySchema`). + Accounts 1.7.0 takes it from the Website only. +- **Licence:** optional `limits.storageBytes`, the Website's storage limit including add-ons (plan + decision 12). New sample `hub-licence-payload-website.json`. +- **Accounts 1.7.0:** the brand style in Admin → Church profile, the church's fonts, corners and + shared footer on its pages, and `church.update` from the Website. Update Accounts before (or with) + anything that sends `church.update`; nothing does until the Website. +- **`@crosscode/ui` 0.2.0:** `fonts.css` (the 8 pairings' fonts, Latin and Latin Extended, from the + pinned `@fontsource-variable` packages, with Capsize size-matched fallbacks on Arial or Georgia; + generated by `scripts/fonts.mjs`, checked by `npm test`, at most 160 KB per pairing for an + English page), `brandAttributes`, `ChurchFooter`, `productLinks`; the components' corners follow + `--cc-radius` and headings the pairing's heading font. Apps without a pairing look as before. +- `package-lock.json` catches up with the agent's and contracts' versions. + ## agent@1.5.0 + contracts@1.16.0 + crosscode script - 2026-11-23 - **Fix: uninstalling one product removed the whole church.** `crosscode uninstall ` only diff --git a/apps/accounts/CHANGELOG.md b/apps/accounts/CHANGELOG.md index e047ea6..5690d15 100644 --- a/apps/accounts/CHANGELOG.md +++ b/apps/accounts/CHANGELOG.md @@ -1,5 +1,31 @@ # Changelog — Accounts +## [1.7.0] - 2026-11-24 + +Needs contracts 1.17.0. The first part of the Church Website 1.0.0 (WEBSITE-1.0-PLAN §11). + +### Added + +- **Brand style** in the church profile (`branding.style`: font pairing and corners, contracts + 1.17.0). Admin → Church profile → **Brand style** shows each of the 8 pairings in its own fonts, + and the three corner styles. Served in `GET /api/church/v1` and `/api/v2/branding`. +- **The church's fonts and corners on Accounts' pages**: `@crosscode/ui/fonts.css` (self-hosted, no + font requests to anyone else) and `brandAttributes` on ``. Without a pairing the pages + keep the device fonts, so nothing changes until an admin picks one. +- **The shared footer** (`ChurchFooter` from `@crosscode/ui`) on the public pages (sign in, forgot + and reset password, signed out, confirm email): service times, address, contact, social links, + links to the church's other sites and the privacy notice, from the church profile. +- **`church.update`** (contracts 1.17.0): the church's Website changes shared profile facts for its + admins (WEBSITE-1.0-PLAN decision 10). Only from a product linked as `website` + (`WRONG_PRODUCT`), only for an `actor` who signs in through it (`NOT_ALLOWED`), and refused + with `PROFILE_CHANGED` (409) when `ifUpdatedAt` is out of date. Live at once; linked products get + `church.changed`; audited as `church_profile_changed_by_product` with the fields changed. + +### Changed + +- Saving the profile merges `branding` field by field (`mergeProfile`), so a form or product that + sends only part of it (the colours without the style, or only the style) never drops the rest. + ## [1.6.0] - 2026-11-20 ### Added diff --git a/apps/accounts/WHATS-NEW.md b/apps/accounts/WHATS-NEW.md index 17d0aa0..8d49983 100644 --- a/apps/accounts/WHATS-NEW.md +++ b/apps/accounts/WHATS-NEW.md @@ -3,6 +3,17 @@ What each version changes for the church, in plain language (read by the Hub like Cross Events' WHATS-NEW.md; a section shows once its version is tagged). +## 1.7.0 + +- **Choose your church's fonts and corners.** Admin → Church profile → **Brand style** has 8 font + pairings, each shown in its own fonts, and sharp, soft or round corners. Your sign-in pages use + them now, and your new Church Website and Cross Events' public pages will too, so all your sites + look like one church. Until you pick, nothing changes. +- **A footer with your church's details** under the sign-in pages: service times, address, contact + details and links to your church's other sites, from the church profile. +- Getting ready for the **Church Website**: its admins will be able to change your service times, + logo and contact details from the website, and they'll change everywhere at once. + ## 1.6.0 - **You're told about each sign-in.** After someone signs in, they get an email saying when, roughly diff --git a/apps/accounts/backend/package.json b/apps/accounts/backend/package.json index 0b9edf7..02fdda1 100644 --- a/apps/accounts/backend/package.json +++ b/apps/accounts/backend/package.json @@ -1,6 +1,6 @@ { "name": "@crosscode/accounts-backend", - "version": "1.6.0", + "version": "1.7.0", "description": "Cross Code Accounts: the church's sign-in (OpenID Connect provider), account pages API and admin API", "private": true, "type": "module", diff --git a/apps/accounts/backend/src/church/profile.ts b/apps/accounts/backend/src/church/profile.ts index 7b441dd..cf37a7f 100644 --- a/apps/accounts/backend/src/church/profile.ts +++ b/apps/accounts/backend/src/church/profile.ts @@ -69,10 +69,37 @@ export class ProfileError extends Error { } } -/** Saves an admin's changes (merged onto what's there), and tells the linked products. */ -export async function updateProfile(ctx: Ctx, input: unknown): Promise { +/** The profile changed since the editor loaded it (`church.update` with `ifUpdatedAt`). */ +export class ProfileChangedError extends Error { + constructor(public updatedAt: string) { + super('The church profile was changed by someone else since you opened it.'); + } +} + +const isObject = (v: unknown): v is Record => !!v && typeof v === 'object' && !Array.isArray(v); + +/** + * The fields given replace what's there; `branding` is merged field by field (1.7.0), so a form + * that doesn't know `branding.style` (or sends only the style) never drops the rest. + */ +export function mergeProfile(base: Record, input: unknown): Record { + if (!isObject(input)) return { ...base }; + const next: Record = { ...base, ...input }; + if (isObject(input.branding)) next.branding = { ...(isObject(base.branding) ? base.branding : {}), ...input.branding }; + return next; +} + +/** + * Saves changes (merged onto what's there) from an admin here or a product (`church.update`), + * and tells the linked products. With `ifUpdatedAt`, refuses if someone saved since. + */ +export async function updateProfile(ctx: Ctx, input: unknown, opts: { ifUpdatedAt?: string } = {}): Promise { const current = await storedProfile(ctx); - const next = { ...DEFAULTS(ctx), ...current, ...(input && typeof input === 'object' ? input : {}) }; + if (opts.ifUpdatedAt) { + const now = current.updatedAt ?? new Date(0).toISOString(); + if (new Date(now).getTime() !== new Date(opts.ifUpdatedAt).getTime()) throw new ProfileChangedError(now); + } + const next = mergeProfile({ ...DEFAULTS(ctx), ...current }, input); const check = profileInputSchema.safeParse(next); if (!check.success) { const fields = Object.fromEntries(check.error.issues.map((i) => [i.path.join('.'), i.message])); @@ -92,6 +119,7 @@ export async function branding(ctx: Ctx) { shortName: c.shortName, logoUrl: c.branding.logoUrl, colours: c.branding.colours, + style: { fontPairing: c.branding.style?.fontPairing ?? null, corners: c.branding.style?.corners ?? null }, signupEnabled: await ctx.settings.bool('signup_enabled', true), }; } diff --git a/apps/accounts/backend/src/links/requests.ts b/apps/accounts/backend/src/links/requests.ts index c004411..10a33ca 100644 --- a/apps/accounts/backend/src/links/requests.ts +++ b/apps/accounts/backend/src/links/requests.ts @@ -31,6 +31,10 @@ import { emailProblem, normaliseEmail, profileChanged, profileOf, setNewsConsent import { turnOff } from '../accounts/twoFactor.js'; import { signOutEverywhere } from '../oidc/sessions.js'; import { anonymise } from '../privacy/deletion.js'; +import { ProfileChangedError, ProfileError, updateProfile } from '../church/profile.js'; + +/** Products that may change the church profile with church.update (1.7.0, WEBSITE-1.0-PLAN decision 10). */ +const PROFILE_EDITORS = new Set(['website']); /** A demo person's address (contracts DEMO_EMAIL_DOMAIN, reserved: no real person has one). */ export const isDemoEmail = (email: string) => email.toLowerCase().endsWith(`@${DEMO_EMAIL_DOMAIN}`); @@ -319,6 +323,22 @@ async function handle(ctx: Ctx, provider: Provider, link: ProductLink, secret: s await logRequest(ctx, link, r, 'people_checked_by_product', null, req, { checked: people.length, deleted: count('deleted'), unknown: count('unknown') }); return reply({ people }); } + case 'church.update': { + // The product checked the person's role (Accounts doesn't know the Website's); Accounts + // checks it's the Website, that the person signs in through it, and audits it as theirs. + if (!PROFILE_EDITORS.has(link.product)) throw new RequestError("Only the church's Website changes the church profile from outside Accounts.", 'WRONG_PRODUCT', 403); + const known = await ctx.db.productPerson.findFirst({ where: { linkId: link.installId, accountId: r.actor } }); + if (!known) throw new RequestError("The person making the change isn't someone who signs in to this product.", 'NOT_ALLOWED', 403); + try { + const church = await updateProfile(ctx, r.church, { ifUpdatedAt: r.ifUpdatedAt }); + await logRequest(ctx, link, r, 'church_profile_changed_by_product', null, req, { fields: Object.keys(r.church) }); + return reply({ church }); + } catch (e) { + if (e instanceof ProfileChangedError) throw new RequestError(e.message, 'PROFILE_CHANGED', 409); + if (e instanceof ProfileError) throw new RequestError(`${e.message} ${Object.entries(e.fields).map(([k, v]) => `${k}: ${v}`).join('; ')}`.trim(), 'INVALID_REQUEST', 400); + throw e; + } + } case 'church.branding': { const changed = await applyLook(ctx, r.church, r.overwrite); await logRequest(ctx, link, r, 'church_look_from_product', null, req, { changed, overwrite: r.overwrite }); diff --git a/apps/accounts/backend/tests/churchUpdate.test.ts b/apps/accounts/backend/tests/churchUpdate.test.ts new file mode 100644 index 0000000..0d371e2 --- /dev/null +++ b/apps/accounts/backend/tests/churchUpdate.test.ts @@ -0,0 +1,108 @@ +// church.update (contracts 1.17.0, Accounts 1.7.0, WEBSITE-1.0-PLAN decision 10): the Website's +// admin changes shared profile facts through Accounts, and the brand style is kept by every save. +import assert from 'node:assert/strict'; +import crypto from 'node:crypto'; +import { after, before, describe, test } from 'node:test'; +import { ACCOUNTS_REQUEST_PATH, IDENTITY_REQUEST_SCHEMA } from '@crosscode/contracts'; +import { ed25519PublicToPem, generateEd25519, LINK_HEADERS, newLinkSecret, signedHeaders } from '@crosscode/contracts/signing'; +import { startHarness, type Harness } from './support/harness.js'; +import { church, mergeProfile, updateProfile } from '../src/church/profile.js'; + +const WEBSITE_ID = '7e2a1c3d-9b4f-4d6e-8f70-2b3c4d5e6f70'; +const EVENTS_ID = '8f3b2d4e-0c5a-4e7f-9a81-3c4d5e6f7a81'; +let h: Harness; +const secrets: Record = {}; +let editor: string; + +before(async () => { + h = await startHarness(); + for (const [id, product] of [[WEBSITE_ID, 'website'], [EVENTS_ID, 'events']] as const) { + secrets[id] = newLinkSecret(); + await h.db.productLink.create({ + data: { installId: id, product, url: `https://${product}.hope.test`, publicKey: ed25519PublicToPem(generateEd25519().publicKey), secret: h.ctx.secrets.encrypt(secrets[id]!), connectedAt: new Date() }, + }); + } + const a = await h.makeAccount({ email: 'editor@hope.test' }); + editor = a.id as string; + for (const linkId of [WEBSITE_ID, EVENTS_ID]) await h.db.productPerson.create({ data: { linkId, accountId: editor, via: 'sign_in', createdAt: new Date() } }); + await updateProfile(h.ctx, { name: 'Hope Family Church', branding: { logoUrl: null, iconUrl: null, colours: { primary: '#1f4e79', accent: '#f2a900' } } }); +}); +after(async () => { await h.close(); }); + +async function ask(body: Record, from = WEBSITE_ID) { + const raw = JSON.stringify({ schema: IDENTITY_REQUEST_SCHEMA, requestId: crypto.randomUUID(), actor: editor, type: 'church.update', ...body }); + const headers = signedHeaders(LINK_HEADERS, { senderId: from, secret: secrets[from]!, rawBody: raw }); + const res = await fetch(`${h.publicUrl}${ACCOUNTS_REQUEST_PATH}`, { method: 'POST', body: raw, headers: { 'content-type': 'application/json', ...headers } }); + return { status: res.status, body: (await res.json()) as Record }; +} + +describe('church.update from the Website', () => { + test('changes only the style, keeps the colours and logo, and goes live at once', async () => { + const res = await ask({ church: { branding: { style: { fontPairing: 'warm', corners: 'round' } } } }); + assert.equal(res.status, 200, JSON.stringify(res.body)); + const c = await church(h.ctx); + assert.deepEqual(c.branding.style, { fontPairing: 'warm', corners: 'round' }); + assert.equal(c.branding.colours.primary, '#1f4e79'); + assert.equal(c.name, 'Hope Family Church'); + assert.deepEqual((res.body.church as { branding: unknown }).branding, c.branding); + }); + + test('tells every linked product the profile changed, and audits it as the editor', async () => { + const before = await h.db.delivery.count(); + const res = await ask({ church: { shortName: 'Hope Family' } }); + assert.equal(res.status, 200, JSON.stringify(res.body)); + assert.ok((await h.db.delivery.count()) > before); + const log = await h.db.auditLog.findFirst({ where: { action: 'church_profile_changed_by_product' }, orderBy: { createdAt: 'desc' } }); + assert.equal(log?.actorId, editor); + }); + + test('refuses another product, someone who doesn\'t sign in through the Website, and a stale edit', async () => { + const events = await ask({ church: { name: 'Hijacked' } }, EVENTS_ID); + assert.equal(events.status, 403); + assert.equal(events.body.code, 'WRONG_PRODUCT'); + + const stranger = await h.makeAccount({ email: 'stranger@hope.test' }); + const notKnown = await ask({ actor: stranger.id as string, church: { name: 'Hijacked' } }); + assert.equal(notKnown.status, 403); + assert.equal(notKnown.body.code, 'NOT_ALLOWED'); + + const stale = await ask({ ifUpdatedAt: '2020-01-01T00:00:00.000Z', church: { name: 'Hijacked' } }); + assert.equal(stale.status, 409); + assert.equal(stale.body.code, 'PROFILE_CHANGED'); + assert.equal((await church(h.ctx)).name, 'Hope Family Church'); + }); + + test('takes an edit made on the current version', async () => { + const current = await church(h.ctx); + const res = await ask({ ifUpdatedAt: current.updatedAt, church: { serviceTimes: [{ day: 'sunday', time: '09:00', label: null, campus: null, note: null }] } }); + assert.equal(res.status, 200, JSON.stringify(res.body)); + assert.equal((await church(h.ctx)).serviceTimes.length, 1); + }); + + test('an invalid value is refused with what\'s wrong', async () => { + const res = await ask({ church: { contact: { email: null, phone: '016 123', whatsapp: null, address: null } } }); + assert.equal(res.status, 400); + assert.equal(res.body.code, 'INVALID_REQUEST'); + }); +}); + +describe('saving the profile keeps the brand style', () => { + test('an admin form that sends branding without the style doesn\'t drop it', async () => { + await updateProfile(h.ctx, { branding: { style: { fontPairing: 'classic', corners: 'sharp' } } }); + await updateProfile(h.ctx, { branding: { logoUrl: null, iconUrl: null, colours: { primary: '#204060', accent: null } } }); + const c = await church(h.ctx); + assert.deepEqual(c.branding.style, { fontPairing: 'classic', corners: 'sharp' }); + assert.equal(c.branding.colours.primary, '#204060'); + }); + + test('mergeProfile replaces other fields whole and merges branding', () => { + const merged = mergeProfile({ name: 'A', social: [1], branding: { logoUrl: 'x', colours: { primary: '#000000' } } }, { social: [], branding: { colours: { primary: '#ffffff' } } }); + assert.deepEqual(merged, { name: 'A', social: [], branding: { logoUrl: 'x', colours: { primary: '#ffffff' } } }); + }); + + test('the sign-in pages get the style', async () => { + const res = await fetch(`${h.publicUrl}/api/v2/branding`); + const b = (await res.json()) as { style: unknown }; + assert.deepEqual(b.style, { fontPairing: 'classic', corners: 'sharp' }); + }); +}); diff --git a/apps/accounts/e2e/brand.spec.ts b/apps/accounts/e2e/brand.spec.ts new file mode 100644 index 0000000..3f7cff6 --- /dev/null +++ b/apps/accounts/e2e/brand.spec.ts @@ -0,0 +1,43 @@ +import AxeBuilder from "@axe-core/playwright"; +import { expect, test } from "@playwright/test"; + +// 1.7.0 (WEBSITE-1.0-PLAN §3, §9): the church's brand style and shared footer on Accounts' public +// pages. The e2e church (e2e/server.ts) has the "warm" pairing, round corners and service times. +const PRODUCT = "http://localhost:5211"; + +test("the sign-in page uses the church's fonts and corners, and shows its footer", async ({ page }) => { + await page.goto(`${PRODUCT}/start?returnTo=/`); + await expect(page.getByRole("heading", { name: "Sign in to Hope Family Church" })).toBeVisible(); + await expect(page.locator("html")).toHaveAttribute("data-cc-fonts", "warm"); + await expect(page.locator("html")).toHaveAttribute("data-cc-corners", "round"); + + const heading = page.getByRole("heading", { name: "Sign in to Hope Family Church" }); + expect(await heading.evaluate((el) => getComputedStyle(el).fontFamily)).toContain("CC Fraunces"); + expect(await page.locator("body").evaluate((el) => getComputedStyle(el).fontFamily)).toContain("CC Nunito Sans"); + // The font files themselves load from this site (self-hosted), not from anyone else. + await page.evaluate(() => document.fonts.ready); + expect(await page.evaluate(() => document.fonts.check('600 20px "CC Fraunces"'))).toBe(true); + expect(await page.getByRole("button", { name: "Sign in" }).evaluate((el) => getComputedStyle(el).borderRadius)).toBe("9999px"); + + const footer = page.locator("footer"); + await expect(footer.getByRole("heading", { name: "Service times" })).toBeVisible(); + await expect(footer).toContainText("Sundays 09:00"); + await expect(footer.getByRole("link", { name: "office@hope.test" })).toHaveAttribute("href", "mailto:office@hope.test"); + await expect(footer.getByRole("link", { name: "Website" })).toHaveAttribute("href", PRODUCT); + await expect(footer.getByRole("link", { name: "Privacy notice" })).toHaveAttribute("href", "/privacy"); +}); + +test("fonts never come from another site", async ({ page }) => { + const foreign: string[] = []; + page.on("request", (r) => { if (/\.(woff2?|ttf|otf)(\?|$)/.test(r.url()) && !r.url().startsWith("http://localhost:3210/")) foreign.push(r.url()); }); + await page.goto(`${PRODUCT}/start?returnTo=/`); + await page.evaluate(() => document.fonts.ready); + expect(foreign).toEqual([]); +}); + +test("the sign-in page with the footer passes axe (WCAG 2.2 AA)", async ({ page }) => { + await page.goto(`${PRODUCT}/start?returnTo=/`); + await expect(page.locator("footer")).toBeVisible(); + const results = await new AxeBuilder({ page }).withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa"]).analyze(); + expect(results.violations.map((v) => `${v.id}: ${v.nodes.map((n) => n.target.join(" ")).join(", ")}`)).toEqual([]); +}); diff --git a/apps/accounts/e2e/server.ts b/apps/accounts/e2e/server.ts index 09badc9..ca3ca7b 100644 --- a/apps/accounts/e2e/server.ts +++ b/apps/accounts/e2e/server.ts @@ -29,7 +29,13 @@ const messenger = new MemoryMessenger(); const ctx = createCtx(loadConfig({ ACCOUNTS_URL: WEB, NODE_ENV: 'test', JOBS_ENABLED: 'false', LINKS_ALLOW_PRIVATE: 'true', HUB_URL: 'http://127.0.0.1:1', TRUST_PROXY: 'true' }), db as never, { messenger }); await ctx.settings.setMany({ hub_install_id: '9a4c2f1e-7b3d-4e5a-8c6f-0d1e2f3a4b5c', - church_profile: JSON.stringify({ name: 'Hope Family Church', shortName: 'Hope', branding: { logoUrl: null, iconUrl: null, colours: { primary: '#7c2d12', accent: '#f2a900' } } }), + // 1.7.0: a brand style, service times and contact details, so the pages show the church's fonts and footer. + church_profile: JSON.stringify({ + name: 'Hope Family Church', shortName: 'Hope', + branding: { logoUrl: null, iconUrl: null, colours: { primary: '#7c2d12', accent: '#f2a900' }, style: { fontPairing: 'warm', corners: 'round' } }, + serviceTimes: [{ day: 'sunday', time: '09:00', label: 'Morning service', campus: null, note: null }], + contact: { email: 'office@hope.test', phone: '+27161234567', whatsapp: null, address: null }, + }), }); const linkSecret = newLinkSecret(); await db.productLink.create({ data: { installId: PRODUCT_ID, product: 'website', url: PRODUCT, publicKey: ed25519PublicToPem(generateEd25519().publicKey), secret: ctx.secrets.encrypt(linkSecret), connectedAt: new Date() } }); diff --git a/apps/accounts/frontend/package.json b/apps/accounts/frontend/package.json index b2a9303..a026e85 100644 --- a/apps/accounts/frontend/package.json +++ b/apps/accounts/frontend/package.json @@ -1,6 +1,6 @@ { "name": "@crosscode/accounts-frontend", - "version": "1.6.0", + "version": "1.7.0", "private": true, "description": "Cross Code Accounts: the church's sign-in pages, the account page and admin", "scripts": { diff --git a/apps/accounts/frontend/src/app/account/confirm-email/ConfirmEmail.tsx b/apps/accounts/frontend/src/app/account/confirm-email/ConfirmEmail.tsx index 8c622cf..edb85e5 100644 --- a/apps/accounts/frontend/src/app/account/confirm-email/ConfirmEmail.tsx +++ b/apps/accounts/frontend/src/app/account/confirm-email/ConfirmEmail.tsx @@ -2,7 +2,8 @@ import Link from "next/link"; import { useState } from "react"; -import { Card, Heading, Notice, Shell } from "@crosscode/ui"; +import { Card, Heading, Notice } from "@crosscode/ui"; +import { PublicShell } from "@/components/PublicShell"; import { useBranding } from "@/components/BrandingProvider"; import { call, selfSignIn } from "@/lib/api"; import { useExternalEffect } from "@/lib/hooks"; @@ -20,12 +21,12 @@ export function ConfirmEmail({ token }: { token: string }) { return () => { alive = false; }; }, [token]); return ( - + Your email address {state ? {state.text} :

Confirming…

} Back to your account
-
+ ); } diff --git a/apps/accounts/frontend/src/app/admin/Admin.tsx b/apps/accounts/frontend/src/app/admin/Admin.tsx index 52bcea2..6e2008a 100644 --- a/apps/accounts/frontend/src/app/admin/Admin.tsx +++ b/apps/accounts/frontend/src/app/admin/Admin.tsx @@ -10,6 +10,7 @@ import { Card, Heading } from "@/components/Panel"; import { call, selfSignIn } from "@/lib/api"; import { useExternalEffect } from "@/lib/hooks"; import { ADMIN_SECTIONS, type AdminSection } from "@/lib/sections"; +import { BrandStyle } from "./BrandStyle"; const when = (iso: string | null | undefined) => (iso ? new Date(iso).toLocaleString("en-ZA", { day: "numeric", month: "short", year: "numeric", hour: "2-digit", minute: "2-digit" }) : "—"); @@ -55,7 +56,7 @@ export function Admin({ section = "people" }: { section?: AdminSection }) { {section === "people" && }
{section === "deletions" && } - {section === "church" && } + {section === "church" && <>} {section === "linked" && } {section === "signin" && } {section === "messages" && } diff --git a/apps/accounts/frontend/src/app/admin/BrandStyle.tsx b/apps/accounts/frontend/src/app/admin/BrandStyle.tsx new file mode 100644 index 0000000..9170f2b --- /dev/null +++ b/apps/accounts/frontend/src/app/admin/BrandStyle.tsx @@ -0,0 +1,98 @@ +"use client"; + +import React, { useState } from "react"; +import { useRouter } from "next/navigation"; +import { CORNERS, FONT_PAIRING_IDS, FONT_PAIRINGS, type Corners, type FontPairing } from "@crosscode/contracts"; +import { Button } from "@crosscode/ui"; +import { Card, Heading } from "@/components/Panel"; +import { call } from "@/lib/api"; +import { useExternalEffect } from "@/lib/hooks"; + +type Style = { fontPairing: FontPairing | null; corners: Corners | null }; +type ChurchStyle = { branding: { style?: Style } }; + +const CORNER_LABELS: Record = { + sharp: { name: "Sharp", radius: "0" }, + soft: { name: "Soft", radius: "0.5rem" }, + round: { name: "Round", radius: "9999px" }, +}; + +/** + * The church's brand style (1.7.0, WEBSITE-1.0-PLAN §3): a font pairing and corners, shared by + * Accounts' pages, the Website and Cross Events. Each option is shown in its own fonts (fonts.css + * is loaded on every page; a pairing's files download only when shown). + */ +export function BrandStyle({ flash }: { flash: (tone: "success" | "error", text: string) => void }) { + const router = useRouter(); + const [saved, setSaved] = useState - + {children} diff --git a/apps/accounts/frontend/src/app/reset/Reset.tsx b/apps/accounts/frontend/src/app/reset/Reset.tsx index 3d2ec70..21ce5d3 100644 --- a/apps/accounts/frontend/src/app/reset/Reset.tsx +++ b/apps/accounts/frontend/src/app/reset/Reset.tsx @@ -2,7 +2,8 @@ import { KeyRound } from "lucide-react"; import React, { useState } from "react"; -import { Button, Card, Field, Heading, Notice, Shell } from "@crosscode/ui"; +import { Button, Card, Field, Heading, Notice } from "@crosscode/ui"; +import { PublicShell } from "@/components/PublicShell"; import { useBranding } from "@/components/BrandingProvider"; import { call, selfSignIn } from "@/lib/api"; @@ -11,7 +12,7 @@ export function Reset({ token }: { token: string | null }) { const [busy, setBusy] = useState(false); const [error, setError] = useState(null); return ( - + } sub="At least 8 characters.">Choose a new password {error && {error}} @@ -29,6 +30,6 @@ export function Reset({ token }: { token: string | null }) { - + ); } diff --git a/apps/accounts/frontend/src/app/signed-out/page.tsx b/apps/accounts/frontend/src/app/signed-out/page.tsx index 16ffc4f..673b0d4 100644 --- a/apps/accounts/frontend/src/app/signed-out/page.tsx +++ b/apps/accounts/frontend/src/app/signed-out/page.tsx @@ -1,18 +1,19 @@ "use client"; import { LogOut } from "lucide-react"; -import { Card, Heading, Shell } from "@crosscode/ui"; +import { Card, Heading } from "@crosscode/ui"; +import { PublicShell } from "@/components/PublicShell"; import { useBranding } from "@/components/BrandingProvider"; import { selfSignIn } from "@/lib/api"; export default function SignedOutPage() { const branding = useBranding(); return ( - + } sub={`You've been signed out of all of ${branding.name}'s sites.`}>You're signed out Sign in again - + ); } diff --git a/apps/accounts/frontend/src/app/signin/SignIn.tsx b/apps/accounts/frontend/src/app/signin/SignIn.tsx index a9420c6..41c3018 100644 --- a/apps/accounts/frontend/src/app/signin/SignIn.tsx +++ b/apps/accounts/frontend/src/app/signin/SignIn.tsx @@ -3,7 +3,8 @@ import { AlertTriangle, FileText, KeyRound, LogIn, Mail, Megaphone, ShieldCheck, UserPlus } from "lucide-react"; import React, { useState } from "react"; import QRCode from "qrcode"; -import { Button, Card, Checkbox, Field, Heading, Notice, Shell } from "@crosscode/ui"; +import { Button, Card, Checkbox, Field, Heading, Notice } from "@crosscode/ui"; +import { PublicShell } from "@/components/PublicShell"; import { useBranding } from "@/components/BrandingProvider"; import { NoticeText } from "@/components/NoticeText"; import { call, type ApiError } from "@/lib/api"; @@ -82,7 +83,7 @@ export function SignIn({ uid }: { uid: string }) { return r; }; - const frame = (children: React.ReactNode) => {children}; + const frame = (children: React.ReactNode) => {children}; if (codes) { return frame( { const next = codes.next; setCodes(null); go(next); }} />); diff --git a/apps/accounts/frontend/src/components/BrandingProvider.tsx b/apps/accounts/frontend/src/components/BrandingProvider.tsx index 3b95b88..cfbc2ca 100644 --- a/apps/accounts/frontend/src/components/BrandingProvider.tsx +++ b/apps/accounts/frontend/src/components/BrandingProvider.tsx @@ -1,8 +1,10 @@ "use client"; import React, { createContext, useContext } from "react"; +import type { FooterChurch } from "@crosscode/ui"; -export type ClientBranding = { name: string; shortName: string | null; logoUrl: string | null; signupEnabled: boolean; setupNeeded: boolean }; +/** `church` (1.7.0): the profile for the shared footer, null when it couldn't be loaded. */ +export type ClientBranding = { name: string; shortName: string | null; logoUrl: string | null; signupEnabled: boolean; setupNeeded: boolean; church?: FooterChurch | null }; const Ctx = createContext({ name: "Sign in", shortName: null, logoUrl: null, signupEnabled: true, setupNeeded: false }); diff --git a/apps/accounts/frontend/src/components/PublicShell.tsx b/apps/accounts/frontend/src/components/PublicShell.tsx new file mode 100644 index 0000000..b5fa8c2 --- /dev/null +++ b/apps/accounts/frontend/src/components/PublicShell.tsx @@ -0,0 +1,16 @@ +"use client"; + +import React from "react"; +import { ChurchFooter, Shell } from "@crosscode/ui"; +import { useBranding } from "@/components/BrandingProvider"; + +/** + * The frame of the public pages (sign in, forgot, reset, signed out, confirm email) with the + * church's shared footer (1.7.0, WEBSITE-1.0-PLAN §9): its service times, contact and links to its + * other sites, as on the Website and Cross Events. + */ +export function PublicShell({ children }: { children: React.ReactNode }) { + const branding = useBranding(); + const footer = branding.church ? : undefined; + return {children}; +} diff --git a/apps/accounts/frontend/src/lib/branding.ts b/apps/accounts/frontend/src/lib/branding.ts index 7b619e0..e176ea0 100644 --- a/apps/accounts/frontend/src/lib/branding.ts +++ b/apps/accounts/frontend/src/lib/branding.ts @@ -1,9 +1,13 @@ +import type { FooterChurch } from "@crosscode/ui"; + /** The church's branding from the backend, for the server-rendered frame of every page. */ export type BrandingData = { name: string; shortName: string | null; logoUrl: string | null; colours: { primary: string; accent: string | null }; + /** 1.7.0: the font pairing and corners (null: not picked). */ + style?: { fontPairing: string | null; corners: string | null }; signupEnabled: boolean; setupNeeded: boolean; }; @@ -20,6 +24,17 @@ export async function loadBranding(): Promise { return { name: "Sign in", shortName: null, logoUrl: null, colours: { primary: "#1f4e79", accent: null }, signupEnabled: true, setupNeeded: false }; } +/** The church profile (`crosscode.church/1`) for the shared footer (1.7.0), or null while it can't be had. */ +export async function loadChurch(): Promise { + try { + const res = await fetch(`${api}/api/church/v1`, { next: { revalidate: 60 } }); + if (res.ok) return (await res.json()) as FooterChurch; + } catch { + // As loadBranding: the page works without it. + } + return null; +} + /** "#1f4e79" → "31 78 121" (Tailwind's rgb(var(--brand) / alpha)), and a darker shade for hover. */ export function rgbVars(hex: string): { brand: string; dark: string } { const m = /^#([0-9a-f]{6})$/i.exec(hex) ?? ["", "1f4e79"]; diff --git a/docs/HANDOVER.md b/docs/HANDOVER.md index 4535d32..8791ff1 100644 --- a/docs/HANDOVER.md +++ b/docs/HANDOVER.md @@ -25,7 +25,7 @@ every release). | Phase | What | State | |-------|------|-------| -| 0 | contracts 1.0.0 → 1.16.0 | **Released and in use.** Not published to a registry (decision 22): the Hub gets a packed release committed to its repo (`backend/vendor/`) | +| 0 | contracts 1.0.0 → 1.17.0 | **Released and in use.** Not published to a registry (decision 22): the Hub gets a packed release committed to its repo (`backend/vendor/`) | | 1 | Hub 2.0 → 2.20.0 | **Released, deployed and tested** (Hub `v2.20.0`) | | 1b | Cross Events 2.2.0: moved here as `apps/events`, the `crosscode` script | **Released, rolled out and tested.** Every install adopted onto the monorepo | | 1c | Cross Events 2.3.x: authenticator app 2FA | **Released and rolled out** (carried into Accounts in phase 4) | @@ -34,7 +34,7 @@ every release). | 3 | Accounts 1.0.0 | **Released, rolled out and tested** (now `accounts@1.6.0`; [ACCOUNTS-1.0-PLAN.md](./ACCOUNTS-1.0-PLAN.md)) | | 4 | Cross Events 3.0.0: sign-in through Accounts | **Released, rolled out and tested** (now `events@3.6.1`; [EVENTS-3.0-PLAN.md](./EVENTS-3.0-PLAN.md)). Churches sign in through their Accounts; crosscode-site `v1.6.0` deployed | | 4+ | Running it: jobs from the dashboard, styled emails, .env from the Hub, sign-in health, the nightly people check; then frp config and one-product uninstalls, and the Hub's popups, pickers and port list | **Released, deployed and tested** 2026-11-20 and 2026-11-23 (below) | -| 5 | Church Website 1.0.0 | **Planned** 2026-11-21: [WEBSITE-1.0-PLAN.md](./WEBSITE-1.0-PLAN.md) (all decisions confirmed). Font pairings confirmed 2026-11-24 (§3). contracts 1.17.0 in progress | +| 5 | Church Website 1.0.0 | **Planned** 2026-11-21: [WEBSITE-1.0-PLAN.md](./WEBSITE-1.0-PLAN.md) (all decisions confirmed). Font pairings confirmed 2026-11-24 (§3). `contracts@1.17.0` and `accounts@1.7.0` released 2026-11-24 (Accounts not yet rolled out); Events 3.7.0 next | | 6–7 | App 1.0.0 → App 1.x | Not started | ## Released 2026-11-23 @@ -100,8 +100,8 @@ out"). 1. **Phase 5, Church Website 1.0.0** (ROADMAP §6, §9). Planned in [WEBSITE-1.0-PLAN.md](./WEBSITE-1.0-PLAN.md): decisions all confirmed 2026-11-21. Font pairings - confirmed 2026-11-24 (§3). Order: - contracts 1.17.0 → Accounts 1.7.0 → Events 3.7.0 (shared fonts and footer) → **Hub 2.21.0** (the + confirmed 2026-11-24 (§3). Order: ~~contracts 1.17.0~~ → ~~Accounts 1.7.0~~ (both released 2026-11-24; Accounts + ships with contracts because it answers the new `church.update`) → Events 3.7.0 (shared fonts and footer) → **Hub 2.21.0** (the plan said 2.13.0; the Hub has moved on since) → `website@1.0.0` → Hope Family Church → a second church → crosscode-site 1.7.0. 2. **Archive `hope-events`** if it isn't yet (every install now reports 2.2.0 or later; diff --git a/docs/VERSIONS.md b/docs/VERSIONS.md index 3f47e37..2ac3a97 100644 --- a/docs/VERSIONS.md +++ b/docs/VERSIONS.md @@ -1,6 +1,6 @@ # Versions — the latest release of everything -Last updated: 2026-11-23. Taken from the git tags, which is what a release is here (branch → merge → +Last updated: 2026-11-24. Taken from the git tags, which is what a release is here (branch → merge → tag → push, see [HANDOVER.md](./HANDOVER.md) "Releasing"). **Update this file with every release.** "Released" means tagged and pushed. Whether a release is **deployed** or rolled out is recorded @@ -11,9 +11,9 @@ separately below; the two often differ. | What | Repo | Latest | Tag | Released | |------|------|--------|-----|----------| | Cross Events | `crosscode-platform` (`apps/events`) | **3.6.1** | `events@3.6.1` | 2026-11-20 | -| Accounts | `crosscode-platform` (`apps/accounts`) | **1.6.0** | `accounts@1.6.0` | 2026-11-20 | +| Accounts | `crosscode-platform` (`apps/accounts`) | **1.7.0** | `accounts@1.7.0` | 2026-11-24 | | Server agent | `crosscode-platform` (`apps/agent`) | **1.5.0** | `agent@1.5.0` | 2026-11-23 | -| Contracts | `crosscode-platform` (`packages/contracts`) | **1.16.0** | `contracts@1.16.0` | 2026-11-23 | +| Contracts | `crosscode-platform` (`packages/contracts`) | **1.17.0** | `contracts@1.17.0` | 2026-11-24 | | Cross Code Hub | `events-hub` | **2.20.0** | `v2.20.0` | 2026-11-23 | | crosscode.co.za | `crosscode-site` | **1.6.1** | `v1.6.1` | 2026-11-23 | | `crosscode` script | `crosscode-platform` (`scripts/`) | `main` | none | 2026-11-23 (last change: uninstall, export and purge one product of a church) | @@ -28,8 +28,8 @@ on each run, so merging to `main` and pushing releases it. Its changes are liste |------|-------|-------------------------| | `@crosscode/auth-client` | `packages/auth-client` | 1.1.0 (released with Events 3.0.0 and Accounts 1.1.0) | | `@crosscode/seo` | `packages/seo` | 1.0.0 (released with Events 2.4.0) | -| `@crosscode/ui` | `packages/ui` | 0.1.0 | -| Website | `apps/website` | 0.0.0 (phase 5, being planned) | +| `@crosscode/ui` | `packages/ui` | 0.2.0 (fonts, `ChurchFooter`; released with Accounts 1.7.0) | +| Website | `apps/website` | 0.0.0 (phase 5, being built: contracts 1.17.0 released) | | App | `apps/app` | 0.0.0 (not started, phase 6) | These shared packages ship inside the apps that use them, from the same checkout, so they don't @@ -37,6 +37,12 @@ need their own tags until something outside this repo depends on them. ## What each latest release was for +- **Contracts 1.17.0 + Accounts 1.7.0 (2026-11-24):** the first piece of the Church Website. Contracts: + the 8 font pairings, corner styles and template ids (`./style`), an optional `branding.style` on the + church profile, `church.update` (the Website changes shared profile facts), an optional `website` + part of the church export and an optional `limits.storageBytes` on the licence. Accounts: Brand + style under Church profile, the church's fonts, corners and shared footer on its pages, and + `church.update`. No migrations. The Hub vendors contracts 1.17.0 with 2.21.0. **Not deployed yet.** - **Hub 2.20.0 (2026-11-23):** the port list says what each port is for (church, product, web or API, linked to the install); a church server's hand-written frpc tunnels are listed as taken on each frp config read. frps's allow_ports is checked against the port list (the Hub's range plus listed ports diff --git a/package-lock.json b/package-lock.json index 7ae8a1a..93a029a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -109,7 +109,7 @@ }, "apps/agent": { "name": "@crosscode/agent", - "version": "1.4.0", + "version": "1.5.0", "license": "UNLICENSED", "dependencies": { "@crosscode/contracts": "*", @@ -952,6 +952,23 @@ "keyv": "^5.6.0" } }, + "node_modules/@capsizecss/core": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/@capsizecss/core/-/core-4.1.3.tgz", + "integrity": "sha512-d2sTTBwKuVioYxpwpU4URMp8VkFK+GI1VNGNawQcF8HBMHzCDa1FLcbeXJSzb5AJik7ZGv3aFVCTs7IS9MhvHg==", + "dev": true, + "license": "MIT", + "dependencies": { + "csstype": "^3.1.1" + } + }, + "node_modules/@capsizecss/metrics": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@capsizecss/metrics/-/metrics-4.5.0.tgz", + "integrity": "sha512-BD0pz1JksZXEX9RLNtUCYYD72sQIVzOPIjaCAXPSz18lWdtPGmNbj6AVL2Q3n0trOLPOjZ9fnvtuAmSPv7yO1g==", + "dev": true, + "license": "MIT" + }, "node_modules/@cj-tech-master/excelts": { "version": "10.2.0", "resolved": "https://registry.npmjs.org/@cj-tech-master/excelts/-/excelts-10.2.0.tgz", @@ -1805,6 +1822,105 @@ "integrity": "sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww==", "license": "MIT" }, + "node_modules/@fontsource-variable/dm-sans": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@fontsource-variable/dm-sans/-/dm-sans-5.3.0.tgz", + "integrity": "sha512-BpUG5bqePiDFMBM4ZtLSlPdAIOM990uB1dlXzIf4aw21yQR7BmykedLXXXMqGWsR18aMLOsbWccwJNh3ztTQaA==", + "license": "OFL-1.1", + "funding": { + "url": "https://github.com/sponsors/ayuhito" + } + }, + "node_modules/@fontsource-variable/eb-garamond": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@fontsource-variable/eb-garamond/-/eb-garamond-5.3.0.tgz", + "integrity": "sha512-656OJsA9Vv24yhqRZFEzXnzS2AYgKdEILLgHJYLzzXndgcWFKfSXFqzbRI5/6Yk1Yt7UfWrUeppE5nRQPQMwlQ==", + "license": "OFL-1.1", + "funding": { + "url": "https://github.com/sponsors/ayuhito" + } + }, + "node_modules/@fontsource-variable/fraunces": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@fontsource-variable/fraunces/-/fraunces-5.3.0.tgz", + "integrity": "sha512-9BYGySn4AHEJdgp9Z28tQ3X+laJMEOITXkQarZXeloWQZDq5oOvXJ3kDA8c7MGIfpogIaZfjrQBqmda8POOCKA==", + "license": "OFL-1.1", + "funding": { + "url": "https://github.com/sponsors/ayuhito" + } + }, + "node_modules/@fontsource-variable/inter": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@fontsource-variable/inter/-/inter-5.3.0.tgz", + "integrity": "sha512-OupL48va4JNofb97w6NYeF9S7W/kHNKM0Er8Dem5nqi4jeOLrVJDoE8tZEpnMJmtkvNbB1EIPPwHcdkF6b1oUA==", + "license": "OFL-1.1", + "funding": { + "url": "https://github.com/sponsors/ayuhito" + } + }, + "node_modules/@fontsource-variable/lora": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@fontsource-variable/lora/-/lora-5.3.0.tgz", + "integrity": "sha512-2ph8KiZ8Bn141hWuC3ErtpJ+Ui8p2MJQn8TJNRSRmLmnCIOCtHfiBM9R7WLRPeUG/q6hXyHOxWQ8DvRSX+ixvQ==", + "license": "OFL-1.1", + "funding": { + "url": "https://github.com/sponsors/ayuhito" + } + }, + "node_modules/@fontsource-variable/nunito": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@fontsource-variable/nunito/-/nunito-5.3.0.tgz", + "integrity": "sha512-tw0ch7evIDSwoeUy+0XzocYHfbRWLeCRPJy22KgbrLjDLAbNw/fErBiil10Ssrs3Sjr55zaZrr36a975j8cBkQ==", + "license": "OFL-1.1", + "funding": { + "url": "https://github.com/sponsors/ayuhito" + } + }, + "node_modules/@fontsource-variable/nunito-sans": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@fontsource-variable/nunito-sans/-/nunito-sans-5.3.0.tgz", + "integrity": "sha512-Vk1PSfckNDwgw2yGcsvJP3o/0zEW8Rp6KzbD8Ql/6iRHQshnhhAjt+cSIfAUyp5vQuSlleGHFW2LfYaaex0diw==", + "license": "OFL-1.1", + "funding": { + "url": "https://github.com/sponsors/ayuhito" + } + }, + "node_modules/@fontsource-variable/oswald": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@fontsource-variable/oswald/-/oswald-5.3.0.tgz", + "integrity": "sha512-sSZzcTeaQGNyZbTVlS4tNNHElK38UktFLqKd6NQDLFCBV27320rQC3kXSZVytYm1PPjKmPxqVaGwqj7LEKUWQw==", + "license": "OFL-1.1", + "funding": { + "url": "https://github.com/sponsors/ayuhito" + } + }, + "node_modules/@fontsource-variable/outfit": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@fontsource-variable/outfit/-/outfit-5.3.0.tgz", + "integrity": "sha512-fPb5XnYK0k7SbR++HEmm4+ZqDszmLKQ+sPRUr8oQ/KNC0vy6r6hazJFe8iYozv4cqlHbvJ/JECkJWrfDodUMVQ==", + "license": "OFL-1.1", + "funding": { + "url": "https://github.com/sponsors/ayuhito" + } + }, + "node_modules/@fontsource-variable/playfair-display": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@fontsource-variable/playfair-display/-/playfair-display-5.3.0.tgz", + "integrity": "sha512-IHdzTvE8eGIXHteZql7KXoqdc3Gfm+Zs1u4XlSC3MeplkwviT3sx/P6gI0tLwg/xIYLF4ZJYveZ5V+bl9cnDwA==", + "license": "OFL-1.1", + "funding": { + "url": "https://github.com/sponsors/ayuhito" + } + }, + "node_modules/@fontsource-variable/source-sans-3": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/@fontsource-variable/source-sans-3/-/source-sans-3-5.3.1.tgz", + "integrity": "sha512-u0p5Z/PM2e1uxYOMiodLM6NVzxHwULcB6Oi7QSr2WU/sdoLBFP/BeOZ3YYHeJ6rHsjPZA1nZweZVaV7sf2MAyQ==", + "license": "OFL-1.1", + "funding": { + "url": "https://github.com/sponsors/ayuhito" + } + }, "node_modules/@humanfs/core": { "version": "0.19.2", "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz", @@ -21276,7 +21392,7 @@ }, "packages/contracts": { "name": "@crosscode/contracts", - "version": "1.15.0", + "version": "1.17.0", "license": "UNLICENSED", "dependencies": { "zod": "^4.6.7" @@ -21320,7 +21436,25 @@ }, "packages/ui": { "name": "@crosscode/ui", - "version": "0.1.0", + "version": "0.2.0", + "dependencies": { + "@fontsource-variable/dm-sans": "5.3.0", + "@fontsource-variable/eb-garamond": "5.3.0", + "@fontsource-variable/fraunces": "5.3.0", + "@fontsource-variable/inter": "5.3.0", + "@fontsource-variable/lora": "5.3.0", + "@fontsource-variable/nunito": "5.3.0", + "@fontsource-variable/nunito-sans": "5.3.0", + "@fontsource-variable/oswald": "5.3.0", + "@fontsource-variable/outfit": "5.3.0", + "@fontsource-variable/playfair-display": "5.3.0", + "@fontsource-variable/source-sans-3": "5.3.1" + }, + "devDependencies": { + "@capsizecss/core": "4.1.3", + "@capsizecss/metrics": "4.5.0", + "@crosscode/contracts": "*" + }, "peerDependencies": { "react": ">=19" } diff --git a/packages/contracts/package.json b/packages/contracts/package.json index ee44463..5edd321 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -1,6 +1,6 @@ { "name": "@crosscode/contracts", - "version": "1.16.0", + "version": "1.17.0", "description": "The shared JSON formats used by every Cross Code product: zod schemas, JSON Schema, TypeScript types and sample payloads", "license": "UNLICENSED", "type": "commonjs", diff --git a/packages/contracts/samples/church-export-website.json b/packages/contracts/samples/church-export-website.json new file mode 100644 index 0000000..2e37880 --- /dev/null +++ b/packages/contracts/samples/church-export-website.json @@ -0,0 +1,171 @@ +{ + "schema": "crosscode.church-export/1", + "exportedAt": "2026-12-10T12:00:00.000Z", + "product": "website", + "productVersion": "1.0.0", + "church": { + "name": "Grace Demo Church", + "timezone": "Africa/Johannesburg" + }, + "people": [ + { + "ref": "p1", + "name": "Thandi Example", + "email": "thandi@example.org", + "phone": null, + "role": "editor", + "createdAt": "2026-12-01T08:00:00.000Z", + "consent": { + "email": null, + "whatsapp": null, + "privacyNoticeAcceptedAt": null + } + } + ], + "events": [], + "registrations": [], + "payments": [], + "checkIns": [], + "rosters": [], + "settings": { + "coming-soon.line": "Our new website is on its way" + }, + "files": [ + { + "path": "uploads/media/hero-sunday.jpg", + "bytes": 482113 + }, + { + "path": "uploads/media/carols.jpg", + "bytes": 203877 + } + ], + "website": { + "template": "community", + "firstPublishedAt": "2026-12-05T09:00:00.000Z", + "style": { + "sectionColour": "tinted", + "spacing": "airy", + "buttons": "pill", + "imageTreatment": "natural", + "header": "solid" + }, + "pages": [ + { + "ref": "g1", + "title": "Home", + "path": "/", + "kind": "home", + "inNavigation": true, + "seo": { + "title": null, + "description": "A family church in Meyerton. Join us on Sundays at 09:00." + }, + "sections": [ + { + "type": "hero", + "variant": "collage", + "hidden": false, + "content": { + "headline": "You belong here", + "images": [ + "uploads/media/hero-sunday.jpg" + ], + "button": { + "label": "Plan your visit", + "href": "/visit" + } + } + }, + { + "type": "service-times", + "variant": "panel", + "hidden": false, + "content": {} + }, + { + "type": "latest-message", + "variant": "card", + "hidden": true, + "content": {} + } + ] + }, + { + "ref": "g2", + "title": "Youth camp", + "path": "/youth-camp", + "kind": "custom", + "inNavigation": false, + "seo": { + "title": "Youth camp 2027", + "description": null + }, + "sections": [ + { + "type": "text", + "variant": "text", + "hidden": false, + "content": { + "heading": "Youth camp", + "body": "Three days away for grades 8 to 12." + } + } + ] + } + ], + "messages": [ + { + "ref": "m1", + "title": "Hope that holds", + "date": "2026-12-07T07:00:00.000Z", + "speaker": "Pastor Sam Example", + "series": "Advent", + "passage": "Romans 15:13", + "notes": null, + "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ", + "source": "youtube-feed", + "hidden": false + } + ], + "events": [ + { + "ref": "w1", + "title": "Carols by candlelight", + "description": "Bring a blanket.", + "startsAt": "2026-12-20T17:00:00.000Z", + "endsAt": "2026-12-20T19:00:00.000Z", + "location": "The church lawn", + "link": null, + "image": "uploads/media/carols.jpg", + "published": true + } + ], + "versions": [ + { + "number": 1, + "publishedAt": "2026-12-05T09:00:00.000Z", + "by": "Thandi Example", + "note": "First version" + }, + { + "number": 2, + "publishedAt": "2026-12-08T15:30:00.000Z", + "by": "Thandi Example", + "note": null + } + ], + "media": [ + { + "path": "uploads/media/hero-sunday.jpg", + "alt": "The congregation singing on a Sunday morning", + "caption": null + }, + { + "path": "uploads/media/carols.jpg", + "alt": "Candles on the church lawn", + "caption": "Carols 2025" + } + ] + } +} diff --git a/packages/contracts/samples/church-update-reply.json b/packages/contracts/samples/church-update-reply.json new file mode 100644 index 0000000..f6aa595 --- /dev/null +++ b/packages/contracts/samples/church-update-reply.json @@ -0,0 +1,81 @@ +{ + "schema": "crosscode.identity-request/1", + "church": { + "schema": "crosscode.church/1", + "customerId": "c7a1e2d3-4b5c-4d6e-8f70-81a2b3c4d5e6", + "updatedAt": "2026-12-02T10:00:00.000Z", + "name": "Hope Family Church", + "shortName": "Hope Family", + "timezone": "Africa/Johannesburg", + "locale": "en-ZA", + "branding": { + "logoUrl": "https://www.hopefamily.co.za/uploads/logo.png", + "iconUrl": "https://www.hopefamily.co.za/uploads/icon-512.png", + "colours": { + "primary": "#1f4e79", + "accent": "#f2a900" + }, + "style": { + "fontPairing": "warm", + "corners": "round" + } + }, + "campuses": [ + { + "slug": "meyerton", + "name": "Meyerton", + "address": { + "line1": "12 Church Street", + "line2": null, + "suburb": "Meyerton Central", + "city": "Meyerton", + "province": "Gauteng", + "postalCode": "1961", + "country": "ZA", + "geo": { + "lat": -26.5559, + "lng": 28.0141 + } + } + } + ], + "serviceTimes": [ + { + "day": "sunday", + "time": "09:00", + "label": "Morning service", + "campus": "meyerton", + "note": "Kids church during the service" + }, + { + "day": "wednesday", + "time": "18:30", + "label": "Prayer evening", + "campus": "meyerton", + "note": null + } + ], + "contact": { + "email": "office@hopefamily.co.za", + "phone": "+27161234567", + "whatsapp": "+27821234567", + "address": null + }, + "social": [ + { + "network": "facebook", + "url": "https://www.facebook.com/hopefamilychurch" + }, + { + "network": "youtube", + "url": "https://www.youtube.com/@hopefamilychurch" + } + ], + "links": { + "website": "https://www.hopefamily.co.za", + "events": "https://events.hopefamily.co.za", + "app": null, + "accounts": "https://accounts.hopefamily.co.za" + } + } +} diff --git a/packages/contracts/samples/church-update.json b/packages/contracts/samples/church-update.json new file mode 100644 index 0000000..c101462 --- /dev/null +++ b/packages/contracts/samples/church-update.json @@ -0,0 +1,31 @@ +{ + "schema": "crosscode.identity-request/1", + "actor": "6b2c3d4e-5f6a-4b7c-9d8e-0f1a2b3c4d5e", + "requestId": "1f2e3d4c-5b6a-4978-8695-a4b3c2d1e0f9", + "type": "church.update", + "ifUpdatedAt": "2026-11-01T09:00:00.000Z", + "church": { + "branding": { + "style": { + "fontPairing": "warm", + "corners": "round" + } + }, + "serviceTimes": [ + { + "day": "sunday", + "time": "09:00", + "label": "Morning service", + "campus": "meyerton", + "note": "Kids church during the service" + }, + { + "day": "wednesday", + "time": "18:30", + "label": "Prayer evening", + "campus": "meyerton", + "note": null + } + ] + } +} diff --git a/packages/contracts/samples/church.json b/packages/contracts/samples/church.json index 9fbdbad..7515309 100644 --- a/packages/contracts/samples/church.json +++ b/packages/contracts/samples/church.json @@ -9,7 +9,8 @@ "branding": { "logoUrl": "https://www.hopefamily.co.za/uploads/logo.png", "iconUrl": "https://www.hopefamily.co.za/uploads/icon-512.png", - "colours": { "primary": "#1f4e79", "accent": "#f2a900" } + "colours": { "primary": "#1f4e79", "accent": "#f2a900" }, + "style": { "fontPairing": "warm", "corners": "soft" } }, "campuses": [ { diff --git a/packages/contracts/samples/hub-licence-payload-website.json b/packages/contracts/samples/hub-licence-payload-website.json new file mode 100644 index 0000000..86d5268 --- /dev/null +++ b/packages/contracts/samples/hub-licence-payload-website.json @@ -0,0 +1,18 @@ +{ + "v": 1, + "licenceId": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e", + "installId": "6c7d8e9f-0a1b-4c2d-9e3f-4a5b6c7d8e9f", + "customerId": "c7a1e2d3-4b5c-4d6e-8f70-81a2b3c4d5e6", + "product": "website", + "customer": "Hope Family Church", + "plan": "website", + "status": "active", + "licenceExpiresAt": "2027-10-31T21:59:59.000Z", + "graceDays": 14, + "issuedAt": "2026-11-03T10:15:00.000Z", + "validUntil": "2026-12-03T10:15:00.000Z", + "limits": { + "aiMonthlyCapCents": 0, + "storageBytes": 10737418240 + } +} diff --git a/packages/contracts/schemas/church-export.json b/packages/contracts/schemas/church-export.json index b2743d5..9543919 100644 --- a/packages/contracts/schemas/church-export.json +++ b/packages/contracts/schemas/church-export.json @@ -656,6 +656,446 @@ "bytes" ] } + }, + "website": { + "type": "object", + "properties": { + "template": { + "type": "string", + "enum": [ + "heritage", + "bold", + "community", + "clean" + ] + }, + "firstPublishedAt": { + "anyOf": [ + { + "type": "string", + "format": "date-time", + "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$" + }, + { + "type": "null" + } + ] + }, + "style": { + "type": "object", + "propertyNames": { + "type": "string", + "maxLength": 100 + }, + "additionalProperties": { + "type": "string", + "maxLength": 200 + } + }, + "pages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "ref": { + "type": "string", + "pattern": "^g[0-9]+$" + }, + "title": { + "type": "string", + "maxLength": 300 + }, + "path": { + "type": "string", + "maxLength": 300, + "pattern": "^\\/[a-z0-9/-]*$" + }, + "kind": { + "type": "string", + "maxLength": 40 + }, + "inNavigation": { + "type": "boolean" + }, + "seo": { + "type": "object", + "properties": { + "title": { + "anyOf": [ + { + "type": "string", + "maxLength": 300 + }, + { + "type": "null" + } + ] + }, + "description": { + "anyOf": [ + { + "type": "string", + "maxLength": 500 + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "title", + "description" + ] + }, + "sections": { + "type": "array", + "items": { + "type": "object", + "properties": { + "type": { + "type": "string", + "maxLength": 60 + }, + "variant": { + "type": "string", + "maxLength": 60 + }, + "hidden": { + "type": "boolean" + }, + "content": { + "type": "object", + "propertyNames": { + "type": "string", + "maxLength": 100 + }, + "additionalProperties": { + "$ref": "#/$defs/__schema0" + } + } + }, + "required": [ + "type", + "variant", + "hidden", + "content" + ] + } + } + }, + "required": [ + "ref", + "title", + "path", + "kind", + "inNavigation", + "seo", + "sections" + ] + } + }, + "messages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "ref": { + "type": "string", + "pattern": "^m[0-9]+$" + }, + "title": { + "type": "string", + "maxLength": 500 + }, + "date": { + "anyOf": [ + { + "type": "string", + "format": "date-time", + "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$" + }, + { + "type": "null" + } + ] + }, + "speaker": { + "anyOf": [ + { + "type": "string", + "maxLength": 300 + }, + { + "type": "null" + } + ] + }, + "series": { + "anyOf": [ + { + "type": "string", + "maxLength": 300 + }, + { + "type": "null" + } + ] + }, + "passage": { + "anyOf": [ + { + "type": "string", + "maxLength": 300 + }, + { + "type": "null" + } + ] + }, + "notes": { + "anyOf": [ + { + "type": "string", + "maxLength": 20000 + }, + { + "type": "null" + } + ] + }, + "url": { + "type": "string", + "maxLength": 2048, + "format": "uri" + }, + "source": { + "type": "string", + "enum": [ + "youtube-feed", + "manual" + ] + }, + "hidden": { + "type": "boolean" + } + }, + "required": [ + "ref", + "title", + "date", + "speaker", + "series", + "passage", + "notes", + "url", + "source", + "hidden" + ] + } + }, + "events": { + "type": "array", + "items": { + "type": "object", + "properties": { + "ref": { + "type": "string", + "pattern": "^w[0-9]+$" + }, + "title": { + "type": "string", + "maxLength": 500 + }, + "description": { + "anyOf": [ + { + "type": "string", + "maxLength": 20000 + }, + { + "type": "null" + } + ] + }, + "startsAt": { + "anyOf": [ + { + "type": "string", + "format": "date-time", + "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$" + }, + { + "type": "null" + } + ] + }, + "endsAt": { + "anyOf": [ + { + "type": "string", + "format": "date-time", + "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$" + }, + { + "type": "null" + } + ] + }, + "location": { + "anyOf": [ + { + "type": "string", + "maxLength": 500 + }, + { + "type": "null" + } + ] + }, + "link": { + "anyOf": [ + { + "type": "string", + "maxLength": 2048, + "format": "uri" + }, + { + "type": "null" + } + ] + }, + "image": { + "anyOf": [ + { + "type": "string", + "pattern": "^uploads\\/[A-Za-z0-9._/-]+$" + }, + { + "type": "null" + } + ] + }, + "published": { + "type": "boolean" + } + }, + "required": [ + "ref", + "title", + "description", + "startsAt", + "endsAt", + "location", + "link", + "image", + "published" + ] + } + }, + "versions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "number": { + "type": "integer", + "exclusiveMinimum": 0, + "maximum": 9007199254740991 + }, + "publishedAt": { + "anyOf": [ + { + "type": "string", + "format": "date-time", + "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$" + }, + { + "type": "null" + } + ] + }, + "by": { + "anyOf": [ + { + "type": "string", + "maxLength": 300 + }, + { + "type": "null" + } + ] + }, + "note": { + "anyOf": [ + { + "type": "string", + "maxLength": 1000 + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "number", + "publishedAt", + "by", + "note" + ] + } + }, + "media": { + "type": "array", + "items": { + "type": "object", + "properties": { + "path": { + "type": "string", + "pattern": "^uploads\\/[A-Za-z0-9._/-]+$" + }, + "alt": { + "anyOf": [ + { + "type": "string", + "maxLength": 500 + }, + { + "type": "null" + } + ] + }, + "caption": { + "anyOf": [ + { + "type": "string", + "maxLength": 1000 + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "path", + "alt", + "caption" + ] + } + } + }, + "required": [ + "template", + "firstPublishedAt", + "style", + "pages", + "messages", + "events", + "versions", + "media" + ] } }, "required": [ @@ -672,5 +1112,38 @@ "rosters", "settings", "files" - ] + ], + "$defs": { + "__schema0": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "number" + }, + { + "type": "boolean" + }, + { + "type": "null" + }, + { + "type": "array", + "items": { + "$ref": "#/$defs/__schema0" + } + }, + { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "$ref": "#/$defs/__schema0" + } + } + ] + } + } } diff --git a/packages/contracts/schemas/church-update-reply.json b/packages/contracts/schemas/church-update-reply.json new file mode 100644 index 0000000..43925bb --- /dev/null +++ b/packages/contracts/schemas/church-update-reply.json @@ -0,0 +1,608 @@ +{ + "$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/church-update-reply.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "schema": { + "type": "string", + "const": "crosscode.identity-request/1" + }, + "church": { + "type": "object", + "properties": { + "schema": { + "type": "string", + "const": "crosscode.church/1" + }, + "customerId": { + "type": "string", + "format": "uuid", + "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$" + }, + "updatedAt": { + "type": "string", + "format": "date-time", + "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$" + }, + "name": { + "type": "string", + "minLength": 1, + "maxLength": 200 + }, + "shortName": { + "anyOf": [ + { + "type": "string", + "maxLength": 30 + }, + { + "type": "null" + } + ] + }, + "timezone": { + "type": "string", + "pattern": "^[A-Za-z_]+(\\/[A-Za-z0-9_+-]+){0,2}$|^UTC$" + }, + "locale": { + "type": "string", + "pattern": "^[a-z]{2,3}(-[A-Z]{2})?$" + }, + "branding": { + "type": "object", + "properties": { + "logoUrl": { + "anyOf": [ + { + "type": "string", + "maxLength": 2048, + "format": "uri" + }, + { + "type": "null" + } + ] + }, + "iconUrl": { + "anyOf": [ + { + "type": "string", + "maxLength": 2048, + "format": "uri" + }, + { + "type": "null" + } + ] + }, + "colours": { + "type": "object", + "properties": { + "primary": { + "type": "string", + "pattern": "^#[0-9a-fA-F]{6}$" + }, + "accent": { + "anyOf": [ + { + "type": "string", + "pattern": "^#[0-9a-fA-F]{6}$" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "primary", + "accent" + ] + }, + "style": { + "type": "object", + "properties": { + "fontPairing": { + "default": null, + "anyOf": [ + { + "type": "string", + "enum": [ + "classic", + "scholarly", + "editorial", + "impact", + "contemporary", + "friendly", + "warm", + "modern" + ] + }, + { + "type": "null" + } + ] + }, + "corners": { + "default": null, + "anyOf": [ + { + "type": "string", + "enum": [ + "sharp", + "soft", + "round" + ] + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "fontPairing", + "corners" + ] + } + }, + "required": [ + "logoUrl", + "iconUrl", + "colours" + ] + }, + "campuses": { + "maxItems": 50, + "type": "array", + "items": { + "type": "object", + "properties": { + "slug": { + "type": "string", + "maxLength": 100, + "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$" + }, + "name": { + "type": "string", + "minLength": 1, + "maxLength": 200 + }, + "address": { + "anyOf": [ + { + "type": "object", + "properties": { + "line1": { + "type": "string", + "minLength": 1, + "maxLength": 200 + }, + "line2": { + "anyOf": [ + { + "type": "string", + "maxLength": 200 + }, + { + "type": "null" + } + ] + }, + "suburb": { + "anyOf": [ + { + "type": "string", + "maxLength": 100 + }, + { + "type": "null" + } + ] + }, + "city": { + "type": "string", + "minLength": 1, + "maxLength": 100 + }, + "province": { + "anyOf": [ + { + "type": "string", + "maxLength": 100 + }, + { + "type": "null" + } + ] + }, + "postalCode": { + "anyOf": [ + { + "type": "string", + "maxLength": 20 + }, + { + "type": "null" + } + ] + }, + "country": { + "type": "string", + "pattern": "^[A-Z]{2}$" + }, + "geo": { + "anyOf": [ + { + "type": "object", + "properties": { + "lat": { + "type": "number", + "minimum": -90, + "maximum": 90 + }, + "lng": { + "type": "number", + "minimum": -180, + "maximum": 180 + } + }, + "required": [ + "lat", + "lng" + ] + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "line1", + "line2", + "suburb", + "city", + "province", + "postalCode", + "country", + "geo" + ] + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "slug", + "name", + "address" + ] + } + }, + "serviceTimes": { + "maxItems": 100, + "type": "array", + "items": { + "type": "object", + "properties": { + "day": { + "type": "string", + "enum": [ + "monday", + "tuesday", + "wednesday", + "thursday", + "friday", + "saturday", + "sunday" + ] + }, + "time": { + "type": "string", + "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$" + }, + "label": { + "anyOf": [ + { + "type": "string", + "maxLength": 100 + }, + { + "type": "null" + } + ] + }, + "campus": { + "anyOf": [ + { + "type": "string", + "maxLength": 100, + "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$" + }, + { + "type": "null" + } + ] + }, + "note": { + "anyOf": [ + { + "type": "string", + "maxLength": 300 + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "day", + "time", + "label", + "campus", + "note" + ] + } + }, + "contact": { + "type": "object", + "properties": { + "email": { + "anyOf": [ + { + "type": "string", + "maxLength": 254, + "format": "email", + "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$" + }, + { + "type": "null" + } + ] + }, + "phone": { + "anyOf": [ + { + "type": "string", + "pattern": "^\\+[1-9]\\d{6,14}$" + }, + { + "type": "null" + } + ] + }, + "whatsapp": { + "anyOf": [ + { + "type": "string", + "pattern": "^\\+[1-9]\\d{6,14}$" + }, + { + "type": "null" + } + ] + }, + "address": { + "anyOf": [ + { + "type": "object", + "properties": { + "line1": { + "type": "string", + "minLength": 1, + "maxLength": 200 + }, + "line2": { + "anyOf": [ + { + "type": "string", + "maxLength": 200 + }, + { + "type": "null" + } + ] + }, + "suburb": { + "anyOf": [ + { + "type": "string", + "maxLength": 100 + }, + { + "type": "null" + } + ] + }, + "city": { + "type": "string", + "minLength": 1, + "maxLength": 100 + }, + "province": { + "anyOf": [ + { + "type": "string", + "maxLength": 100 + }, + { + "type": "null" + } + ] + }, + "postalCode": { + "anyOf": [ + { + "type": "string", + "maxLength": 20 + }, + { + "type": "null" + } + ] + }, + "country": { + "type": "string", + "pattern": "^[A-Z]{2}$" + }, + "geo": { + "anyOf": [ + { + "type": "object", + "properties": { + "lat": { + "type": "number", + "minimum": -90, + "maximum": 90 + }, + "lng": { + "type": "number", + "minimum": -180, + "maximum": 180 + } + }, + "required": [ + "lat", + "lng" + ] + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "line1", + "line2", + "suburb", + "city", + "province", + "postalCode", + "country", + "geo" + ] + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "email", + "phone", + "whatsapp", + "address" + ] + }, + "social": { + "maxItems": 20, + "type": "array", + "items": { + "type": "object", + "properties": { + "network": { + "type": "string", + "enum": [ + "facebook", + "instagram", + "youtube", + "tiktok", + "x", + "spotify", + "whatsapp-channel", + "other" + ] + }, + "url": { + "type": "string", + "maxLength": 2048, + "format": "uri" + } + }, + "required": [ + "network", + "url" + ] + } + }, + "links": { + "type": "object", + "properties": { + "website": { + "anyOf": [ + { + "type": "string", + "maxLength": 2048, + "format": "uri" + }, + { + "type": "null" + } + ] + }, + "events": { + "anyOf": [ + { + "type": "string", + "maxLength": 2048, + "format": "uri" + }, + { + "type": "null" + } + ] + }, + "app": { + "anyOf": [ + { + "type": "string", + "maxLength": 2048, + "format": "uri" + }, + { + "type": "null" + } + ] + }, + "accounts": { + "type": "string", + "maxLength": 2048, + "format": "uri" + } + }, + "required": [ + "website", + "events", + "app", + "accounts" + ] + } + }, + "required": [ + "schema", + "customerId", + "updatedAt", + "name", + "shortName", + "timezone", + "locale", + "branding", + "campuses", + "serviceTimes", + "contact", + "social", + "links" + ] + } + }, + "required": [ + "schema", + "church" + ] +} diff --git a/packages/contracts/schemas/church.json b/packages/contracts/schemas/church.json index 81f8b3b..2000fef 100644 --- a/packages/contracts/schemas/church.json +++ b/packages/contracts/schemas/church.json @@ -91,6 +91,52 @@ "primary", "accent" ] + }, + "style": { + "type": "object", + "properties": { + "fontPairing": { + "default": null, + "anyOf": [ + { + "type": "string", + "enum": [ + "classic", + "scholarly", + "editorial", + "impact", + "contemporary", + "friendly", + "warm", + "modern" + ] + }, + { + "type": "null" + } + ] + }, + "corners": { + "default": null, + "anyOf": [ + { + "type": "string", + "enum": [ + "sharp", + "soft", + "round" + ] + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "fontPairing", + "corners" + ] } }, "required": [ diff --git a/packages/contracts/schemas/hub-licence-payload.json b/packages/contracts/schemas/hub-licence-payload.json index 17c5a84..9791682 100644 --- a/packages/contracts/schemas/hub-licence-payload.json +++ b/packages/contracts/schemas/hub-licence-payload.json @@ -78,6 +78,11 @@ "aiMonthlyCapCents": { "type": "number", "minimum": 0 + }, + "storageBytes": { + "type": "integer", + "minimum": 0, + "maximum": 9007199254740991 } }, "required": [ diff --git a/packages/contracts/schemas/identity-request.json b/packages/contracts/schemas/identity-request.json index fd22c8f..d6e6c73 100644 --- a/packages/contracts/schemas/identity-request.json +++ b/packages/contracts/schemas/identity-request.json @@ -1308,6 +1308,548 @@ "church", "overwrite" ] + }, + { + "type": "object", + "properties": { + "schema": { + "type": "string", + "const": "crosscode.identity-request/1" + }, + "requestId": { + "type": "string", + "format": "uuid", + "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$" + }, + "actor": { + "type": "string", + "format": "uuid", + "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$" + }, + "type": { + "type": "string", + "const": "church.update" + }, + "ifUpdatedAt": { + "type": "string", + "format": "date-time", + "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$" + }, + "church": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1, + "maxLength": 200 + }, + "shortName": { + "anyOf": [ + { + "type": "string", + "maxLength": 30 + }, + { + "type": "null" + } + ] + }, + "timezone": { + "type": "string", + "pattern": "^[A-Za-z_]+(\\/[A-Za-z0-9_+-]+){0,2}$|^UTC$" + }, + "locale": { + "type": "string", + "pattern": "^[a-z]{2,3}(-[A-Z]{2})?$" + }, + "branding": { + "type": "object", + "properties": { + "logoUrl": { + "anyOf": [ + { + "type": "string", + "maxLength": 2048, + "format": "uri" + }, + { + "type": "null" + } + ] + }, + "iconUrl": { + "anyOf": [ + { + "type": "string", + "maxLength": 2048, + "format": "uri" + }, + { + "type": "null" + } + ] + }, + "colours": { + "type": "object", + "properties": { + "primary": { + "type": "string", + "pattern": "^#[0-9a-fA-F]{6}$" + }, + "accent": { + "anyOf": [ + { + "type": "string", + "pattern": "^#[0-9a-fA-F]{6}$" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "primary", + "accent" + ] + }, + "style": { + "type": "object", + "properties": { + "fontPairing": { + "default": null, + "anyOf": [ + { + "type": "string", + "enum": [ + "classic", + "scholarly", + "editorial", + "impact", + "contemporary", + "friendly", + "warm", + "modern" + ] + }, + { + "type": "null" + } + ] + }, + "corners": { + "default": null, + "anyOf": [ + { + "type": "string", + "enum": [ + "sharp", + "soft", + "round" + ] + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "fontPairing", + "corners" + ] + } + } + }, + "campuses": { + "maxItems": 50, + "type": "array", + "items": { + "type": "object", + "properties": { + "slug": { + "type": "string", + "maxLength": 100, + "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$" + }, + "name": { + "type": "string", + "minLength": 1, + "maxLength": 200 + }, + "address": { + "anyOf": [ + { + "type": "object", + "properties": { + "line1": { + "type": "string", + "minLength": 1, + "maxLength": 200 + }, + "line2": { + "anyOf": [ + { + "type": "string", + "maxLength": 200 + }, + { + "type": "null" + } + ] + }, + "suburb": { + "anyOf": [ + { + "type": "string", + "maxLength": 100 + }, + { + "type": "null" + } + ] + }, + "city": { + "type": "string", + "minLength": 1, + "maxLength": 100 + }, + "province": { + "anyOf": [ + { + "type": "string", + "maxLength": 100 + }, + { + "type": "null" + } + ] + }, + "postalCode": { + "anyOf": [ + { + "type": "string", + "maxLength": 20 + }, + { + "type": "null" + } + ] + }, + "country": { + "type": "string", + "pattern": "^[A-Z]{2}$" + }, + "geo": { + "anyOf": [ + { + "type": "object", + "properties": { + "lat": { + "type": "number", + "minimum": -90, + "maximum": 90 + }, + "lng": { + "type": "number", + "minimum": -180, + "maximum": 180 + } + }, + "required": [ + "lat", + "lng" + ] + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "line1", + "line2", + "suburb", + "city", + "province", + "postalCode", + "country", + "geo" + ] + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "slug", + "name", + "address" + ] + } + }, + "serviceTimes": { + "maxItems": 100, + "type": "array", + "items": { + "type": "object", + "properties": { + "day": { + "type": "string", + "enum": [ + "monday", + "tuesday", + "wednesday", + "thursday", + "friday", + "saturday", + "sunday" + ] + }, + "time": { + "type": "string", + "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$" + }, + "label": { + "anyOf": [ + { + "type": "string", + "maxLength": 100 + }, + { + "type": "null" + } + ] + }, + "campus": { + "anyOf": [ + { + "type": "string", + "maxLength": 100, + "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$" + }, + { + "type": "null" + } + ] + }, + "note": { + "anyOf": [ + { + "type": "string", + "maxLength": 300 + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "day", + "time", + "label", + "campus", + "note" + ] + } + }, + "contact": { + "type": "object", + "properties": { + "email": { + "anyOf": [ + { + "type": "string", + "maxLength": 254, + "format": "email", + "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$" + }, + { + "type": "null" + } + ] + }, + "phone": { + "anyOf": [ + { + "type": "string", + "pattern": "^\\+[1-9]\\d{6,14}$" + }, + { + "type": "null" + } + ] + }, + "whatsapp": { + "anyOf": [ + { + "type": "string", + "pattern": "^\\+[1-9]\\d{6,14}$" + }, + { + "type": "null" + } + ] + }, + "address": { + "anyOf": [ + { + "type": "object", + "properties": { + "line1": { + "type": "string", + "minLength": 1, + "maxLength": 200 + }, + "line2": { + "anyOf": [ + { + "type": "string", + "maxLength": 200 + }, + { + "type": "null" + } + ] + }, + "suburb": { + "anyOf": [ + { + "type": "string", + "maxLength": 100 + }, + { + "type": "null" + } + ] + }, + "city": { + "type": "string", + "minLength": 1, + "maxLength": 100 + }, + "province": { + "anyOf": [ + { + "type": "string", + "maxLength": 100 + }, + { + "type": "null" + } + ] + }, + "postalCode": { + "anyOf": [ + { + "type": "string", + "maxLength": 20 + }, + { + "type": "null" + } + ] + }, + "country": { + "type": "string", + "pattern": "^[A-Z]{2}$" + }, + "geo": { + "anyOf": [ + { + "type": "object", + "properties": { + "lat": { + "type": "number", + "minimum": -90, + "maximum": 90 + }, + "lng": { + "type": "number", + "minimum": -180, + "maximum": 180 + } + }, + "required": [ + "lat", + "lng" + ] + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "line1", + "line2", + "suburb", + "city", + "province", + "postalCode", + "country", + "geo" + ] + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "email", + "phone", + "whatsapp", + "address" + ] + }, + "social": { + "maxItems": 20, + "type": "array", + "items": { + "type": "object", + "properties": { + "network": { + "type": "string", + "enum": [ + "facebook", + "instagram", + "youtube", + "tiktok", + "x", + "spotify", + "whatsapp-channel", + "other" + ] + }, + "url": { + "type": "string", + "maxLength": 2048, + "format": "uri" + } + }, + "required": [ + "network", + "url" + ] + } + } + } + } + }, + "required": [ + "schema", + "requestId", + "actor", + "type", + "church" + ] } ] } diff --git a/packages/contracts/scripts/json-schemas.cjs b/packages/contracts/scripts/json-schemas.cjs index e24d4fe..2ffa816 100644 --- a/packages/contracts/scripts/json-schemas.cjs +++ b/packages/contracts/scripts/json-schemas.cjs @@ -68,6 +68,7 @@ function contracts(c) { "messaging-test-reply": c.messagingTestReplySchema, "people-remove-demo-reply": c.peopleRemoveDemoReplySchema, "people-check-reply": c.peopleCheckReplySchema, + "church-update-reply": c.churchUpdateReplySchema, }; } diff --git a/packages/contracts/src/church-export.ts b/packages/contracts/src/church-export.ts index 99606cd..9f3fc3c 100644 --- a/packages/contracts/src/church-export.ts +++ b/packages/contracts/src/church-export.ts @@ -1,5 +1,6 @@ import { z } from "zod"; -import { dateTimeSchema, productSchema, timezoneSchema } from "./common"; +import { dateTimeSchema, productSchema, timezoneSchema, urlSchema } from "./common"; +import { websiteTemplateSchema } from "./style"; /** * crosscode.church-export/1: a church's data when it leaves (docs/AGENT-1.0-PLAN.md §9). Written @@ -14,6 +15,7 @@ const ref = (prefix: string) => z.string().regex(new RegExp(`^${prefix}[0-9]+$`) const text = (max = 20000) => z.string().max(max); const when = dateTimeSchema.nullable(); const cents = z.int(); +const uploadPath = z.string().regex(/^uploads\/[A-Za-z0-9._/-]+$/); export const exportPersonSchema = z.object({ ref: ref("p"), @@ -62,6 +64,76 @@ export const exportCheckInSchema = z.object({ eventRef: ref("e"), personRef: ref export const exportRosterSchema = z.object({ eventRef: ref("e").nullable(), role: text(200), personRef: ref("p").nullable(), startsAt: when, endsAt: when }); +// The Website's part (contracts 1.17.0, WEBSITE-1.0-PLAN §11): its content as the admins left it +// (the working copy, including changes not yet published), the publish history's notes, messages, +// simple events and the media library. Images are files in `uploads/`, listed in `files`. + +/** A section of a page: its type and layout, and what the admin filled in (text, links, image paths). */ +export const exportWebsiteSectionSchema = z.object({ + /** E.g. `hero`, `service-times`, `ministries`, `text`, `gallery`. */ + type: text(60), + /** E.g. `photo`, `cards`. */ + variant: text(60), + hidden: z.boolean(), + content: z.record(z.string().max(100), z.json()), +}); + +export const exportWebsitePageSchema = z.object({ + ref: ref("g"), + title: text(300), + /** The page's path on the site: `/` for home, `/about`, `/youth-camp`. */ + path: z.string().regex(/^\/[a-z0-9/-]*$/).max(300), + /** `home`, `about`, `visit`, `contact`, `give`, … or `custom` for a page the church added. */ + kind: text(40), + inNavigation: z.boolean(), + seo: z.object({ title: text(300).nullable(), description: text(500).nullable() }), + sections: z.array(exportWebsiteSectionSchema), +}); + +export const exportWebsiteMessageSchema = z.object({ + ref: ref("m"), + title: text(500), + date: when, + speaker: text(300).nullable(), + series: text(300).nullable(), + passage: text(300).nullable(), + notes: text().nullable(), + /** The YouTube or Spotify link (audio and video are never uploaded). */ + url: urlSchema, + /** `youtube-feed` when it came in from the channel or playlist by itself. */ + source: z.enum(["youtube-feed", "manual"]), + hidden: z.boolean(), +}); + +/** A simple event made in the Website (Cross Events' own events are in its export's `events`). */ +export const exportWebsiteEventSchema = z.object({ + ref: ref("w"), + title: text(500), + description: text().nullable(), + startsAt: when, + endsAt: when, + location: text(500).nullable(), + link: urlSchema.nullable(), + image: uploadPath.nullable(), + published: z.boolean(), +}); + +export const exportWebsiteSchema = z.object({ + template: websiteTemplateSchema, + /** Null when the site was never published (it showed Coming soon). */ + firstPublishedAt: when, + /** The Website-only style settings (section colour, spacing, buttons, image treatment, header). */ + style: z.record(z.string().max(100), z.string().max(200)), + pages: z.array(exportWebsitePageSchema), + messages: z.array(exportWebsiteMessageSchema), + events: z.array(exportWebsiteEventSchema), + /** Every publish, oldest first. The snapshots aren't exported: `pages` is the content. */ + versions: z.array(z.object({ number: z.int().positive(), publishedAt: when, by: text(300).nullable(), note: text(1000).nullable() })), + /** The media library: alt text and captions of the files in `uploads/`. */ + media: z.array(z.object({ path: uploadPath, alt: text(500).nullable(), caption: text(1000).nullable() })), +}); +export type ExportWebsite = z.infer; + export const churchExportSchema = z.object({ schema: z.literal("crosscode.church-export/1"), exportedAt: dateTimeSchema, @@ -77,7 +149,9 @@ export const churchExportSchema = z.object({ /** The site's own settings that matter to a church (name, contact, branding), never secrets. */ settings: z.record(z.string().max(100), z.string().max(5000)), /** Uploaded files in the ZIP's `uploads/` folder. */ - files: z.array(z.object({ path: z.string().regex(/^uploads\/[A-Za-z0-9._/-]+$/), bytes: z.int().nonnegative() })), + files: z.array(z.object({ path: uploadPath, bytes: z.int().nonnegative() })), + /** Only in the Website's export (contracts 1.17.0). Its editors are in `people`, with their roles. */ + website: exportWebsiteSchema.optional(), }); export type ChurchExport = z.infer; diff --git a/packages/contracts/src/church.ts b/packages/contracts/src/church.ts index 9712bbe..1b48192 100644 --- a/packages/contracts/src/church.ts +++ b/packages/contracts/src/church.ts @@ -1,6 +1,7 @@ import { z } from "zod"; import { dateTimeSchema, emailSchema, hexColourSchema, idSchema, phoneSchema, slugSchema, timeOfDaySchema, timezoneSchema, urlSchema } from "./common"; import { schemaName } from "./schema-name"; +import { brandStyleSchema } from "./style"; /** * `crosscode.church/1` — the church profile, set once and shared by every product of a church @@ -68,6 +69,11 @@ export const churchObjectSchema = z primary: hexColourSchema, accent: hexColourSchema.nullable(), }), + /** + * Font pairing and corners, shared by every product (contracts 1.17.0, `./style`). Optional: + * a profile from an Accounts before 1.7.0 has none, which means the defaults. + */ + style: brandStyleSchema.optional(), }), /** Empty when campuses are off. */ campuses: z.array(campusSchema).max(50), diff --git a/packages/contracts/src/hub.ts b/packages/contracts/src/hub.ts index 2c443e4..4dcf814 100644 --- a/packages/contracts/src/hub.ts +++ b/packages/contracts/src/hub.ts @@ -355,6 +355,14 @@ export const licencePayloadSchema = z.object({ graceDays: z.int().nonnegative(), issuedAt: dateTimeSchema, validUntil: dateTimeSchema, - limits: z.object({ aiMonthlyCapCents: z.number().nonnegative() }), + limits: z.object({ + aiMonthlyCapCents: z.number().nonnegative(), + /** + * The Website's storage limit in bytes: what's included plus any storage add-ons + * (WEBSITE-1.0-PLAN §10, decision 12). Uploads stop when it's full. Only on a Website licence, + * from Hub 2.21.0 (contracts 1.17.0); a Website without it uses its own included amount. + */ + storageBytes: z.int().nonnegative().optional(), + }), }); export type LicencePayload = z.infer; diff --git a/packages/contracts/src/identity-request.ts b/packages/contracts/src/identity-request.ts index 33a7dfa..5512c31 100644 --- a/packages/contracts/src/identity-request.ts +++ b/packages/contracts/src/identity-request.ts @@ -2,6 +2,7 @@ import { z } from "zod"; import { dateTimeSchema, emailSchema, idSchema, phoneSchema } from "./common"; import { profileSchema, twoFactorMethodSchema } from "./identity"; import { schemaName } from "./schema-name"; +import { churchObjectSchema, churchSchema } from "./church"; /** * `crosscode.identity-request/1` (contracts 1.8.0, docs/EVENTS-3.0-PLAN.md §4 and §8): what a @@ -21,6 +22,8 @@ import { schemaName } from "./schema-name"; * unsubscribe link). Accounts only acts on people the product knows (signed in through it or * imported by it), and audits each with the product and the admin's `sub`. 1.11.0 adds * `people.removeDemo`: new demo data in a product removes the old demo people's accounts. + * - **`church.*`**: the church profile from a product. `church.branding` (1.9.0) fills in the + * look; `church.update` (1.17.0) changes shared facts from the Website's admin. */ export const IDENTITY_REQUEST_SCHEMA = schemaName("identity-request", 1); @@ -240,10 +243,40 @@ export const messagingSetSchema = messagingTestSchema.extend({ type: z.literal(" */ export const churchBrandingSchema = base.extend({ type: z.literal("church.branding"), church: churchLookSchema, overwrite: z.boolean() }); +/** + * The profile fields a product may change: the profile without what Accounts fills in itself + * (`customerId`, `updatedAt`, `links`). + */ +export const churchEditableSchema = churchObjectSchema.omit({ schema: true, customerId: true, updatedAt: true, links: true }); + +/** + * 1.17.0: change shared profile facts from a product's admin (the Website's, WEBSITE-1.0-PLAN + * decision 10). The product checks the person may do it (its own roles: Accounts doesn't know + * them) and sends it with them as `actor`; Accounts audits it with the product and the actor. + * + * Only the fields given change. A given field replaces Accounts' value as a whole (a list, an + * address, `branding.colours`), except `branding`, whose own fields can be given one at a time + * (only `style`, say). It goes live at once (shared facts aren't drafts) and Accounts sends + * `church.changed` to every linked product. With `ifUpdatedAt`, Accounts refuses with + * `PROFILE_CHANGED` when the profile changed since (someone saved in between). + * + * Accounts takes it from the Website only (`WRONG_PRODUCT` otherwise) and needs an `actor` + * (`NOT_ALLOWED`). The reply is the profile after the change. + */ +export const churchUpdateSchema = base.extend({ + type: z.literal("church.update"), + actor: idSchema, + ifUpdatedAt: dateTimeSchema.optional(), + church: churchEditableSchema + .extend({ branding: churchEditableSchema.shape.branding.partial() }) + .partial() + .refine((c) => Object.keys(c).length > 0, "Nothing to change"), +}); + export const identityRequestSchema = z.discriminatedUnion("type", [ importBeginSchema, importBatchSchema, importFinishSchema, importAbortSchema, peopleEnsureSchema, peopleUpdateSchema, peopleResetTwoFactorSchema, peopleUnlockSchema, peopleSetActiveSchema, peopleNewsOffSchema, - peopleRemoveDemoSchema, peopleCheckSchema, messagingStatusSchema, messagingTestSchema, messagingSetSchema, churchBrandingSchema, + peopleRemoveDemoSchema, peopleCheckSchema, messagingStatusSchema, messagingTestSchema, messagingSetSchema, churchBrandingSchema, churchUpdateSchema, ]); export type IdentityRequest = z.infer; export type IdentityRequestType = IdentityRequest["type"]; @@ -323,7 +356,13 @@ export const messagingTestReplySchema = z.object({ }); export type MessagingTestReply = z.infer; +/** church.update: the profile after the change. */ +export const churchUpdateReplySchema = z.object({ schema: z.literal(IDENTITY_REQUEST_SCHEMA), church: churchSchema }); +export type ChurchUpdateReply = z.infer; + /** Errors: `{ message, code }` as the other link calls. */ export const IDENTITY_REQUEST_ERROR_CODES = [ "NOT_LINKED", "BAD_SIGNATURE", "STALE_REQUEST", "INVALID_REQUEST", "NOT_MOVING", "WRONG_PRODUCT", "UNKNOWN_PERSON", "EMAIL_TAKEN", "NOT_ALLOWED", + /** 1.17.0, church.update with `ifUpdatedAt`: the profile changed since. */ + "PROFILE_CHANGED", ] as const; diff --git a/packages/contracts/src/index.ts b/packages/contracts/src/index.ts index 8d7890c..32f508e 100644 --- a/packages/contracts/src/index.ts +++ b/packages/contracts/src/index.ts @@ -6,6 +6,7 @@ export * from "./schema-name"; export * from "./common"; export * from "./event"; export * from "./church"; +export * from "./style"; export * from "./identity"; export * from "./identity-request"; export * from "./return-to"; diff --git a/packages/contracts/src/style.ts b/packages/contracts/src/style.ts new file mode 100644 index 0000000..5c680e0 --- /dev/null +++ b/packages/contracts/src/style.ts @@ -0,0 +1,73 @@ +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; + +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; + +/** 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; +/** 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; + +/** + * 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 = { + 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; diff --git a/packages/contracts/tests/agent.test.ts b/packages/contracts/tests/agent.test.ts index 0f3ed00..ad55017 100644 --- a/packages/contracts/tests/agent.test.ts +++ b/packages/contracts/tests/agent.test.ts @@ -141,8 +141,8 @@ describe("exports", () => { expect(() => decryptExport(file, encryptExport(zip).key)).toThrow(); }); - it("the sample has no internal ids", () => { - const data = sample("church-export.json"); + it.each(["church-export.json", "church-export-website.json"])("%s has no internal ids", (file) => { + const data = sample(file); expect(churchExportSchema.safeParse(data).success).toBe(true); const keys: string[] = []; const walk = (v: unknown): void => { diff --git a/packages/contracts/tests/json-schemas.test.ts b/packages/contracts/tests/json-schemas.test.ts index af7d762..dd33976 100644 --- a/packages/contracts/tests/json-schemas.test.ts +++ b/packages/contracts/tests/json-schemas.test.ts @@ -35,7 +35,9 @@ const SAMPLE_SCHEMA: Record = { "hub-heartbeat-accounts.json": "hub-heartbeat-request", "hub-heartbeat-response.json": "hub-heartbeat-response", "hub-licence-payload.json": "hub-licence-payload", + "hub-licence-payload-website.json": "hub-licence-payload", "church-export.json": "church-export", + "church-export-website.json": "church-export", "church-changed.json": "church-changed", "link-connect.json": "link-connect", "link-connected.json": "link-connected", @@ -52,6 +54,8 @@ const SAMPLE_SCHEMA: Record = { "people-remove-demo-reply.json": "people-remove-demo-reply", "people-check.json": "identity-request", "people-check-reply.json": "people-check-reply", + "church-update.json": "identity-request", + "church-update-reply.json": "church-update-reply", }; describe("JSON Schema (schemas/)", () => { diff --git a/packages/contracts/tests/samples.test.ts b/packages/contracts/tests/samples.test.ts index ce8a3bc..cec8e2e 100644 --- a/packages/contracts/tests/samples.test.ts +++ b/packages/contracts/tests/samples.test.ts @@ -17,7 +17,7 @@ import { importBatchReplySchema, peopleEnsureReplySchema, messagingTestReplySchema, - peopleRemoveDemoReplySchema, peopleCheckReplySchema, + peopleRemoveDemoReplySchema, peopleCheckReplySchema, churchUpdateReplySchema, userDeletedReplySchema, userExportReplySchema, } from "../src"; @@ -44,7 +44,9 @@ const SCHEMAS: Record = { "hub-heartbeat-accounts.json": hub.heartbeatRequestSchema, "hub-heartbeat-response.json": hub.heartbeatResponseSchema, "hub-licence-payload.json": hub.licencePayloadSchema, + "hub-licence-payload-website.json": hub.licencePayloadSchema, "church-export.json": churchExportSchema, + "church-export-website.json": churchExportSchema, "church-changed.json": churchChangedSchema, "link-connect.json": linkConnectSchema, "link-connected.json": linkConnectedSchema, @@ -61,6 +63,8 @@ const SCHEMAS: Record = { "people-remove-demo-reply.json": peopleRemoveDemoReplySchema, "people-check.json": identityRequestSchema, "people-check-reply.json": peopleCheckReplySchema, + "church-update.json": identityRequestSchema, + "church-update-reply.json": churchUpdateReplySchema, }; describe("samples", () => { diff --git a/packages/contracts/tests/style.test.ts b/packages/contracts/tests/style.test.ts new file mode 100644 index 0000000..283bcc7 --- /dev/null +++ b/packages/contracts/tests/style.test.ts @@ -0,0 +1,102 @@ +import { + brandStyleSchema, + churchExportSchema, + churchSchema, + CORNERS, + FONT_PAIRING_IDS, + FONT_PAIRINGS, + hub, + identityRequestSchema, + TEMPLATE_FONT_PAIRINGS, + WEBSITE_TEMPLATES, +} from "../src"; +import type { Church, ChurchExport } from "../src"; +import { sample } from "./helpers"; + +describe("brand style (1.17.0)", () => { + it("has the 8 confirmed font pairings, ids unchanged", () => { + // These ids are stored in churches' profiles: changing or removing one is a breaking change. + expect(FONT_PAIRING_IDS).toEqual(["classic", "scholarly", "editorial", "impact", "contemporary", "friendly", "warm", "modern"]); + expect(CORNERS).toEqual(["sharp", "soft", "round"]); + }); + + it("each template recommends three different pairings, and every pairing is recommended somewhere", () => { + expect(Object.keys(TEMPLATE_FONT_PAIRINGS).sort()).toEqual([...WEBSITE_TEMPLATES].sort()); + for (const picks of Object.values(TEMPLATE_FONT_PAIRINGS)) expect(new Set(picks).size).toBe(3); + const recommended = new Set(Object.values(TEMPLATE_FONT_PAIRINGS).flat()); + expect([...recommended].sort()).toEqual([...FONT_PAIRING_IDS].sort()); + }); + + it("every pairing names a heading and a body font", () => { + for (const p of Object.values(FONT_PAIRINGS)) { + expect(p.heading.family.length).toBeGreaterThan(0); + expect(p.body.family.length).toBeGreaterThan(0); + } + }); + + it("a profile without a style still parses (Accounts before 1.7.0)", () => { + const c = sample("church.json"); + delete c.branding.style; + const parsed = churchSchema.parse(c); + expect(parsed.branding.style).toBeUndefined(); + }); + + it("an unknown pairing or corner from a newer Accounts reads as null instead of failing", () => { + expect(brandStyleSchema.parse({ fontPairing: "gothic", corners: "pointy" })).toEqual({ fontPairing: null, corners: null }); + const c = sample("church.json"); + const parsed = churchSchema.parse({ ...c, branding: { ...c.branding, style: { fontPairing: "gothic", corners: "round" } } }); + expect(parsed.branding.style).toEqual({ fontPairing: null, corners: "round" }); + }); +}); + +describe("the Website's export (1.17.0)", () => { + const data = () => sample("church-export-website.json"); + + it("is optional, so Events' and Accounts' exports are unchanged", () => { + const events = churchExportSchema.parse(sample("church-export.json")); + expect(events.website).toBeUndefined(); + }); + + it("refuses an unknown template, a page path that isn't one, and media outside uploads/", () => { + const d = data(); + const bad = (website: object) => churchExportSchema.safeParse({ ...d, website: { ...d.website, ...website } }).success; + expect(bad({ template: "minimal" })).toBe(false); + expect(bad({ pages: [{ ...d.website!.pages[0]!, path: "about" }] })).toBe(false); + expect(bad({ media: [{ path: "../etc/passwd", alt: null, caption: null }] })).toBe(false); + }); + + it("a message is a YouTube-feed or hand-added link", () => { + const d = data(); + const msg = { ...d.website!.messages[0]!, source: "upload" }; + expect(churchExportSchema.safeParse({ ...d, website: { ...d.website, messages: [msg] } }).success).toBe(false); + }); +}); + +describe("licence storage limit (1.17.0)", () => { + it("is optional, and only whole non-negative bytes", () => { + const lic = sample("hub-licence-payload-website.json"); + expect(hub.licencePayloadSchema.parse(lic).limits.storageBytes).toBe(10737418240); + expect(hub.licencePayloadSchema.parse(sample("hub-licence-payload.json")).limits.storageBytes).toBeUndefined(); + expect(hub.licencePayloadSchema.safeParse({ ...lic, limits: { ...lic.limits, storageBytes: -1 } }).success).toBe(false); + }); +}); + +describe("church.update (1.17.0)", () => { + const req = () => sample>("church-update.json"); + + it("needs an actor and something to change", () => { + expect(identityRequestSchema.safeParse({ ...req(), actor: null }).success).toBe(false); + expect(identityRequestSchema.safeParse({ ...req(), church: {} }).success).toBe(false); + }); + + it("takes part of branding (only the style), but not the fields Accounts fills in", () => { + const parsed = identityRequestSchema.parse({ ...req(), church: { branding: { style: { fontPairing: "modern", corners: null } } } }); + expect(parsed.type === "church.update" && parsed.church.branding).toEqual({ style: { fontPairing: "modern", corners: null } }); + const withLinks = identityRequestSchema.parse({ ...req(), church: { name: "Hope", links: { accounts: "https://evil.example" }, customerId: "x" } }); + expect(withLinks.type === "church.update" && Object.keys(withLinks.church)).toEqual(["name"]); + }); + + it("still checks what it's given", () => { + expect(identityRequestSchema.safeParse({ ...req(), church: { branding: { colours: { primary: "blue", accent: null } } } }).success).toBe(false); + }); +}); diff --git a/packages/ui/fonts/LICENSES.md b/packages/ui/fonts/LICENSES.md new file mode 100644 index 0000000..d9406af --- /dev/null +++ b/packages/ui/fonts/LICENSES.md @@ -0,0 +1,18 @@ +# Font licences + +Every font in `files/` is from the [Fontsource](https://fontsource.org) packages pinned in +`packages/ui/package.json` and is licensed under the **SIL Open Font License 1.1**: free to use, +bundle and self-host, not to be sold on its own. Each package's `LICENSE` has the full text and the +copyright holders. + +- Lora: `@fontsource-variable/lora` +- Source Sans 3: `@fontsource-variable/source-sans-3` +- EB Garamond: `@fontsource-variable/eb-garamond` +- Playfair Display: `@fontsource-variable/playfair-display` +- Inter: `@fontsource-variable/inter` +- Oswald: `@fontsource-variable/oswald` +- Outfit: `@fontsource-variable/outfit` +- DM Sans: `@fontsource-variable/dm-sans` +- Nunito: `@fontsource-variable/nunito` +- Fraunces: `@fontsource-variable/fraunces` +- Nunito Sans: `@fontsource-variable/nunito-sans` diff --git a/packages/ui/fonts/files/dm-sans-latin-ext-wght-italic.woff2 b/packages/ui/fonts/files/dm-sans-latin-ext-wght-italic.woff2 new file mode 100644 index 0000000..9ad3c7b Binary files /dev/null and b/packages/ui/fonts/files/dm-sans-latin-ext-wght-italic.woff2 differ diff --git a/packages/ui/fonts/files/dm-sans-latin-ext-wght-normal.woff2 b/packages/ui/fonts/files/dm-sans-latin-ext-wght-normal.woff2 new file mode 100644 index 0000000..db39c62 Binary files /dev/null and b/packages/ui/fonts/files/dm-sans-latin-ext-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/dm-sans-latin-wght-italic.woff2 b/packages/ui/fonts/files/dm-sans-latin-wght-italic.woff2 new file mode 100644 index 0000000..4a40d16 Binary files /dev/null and b/packages/ui/fonts/files/dm-sans-latin-wght-italic.woff2 differ diff --git a/packages/ui/fonts/files/dm-sans-latin-wght-normal.woff2 b/packages/ui/fonts/files/dm-sans-latin-wght-normal.woff2 new file mode 100644 index 0000000..01383d7 Binary files /dev/null and b/packages/ui/fonts/files/dm-sans-latin-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/eb-garamond-latin-ext-wght-italic.woff2 b/packages/ui/fonts/files/eb-garamond-latin-ext-wght-italic.woff2 new file mode 100644 index 0000000..4430cc2 Binary files /dev/null and b/packages/ui/fonts/files/eb-garamond-latin-ext-wght-italic.woff2 differ diff --git a/packages/ui/fonts/files/eb-garamond-latin-ext-wght-normal.woff2 b/packages/ui/fonts/files/eb-garamond-latin-ext-wght-normal.woff2 new file mode 100644 index 0000000..cdc58b0 Binary files /dev/null and b/packages/ui/fonts/files/eb-garamond-latin-ext-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/eb-garamond-latin-wght-italic.woff2 b/packages/ui/fonts/files/eb-garamond-latin-wght-italic.woff2 new file mode 100644 index 0000000..e3f8150 Binary files /dev/null and b/packages/ui/fonts/files/eb-garamond-latin-wght-italic.woff2 differ diff --git a/packages/ui/fonts/files/eb-garamond-latin-wght-normal.woff2 b/packages/ui/fonts/files/eb-garamond-latin-wght-normal.woff2 new file mode 100644 index 0000000..ed33cd8 Binary files /dev/null and b/packages/ui/fonts/files/eb-garamond-latin-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/fraunces-latin-ext-soft-normal.woff2 b/packages/ui/fonts/files/fraunces-latin-ext-soft-normal.woff2 new file mode 100644 index 0000000..fdf25c1 Binary files /dev/null and b/packages/ui/fonts/files/fraunces-latin-ext-soft-normal.woff2 differ diff --git a/packages/ui/fonts/files/fraunces-latin-soft-normal.woff2 b/packages/ui/fonts/files/fraunces-latin-soft-normal.woff2 new file mode 100644 index 0000000..e6dbcec Binary files /dev/null and b/packages/ui/fonts/files/fraunces-latin-soft-normal.woff2 differ diff --git a/packages/ui/fonts/files/inter-latin-ext-wght-italic.woff2 b/packages/ui/fonts/files/inter-latin-ext-wght-italic.woff2 new file mode 100644 index 0000000..7bf20e1 Binary files /dev/null and b/packages/ui/fonts/files/inter-latin-ext-wght-italic.woff2 differ diff --git a/packages/ui/fonts/files/inter-latin-ext-wght-normal.woff2 b/packages/ui/fonts/files/inter-latin-ext-wght-normal.woff2 new file mode 100644 index 0000000..479d010 Binary files /dev/null and b/packages/ui/fonts/files/inter-latin-ext-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/inter-latin-wght-italic.woff2 b/packages/ui/fonts/files/inter-latin-wght-italic.woff2 new file mode 100644 index 0000000..2f06c65 Binary files /dev/null and b/packages/ui/fonts/files/inter-latin-wght-italic.woff2 differ diff --git a/packages/ui/fonts/files/inter-latin-wght-normal.woff2 b/packages/ui/fonts/files/inter-latin-wght-normal.woff2 new file mode 100644 index 0000000..d15208d Binary files /dev/null and b/packages/ui/fonts/files/inter-latin-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/lora-latin-ext-wght-normal.woff2 b/packages/ui/fonts/files/lora-latin-ext-wght-normal.woff2 new file mode 100644 index 0000000..b8d5a4f Binary files /dev/null and b/packages/ui/fonts/files/lora-latin-ext-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/lora-latin-wght-normal.woff2 b/packages/ui/fonts/files/lora-latin-wght-normal.woff2 new file mode 100644 index 0000000..918a477 Binary files /dev/null and b/packages/ui/fonts/files/lora-latin-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/nunito-latin-ext-wght-italic.woff2 b/packages/ui/fonts/files/nunito-latin-ext-wght-italic.woff2 new file mode 100644 index 0000000..54b2abc Binary files /dev/null and b/packages/ui/fonts/files/nunito-latin-ext-wght-italic.woff2 differ diff --git a/packages/ui/fonts/files/nunito-latin-ext-wght-normal.woff2 b/packages/ui/fonts/files/nunito-latin-ext-wght-normal.woff2 new file mode 100644 index 0000000..14a9f78 Binary files /dev/null and b/packages/ui/fonts/files/nunito-latin-ext-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/nunito-latin-wght-italic.woff2 b/packages/ui/fonts/files/nunito-latin-wght-italic.woff2 new file mode 100644 index 0000000..d5b4668 Binary files /dev/null and b/packages/ui/fonts/files/nunito-latin-wght-italic.woff2 differ diff --git a/packages/ui/fonts/files/nunito-latin-wght-normal.woff2 b/packages/ui/fonts/files/nunito-latin-wght-normal.woff2 new file mode 100644 index 0000000..3e909a1 Binary files /dev/null and b/packages/ui/fonts/files/nunito-latin-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/nunito-sans-latin-ext-wght-italic.woff2 b/packages/ui/fonts/files/nunito-sans-latin-ext-wght-italic.woff2 new file mode 100644 index 0000000..51402e1 Binary files /dev/null and b/packages/ui/fonts/files/nunito-sans-latin-ext-wght-italic.woff2 differ diff --git a/packages/ui/fonts/files/nunito-sans-latin-ext-wght-normal.woff2 b/packages/ui/fonts/files/nunito-sans-latin-ext-wght-normal.woff2 new file mode 100644 index 0000000..6c98227 Binary files /dev/null and b/packages/ui/fonts/files/nunito-sans-latin-ext-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/nunito-sans-latin-wght-italic.woff2 b/packages/ui/fonts/files/nunito-sans-latin-wght-italic.woff2 new file mode 100644 index 0000000..cf178d3 Binary files /dev/null and b/packages/ui/fonts/files/nunito-sans-latin-wght-italic.woff2 differ diff --git a/packages/ui/fonts/files/nunito-sans-latin-wght-normal.woff2 b/packages/ui/fonts/files/nunito-sans-latin-wght-normal.woff2 new file mode 100644 index 0000000..4361be6 Binary files /dev/null and b/packages/ui/fonts/files/nunito-sans-latin-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/oswald-latin-ext-wght-normal.woff2 b/packages/ui/fonts/files/oswald-latin-ext-wght-normal.woff2 new file mode 100644 index 0000000..cde7f80 Binary files /dev/null and b/packages/ui/fonts/files/oswald-latin-ext-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/oswald-latin-wght-normal.woff2 b/packages/ui/fonts/files/oswald-latin-wght-normal.woff2 new file mode 100644 index 0000000..7b2a550 Binary files /dev/null and b/packages/ui/fonts/files/oswald-latin-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/outfit-latin-ext-wght-normal.woff2 b/packages/ui/fonts/files/outfit-latin-ext-wght-normal.woff2 new file mode 100644 index 0000000..c54ceec Binary files /dev/null and b/packages/ui/fonts/files/outfit-latin-ext-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/outfit-latin-wght-normal.woff2 b/packages/ui/fonts/files/outfit-latin-wght-normal.woff2 new file mode 100644 index 0000000..85e3332 Binary files /dev/null and b/packages/ui/fonts/files/outfit-latin-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/playfair-display-latin-ext-wght-normal.woff2 b/packages/ui/fonts/files/playfair-display-latin-ext-wght-normal.woff2 new file mode 100644 index 0000000..53c412b Binary files /dev/null and b/packages/ui/fonts/files/playfair-display-latin-ext-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/playfair-display-latin-wght-normal.woff2 b/packages/ui/fonts/files/playfair-display-latin-wght-normal.woff2 new file mode 100644 index 0000000..5a3fbbd Binary files /dev/null and b/packages/ui/fonts/files/playfair-display-latin-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/source-sans-3-latin-ext-wght-italic.woff2 b/packages/ui/fonts/files/source-sans-3-latin-ext-wght-italic.woff2 new file mode 100644 index 0000000..a5ee6af Binary files /dev/null and b/packages/ui/fonts/files/source-sans-3-latin-ext-wght-italic.woff2 differ diff --git a/packages/ui/fonts/files/source-sans-3-latin-ext-wght-normal.woff2 b/packages/ui/fonts/files/source-sans-3-latin-ext-wght-normal.woff2 new file mode 100644 index 0000000..7f78ca9 Binary files /dev/null and b/packages/ui/fonts/files/source-sans-3-latin-ext-wght-normal.woff2 differ diff --git a/packages/ui/fonts/files/source-sans-3-latin-wght-italic.woff2 b/packages/ui/fonts/files/source-sans-3-latin-wght-italic.woff2 new file mode 100644 index 0000000..7c4bc85 Binary files /dev/null and b/packages/ui/fonts/files/source-sans-3-latin-wght-italic.woff2 differ diff --git a/packages/ui/fonts/files/source-sans-3-latin-wght-normal.woff2 b/packages/ui/fonts/files/source-sans-3-latin-wght-normal.woff2 new file mode 100644 index 0000000..2622b13 Binary files /dev/null and b/packages/ui/fonts/files/source-sans-3-latin-wght-normal.woff2 differ diff --git a/packages/ui/fonts/fonts.css b/packages/ui/fonts/fonts.css new file mode 100644 index 0000000..5b24aee --- /dev/null +++ b/packages/ui/fonts/fonts.css @@ -0,0 +1,60 @@ +/* Generated by packages/ui/scripts/fonts.mjs from @fontsource-variable (SIL Open Font License 1.1, + see fonts/LICENSES.md) and Capsize metrics. Don't edit: run `npm run fonts -w packages/ui`. */ + +@font-face { font-family: 'CC Lora'; font-style: normal; font-display: swap; font-weight: 400 700; src: url(./files/lora-latin-ext-wght-normal.woff2) format('woff2-variations'), url(./files/lora-latin-ext-wght-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; } +@font-face { font-family: 'CC Lora'; font-style: normal; font-display: swap; font-weight: 400 700; src: url(./files/lora-latin-wght-normal.woff2) format('woff2-variations'), url(./files/lora-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; } +@font-face { font-family: "CC Lora Fallback"; src: local('Georgia'); ascent-override: 95.8281%; descent-override: 26.1003%; size-adjust: 104.9796%; } +@font-face { font-family: 'CC Source Sans 3'; font-style: normal; font-display: swap; font-weight: 200 900; src: url(./files/source-sans-3-latin-ext-wght-normal.woff2) format('woff2-variations'), url(./files/source-sans-3-latin-ext-wght-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C4,U+2113,U+2C60-2C7F,U+A720-A7FF; } +@font-face { font-family: 'CC Source Sans 3'; font-style: normal; font-display: swap; font-weight: 200 900; src: url(./files/source-sans-3-latin-wght-normal.woff2) format('woff2-variations'), url(./files/source-sans-3-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; } +@font-face { font-family: 'CC Source Sans 3'; font-style: italic; font-display: swap; font-weight: 200 900; src: url(./files/source-sans-3-latin-ext-wght-italic.woff2) format('woff2-variations'), url(./files/source-sans-3-latin-ext-wght-italic.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C4,U+2113,U+2C60-2C7F,U+A720-A7FF; } +@font-face { font-family: 'CC Source Sans 3'; font-style: italic; font-display: swap; font-weight: 200 900; src: url(./files/source-sans-3-latin-wght-italic.woff2) format('woff2-variations'), url(./files/source-sans-3-latin-wght-italic.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; } +@font-face { font-family: "CC Source Sans 3 Fallback"; src: local('Arial'), local('ArialMT'); ascent-override: 109.2105%; descent-override: 42.6604%; line-gap-override: 0%; size-adjust: 93.7639%; } +@font-face { font-family: 'CC EB Garamond'; font-style: normal; font-display: swap; font-weight: 400 800; src: url(./files/eb-garamond-latin-ext-wght-normal.woff2) format('woff2-variations'), url(./files/eb-garamond-latin-ext-wght-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; } +@font-face { font-family: 'CC EB Garamond'; font-style: normal; font-display: swap; font-weight: 400 800; src: url(./files/eb-garamond-latin-wght-normal.woff2) format('woff2-variations'), url(./files/eb-garamond-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; } +@font-face { font-family: 'CC EB Garamond'; font-style: italic; font-display: swap; font-weight: 400 800; src: url(./files/eb-garamond-latin-ext-wght-italic.woff2) format('woff2-variations'), url(./files/eb-garamond-latin-ext-wght-italic.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; } +@font-face { font-family: 'CC EB Garamond'; font-style: italic; font-display: swap; font-weight: 400 800; src: url(./files/eb-garamond-latin-wght-italic.woff2) format('woff2-variations'), url(./files/eb-garamond-latin-wght-italic.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; } +@font-face { font-family: "CC EB Garamond Fallback"; src: local('Georgia'); ascent-override: 116.603%; descent-override: 34.5061%; size-adjust: 86.3614%; } +@font-face { font-family: 'CC Playfair Display'; font-style: normal; font-display: swap; font-weight: 400 900; src: url(./files/playfair-display-latin-ext-wght-normal.woff2) format('woff2-variations'), url(./files/playfair-display-latin-ext-wght-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; } +@font-face { font-family: 'CC Playfair Display'; font-style: normal; font-display: swap; font-weight: 400 900; src: url(./files/playfair-display-latin-wght-normal.woff2) format('woff2-variations'), url(./files/playfair-display-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; } +@font-face { font-family: "CC Playfair Display Fallback"; src: local('Georgia'); ascent-override: 106.716%; descent-override: 24.7558%; size-adjust: 101.3906%; } +@font-face { font-family: 'CC Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(./files/inter-latin-ext-wght-normal.woff2) format('woff2-variations'), url(./files/inter-latin-ext-wght-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; } +@font-face { font-family: 'CC Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(./files/inter-latin-wght-normal.woff2) format('woff2-variations'), url(./files/inter-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; } +@font-face { font-family: 'CC Inter'; font-style: italic; font-display: swap; font-weight: 100 900; src: url(./files/inter-latin-ext-wght-italic.woff2) format('woff2-variations'), url(./files/inter-latin-ext-wght-italic.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; } +@font-face { font-family: 'CC Inter'; font-style: italic; font-display: swap; font-weight: 100 900; src: url(./files/inter-latin-wght-italic.woff2) format('woff2-variations'), url(./files/inter-latin-wght-italic.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; } +@font-face { font-family: "CC Inter Fallback"; src: local('Arial'), local('ArialMT'); ascent-override: 90.4365%; descent-override: 22.518%; line-gap-override: 0%; size-adjust: 107.1194%; } +@font-face { font-family: 'CC Oswald'; font-style: normal; font-display: swap; font-weight: 200 700; src: url(./files/oswald-latin-ext-wght-normal.woff2) format('woff2-variations'), url(./files/oswald-latin-ext-wght-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; } +@font-face { font-family: 'CC Oswald'; font-style: normal; font-display: swap; font-weight: 200 700; src: url(./files/oswald-latin-wght-normal.woff2) format('woff2-variations'), url(./files/oswald-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; } +@font-face { font-family: "CC Oswald Fallback"; src: local('Arial'), local('ArialMT'); ascent-override: 146.5125%; descent-override: 35.4921%; line-gap-override: 0%; size-adjust: 81.4265%; } +@font-face { font-family: 'CC Outfit'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(./files/outfit-latin-ext-wght-normal.woff2) format('woff2-variations'), url(./files/outfit-latin-ext-wght-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; } +@font-face { font-family: 'CC Outfit'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(./files/outfit-latin-wght-normal.woff2) format('woff2-variations'), url(./files/outfit-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; } +@font-face { font-family: "CC Outfit Fallback"; src: local('Arial'), local('ArialMT'); ascent-override: 100.18%; descent-override: 26.0468%; line-gap-override: 0%; size-adjust: 99.8204%; } +@font-face { font-family: 'CC DM Sans'; font-style: normal; font-display: swap; font-weight: 100 1000; src: url(./files/dm-sans-latin-ext-wght-normal.woff2) format('woff2-variations'), url(./files/dm-sans-latin-ext-wght-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; } +@font-face { font-family: 'CC DM Sans'; font-style: normal; font-display: swap; font-weight: 100 1000; src: url(./files/dm-sans-latin-wght-normal.woff2) format('woff2-variations'), url(./files/dm-sans-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; } +@font-face { font-family: 'CC DM Sans'; font-style: italic; font-display: swap; font-weight: 100 1000; src: url(./files/dm-sans-latin-ext-wght-italic.woff2) format('woff2-variations'), url(./files/dm-sans-latin-ext-wght-italic.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; } +@font-face { font-family: 'CC DM Sans'; font-style: italic; font-display: swap; font-weight: 100 1000; src: url(./files/dm-sans-latin-wght-italic.woff2) format('woff2-variations'), url(./files/dm-sans-latin-wght-italic.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; } +@font-face { font-family: "CC DM Sans Fallback"; src: local('Arial'), local('ArialMT'); ascent-override: 94.9001%; descent-override: 29.6563%; line-gap-override: 0%; size-adjust: 104.531%; } +@font-face { font-family: 'CC Nunito'; font-style: normal; font-display: swap; font-weight: 200 1000; src: url(./files/nunito-latin-ext-wght-normal.woff2) format('woff2-variations'), url(./files/nunito-latin-ext-wght-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; } +@font-face { font-family: 'CC Nunito'; font-style: normal; font-display: swap; font-weight: 200 1000; src: url(./files/nunito-latin-wght-normal.woff2) format('woff2-variations'), url(./files/nunito-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; } +@font-face { font-family: 'CC Nunito'; font-style: italic; font-display: swap; font-weight: 200 1000; src: url(./files/nunito-latin-ext-wght-italic.woff2) format('woff2-variations'), url(./files/nunito-latin-ext-wght-italic.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; } +@font-face { font-family: 'CC Nunito'; font-style: italic; font-display: swap; font-weight: 200 1000; src: url(./files/nunito-latin-wght-italic.woff2) format('woff2-variations'), url(./files/nunito-latin-wght-italic.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; } +@font-face { font-family: "CC Nunito Fallback"; src: local('Arial'), local('ArialMT'); ascent-override: 99.7134%; descent-override: 34.8159%; line-gap-override: 0%; size-adjust: 101.3906%; } +@font-face { font-family: 'CC Fraunces'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(./files/fraunces-latin-ext-soft-normal.woff2) format('woff2-variations'), url(./files/fraunces-latin-ext-soft-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; } +@font-face { font-family: 'CC Fraunces'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(./files/fraunces-latin-soft-normal.woff2) format('woff2-variations'), url(./files/fraunces-latin-soft-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; } +@font-face { font-family: "CC Fraunces Fallback"; src: local('Georgia'); ascent-override: 92.9623%; descent-override: 24.2386%; size-adjust: 105.2039%; } +@font-face { font-family: 'CC Nunito Sans'; font-style: normal; font-display: swap; font-weight: 200 1000; src: url(./files/nunito-sans-latin-ext-wght-normal.woff2) format('woff2-variations'), url(./files/nunito-sans-latin-ext-wght-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; } +@font-face { font-family: 'CC Nunito Sans'; font-style: normal; font-display: swap; font-weight: 200 1000; src: url(./files/nunito-sans-latin-wght-normal.woff2) format('woff2-variations'), url(./files/nunito-sans-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; } +@font-face { font-family: 'CC Nunito Sans'; font-style: italic; font-display: swap; font-weight: 200 1000; src: url(./files/nunito-sans-latin-ext-wght-italic.woff2) format('woff2-variations'), url(./files/nunito-sans-latin-ext-wght-italic.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; } +@font-face { font-family: 'CC Nunito Sans'; font-style: italic; font-display: swap; font-weight: 200 1000; src: url(./files/nunito-sans-latin-wght-italic.woff2) format('woff2-variations'), url(./files/nunito-sans-latin-wght-italic.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; } +@font-face { font-family: "CC Nunito Sans Fallback"; src: local('Arial'), local('ArialMT'); ascent-override: 99.7134%; descent-override: 34.8159%; line-gap-override: 0%; size-adjust: 101.3906%; } + +[data-cc-fonts="classic"] { --cc-font-heading: "CC Lora", "CC Lora Fallback", Georgia, serif; --cc-font-body: "CC Source Sans 3", "CC Source Sans 3 Fallback", Arial, sans-serif; --cc-heading-variation: normal; } +[data-cc-fonts="scholarly"] { --cc-font-heading: "CC EB Garamond", "CC EB Garamond Fallback", Georgia, serif; --cc-font-body: "CC EB Garamond", "CC EB Garamond Fallback", Georgia, serif; --cc-heading-variation: normal; } +[data-cc-fonts="editorial"] { --cc-font-heading: "CC Playfair Display", "CC Playfair Display Fallback", Georgia, serif; --cc-font-body: "CC Inter", "CC Inter Fallback", Arial, sans-serif; --cc-heading-variation: normal; } +[data-cc-fonts="impact"] { --cc-font-heading: "CC Oswald", "CC Oswald Fallback", Arial, sans-serif; --cc-font-body: "CC Source Sans 3", "CC Source Sans 3 Fallback", Arial, sans-serif; --cc-heading-variation: normal; } +[data-cc-fonts="contemporary"] { --cc-font-heading: "CC Outfit", "CC Outfit Fallback", Arial, sans-serif; --cc-font-body: "CC DM Sans", "CC DM Sans Fallback", Arial, sans-serif; --cc-heading-variation: normal; } +[data-cc-fonts="friendly"] { --cc-font-heading: "CC Nunito", "CC Nunito Fallback", Arial, sans-serif; --cc-font-body: "CC Nunito", "CC Nunito Fallback", Arial, sans-serif; --cc-heading-variation: normal; } +[data-cc-fonts="warm"] { --cc-font-heading: "CC Fraunces", "CC Fraunces Fallback", Georgia, serif; --cc-font-body: "CC Nunito Sans", "CC Nunito Sans Fallback", Arial, sans-serif; --cc-heading-variation: "SOFT" 100, "WONK" 0; } +[data-cc-fonts="modern"] { --cc-font-heading: "CC Inter", "CC Inter Fallback", Arial, sans-serif; --cc-font-body: "CC Inter", "CC Inter Fallback", Arial, sans-serif; --cc-heading-variation: normal; } +[data-cc-corners="sharp"] { --cc-radius: 0; --cc-radius-sm: 0; --cc-radius-button: 0; } +[data-cc-corners="soft"] { --cc-radius: 1rem; --cc-radius-sm: 0.5rem; --cc-radius-button: 0.5rem; } +[data-cc-corners="round"] { --cc-radius: 1.25rem; --cc-radius-sm: 0.75rem; --cc-radius-button: 9999px; } diff --git a/packages/ui/package.json b/packages/ui/package.json index 77fb520..2fb5eb0 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -1,11 +1,42 @@ { "name": "@crosscode/ui", - "version": "0.1.0", + "version": "0.2.0", "private": true, - "description": "Shared UI for the church's sign-in pages, Website and App: the branded shell, forms and buttons (Tailwind; apps compile the source with transpilePackages)", + "description": "Shared UI for the church's sign-in pages, Website and App: the branded shell, forms and buttons, the church's fonts and footer (Tailwind; apps compile the source with transpilePackages)", "main": "src/index.tsx", "types": "src/index.tsx", + "exports": { + ".": "./src/index.tsx", + "./fonts.css": "./fonts/fonts.css", + "./package.json": "./package.json" + }, + "files": [ + "src", + "fonts" + ], + "scripts": { + "fonts": "node scripts/fonts.mjs", + "test": "node scripts/fonts.mjs --check" + }, "peerDependencies": { "react": ">=19" + }, + "dependencies": { + "@fontsource-variable/dm-sans": "5.3.0", + "@fontsource-variable/eb-garamond": "5.3.0", + "@fontsource-variable/fraunces": "5.3.0", + "@fontsource-variable/inter": "5.3.0", + "@fontsource-variable/lora": "5.3.0", + "@fontsource-variable/nunito": "5.3.0", + "@fontsource-variable/nunito-sans": "5.3.0", + "@fontsource-variable/oswald": "5.3.0", + "@fontsource-variable/outfit": "5.3.0", + "@fontsource-variable/playfair-display": "5.3.0", + "@fontsource-variable/source-sans-3": "5.3.1" + }, + "devDependencies": { + "@crosscode/contracts": "*", + "@capsizecss/core": "4.1.3", + "@capsizecss/metrics": "4.5.0" } } diff --git a/packages/ui/scripts/fonts.mjs b/packages/ui/scripts/fonts.mjs new file mode 100644 index 0000000..d198f6f --- /dev/null +++ b/packages/ui/scripts/fonts.mjs @@ -0,0 +1,141 @@ +// Builds the church fonts (WEBSITE-1.0-PLAN §3 "Font pairings", contracts FONT_PAIRINGS) into +// packages/ui/fonts/: the woff2 files each pairing needs (Latin and Latin Extended only) copied +// from the pinned @fontsource-variable packages, and fonts.css with +// - an @font-face per file (unicode-range from Fontsource, so a page only downloads what it uses), +// - a size-matched fallback face per font (Capsize metrics on Arial or Georgia), so the swap +// from the fallback to the font doesn't move the layout, +// - [data-cc-fonts=""] → --cc-font-heading / --cc-font-body / --cc-heading-variation (for +// Fraunces's soft axis: apply it as font-variation-settings on headings), and +// - [data-cc-corners=""] → --cc-radius (and --cc-radius-sm, --cc-radius-button). +// +// node scripts/fonts.mjs write fonts/ +// node scripts/fonts.mjs --check fail if fonts/ is out of date (run by `npm test`) +// +// The output is committed, so the apps' builds don't depend on this script or Capsize. +import fs from "node:fs"; +import process from "node:process"; +import { Buffer } from "node:buffer"; +import console from "node:console"; +import path from "node:path"; +import { createRequire } from "node:module"; +import { fileURLToPath } from "node:url"; +import { createFontStack } from "@capsizecss/core"; +import { CORNERS, FONT_PAIRINGS } from "@crosscode/contracts"; + +const require = createRequire(import.meta.url); +const here = path.dirname(fileURLToPath(import.meta.url)); +const OUT = path.join(here, "..", "fonts"); +const SUBSETS = ["latin-ext", "latin"]; // Fontsource's order: the later block wins where ranges overlap. +const BUDGET = 160 * 1024; // per pairing, for an English page (Latin): heading + body + body italic. + +const slug = (family) => family.toLowerCase().replace(/\s+/g, "-"); +const camel = (family) => slug(family).replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase()); +const cssName = (family) => `CC ${family}`; +/** Fonts that use another Fontsource axis file than plain weight, and the setting that turns it on. */ +const AXES = { Fraunces: { file: "soft", variation: '"SOFT" 100, "WONK" 0' } }; +const metrics = (name) => require(`@capsizecss/metrics/${name}`).default ?? require(`@capsizecss/metrics/${name}`); + +/** family → { category, styles } from the pairings: body fonts need italic, headings don't. */ +function families() { + const out = new Map(); + for (const p of Object.values(FONT_PAIRINGS)) { + for (const [role, face] of [["heading", p.heading], ["body", p.body]]) { + const f = out.get(face.family) ?? { category: face.category, styles: new Set(["normal"]) }; + if (role === "body") f.styles.add("italic"); + out.set(face.family, f); + } + } + return out; +} + +/** The @font-face blocks Fontsource has for a family's style, by subset. */ +function fontsourceFaces(family, style) { + const pkg = path.dirname(require.resolve(`@fontsource-variable/${slug(family)}/package.json`)); + const axis = AXES[family]?.file ?? "wght"; + const css = fs.readFileSync(path.join(pkg, style === "italic" ? `${axis}-italic.css` : `${axis}.css`), "utf8"); + const faces = {}; + for (const m of css.matchAll(/\/\* ([a-z0-9-]+) \*\/\s*@font-face \{([^}]*)\}/g)) { + const subset = SUBSETS.find((s) => m[1] === `${slug(family)}-${s}-${axis}-${style}`); + if (!subset) continue; + const body = m[2]; + faces[subset] = { + weight: /font-weight:\s*([^;]+);/.exec(body)[1].trim(), + range: /unicode-range:\s*([^;]+);/.exec(body)[1].trim(), + file: path.join(pkg, "files", `${m[1]}.woff2`), + }; + } + for (const s of SUBSETS) if (!faces[s]) throw new Error(`${family} ${style}: no ${s} face in Fontsource`); + return faces; +} + +const fallbackFor = (category) => (category === "serif" ? { name: "Georgia", metrics: metrics("georgia"), generic: "serif" } : { name: "Arial", metrics: metrics("arial"), generic: "sans-serif" }); + +export function build() { + const files = new Map(); // name in fonts/files → source path + const css = [ + "/* Generated by packages/ui/scripts/fonts.mjs from @fontsource-variable (SIL Open Font License 1.1,", + " see fonts/LICENSES.md) and Capsize metrics. Don't edit: run `npm run fonts -w packages/ui`. */", + "", + ]; + const stacks = {}; + const sizes = {}; + for (const [family, f] of families()) { + for (const style of f.styles) { + for (const [subset, face] of Object.entries(fontsourceFaces(family, style))) { + const name = path.basename(face.file); + files.set(name, face.file); + if (subset === "latin") sizes[`${family}/${style}`] = fs.statSync(face.file).size; + css.push(`@font-face { font-family: '${cssName(family)}'; font-style: ${style}; font-display: swap; font-weight: ${face.weight}; src: url(./files/${name}) format('woff2-variations'), url(./files/${name}) format('woff2'); unicode-range: ${face.range}; }`); + } + } + const fb = fallbackFor(f.category); + const own = { ...metrics(camel(family)), familyName: cssName(family) }; + const { fontFamily, fontFaces } = createFontStack([own, fb.metrics], { fontFaceFormat: "styleString" }); + css.push(fontFaces.replace(/\s+/g, " ").replace(/\} ?@/g, "}\n@").trim()); + stacks[family] = `${fontFamily}, ${fb.generic}`; + } + css.push(""); + for (const [id, p] of Object.entries(FONT_PAIRINGS)) { + css.push(`[data-cc-fonts="${id}"] { --cc-font-heading: ${stacks[p.heading.family]}; --cc-font-body: ${stacks[p.body.family]}; --cc-heading-variation: ${AXES[p.heading.family]?.variation ?? "normal"}; }`); + const used = new Set([`${p.heading.family}/normal`, `${p.body.family}/normal`, `${p.body.family}/italic`]); + const total = [...used].reduce((n, k) => n + sizes[k], 0); + if (total > BUDGET) throw new Error(`${id} needs ${Math.round(total / 1024)} KB of fonts for an English page; the budget is ${BUDGET / 1024} KB`); + } + const RADII = { sharp: ["0", "0", "0"], soft: ["1rem", "0.5rem", "0.5rem"], round: ["1.25rem", "0.75rem", "9999px"] }; + if (Object.keys(RADII).join() !== CORNERS.join()) throw new Error("A corner style without a radius"); + for (const [id, [r, sm, button]] of Object.entries(RADII)) css.push(`[data-cc-corners="${id}"] { --cc-radius: ${r}; --cc-radius-sm: ${sm}; --cc-radius-button: ${button}; }`); + return { css: css.join("\n") + "\n", files }; +} + +const LICENCES = (families) => `# Font licences + +Every font in \`files/\` is from the [Fontsource](https://fontsource.org) packages pinned in +\`packages/ui/package.json\` and is licensed under the **SIL Open Font License 1.1**: free to use, +bundle and self-host, not to be sold on its own. Each package's \`LICENSE\` has the full text and the +copyright holders. + +${[...families].map((f) => `- ${f}: \`@fontsource-variable/${slug(f)}\``).join("\n")} +`; + +const isMain = process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url); +if (isMain) { + const check = process.argv.includes("--check"); + const { css, files } = build(); + const want = new Map([["fonts.css", Buffer.from(css)], ["LICENSES.md", Buffer.from(LICENCES(families().keys()))]]); + for (const [name, src] of files) want.set(`files/${name}`, fs.readFileSync(src)); + const have = fs.existsSync(OUT) ? fs.readdirSync(OUT, { recursive: true }).map(String).map((p) => p.replace(/\\/g, "/")).filter((p) => fs.statSync(path.join(OUT, p)).isFile()) : []; + const stale = [...want].filter(([p, buf]) => !fs.existsSync(path.join(OUT, p)) || !fs.readFileSync(path.join(OUT, p)).equals(buf)).map(([p]) => p); + const extra = have.filter((p) => !want.has(p)); + if (check) { + if (stale.length || extra.length) { + console.error(`fonts/ is out of date (${[...stale, ...extra].slice(0, 5).join(", ")}): run \`npm run fonts -w packages/ui\``); + process.exit(1); + } + console.log(`fonts/ is up to date (${files.size} font files)`); + } else { + fs.mkdirSync(path.join(OUT, "files"), { recursive: true }); + for (const p of extra) fs.rmSync(path.join(OUT, p)); + for (const [p, buf] of want) fs.writeFileSync(path.join(OUT, p), buf); + console.log(`Wrote fonts/ (${files.size} font files)`); + } +} diff --git a/packages/ui/src/brand.tsx b/packages/ui/src/brand.tsx new file mode 100644 index 0000000..60500cf --- /dev/null +++ b/packages/ui/src/brand.tsx @@ -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 ``. 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. + */ +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 ( +
+
+
+ {church.branding.logoUrl + ? {church.name} + :

{church.name}

} + {address && ( +
+ {address.line1}{address.line2 && <>, {address.line2}}
+ {[address.suburb, address.city, address.postalCode].filter(Boolean).join(", ")} +
+ )} +
+ {times.length > 0 && ( +
+

Service times

+
    + {times.map((t, i) =>
  • {DAYS[t.day] ?? t.day} {t.time}{t.label && · {t.label}}
  • )} +
+
+ )} + {contact && (contact.email || contact.phone || contact.whatsapp || social.length > 0) && ( +
+

Contact

+ +
+ )} + {(sites.length > 0 || privacyUrl) && ( + + )} +
+

© {new Date().getFullYear()} {church.name}

+
+ ); +} diff --git a/packages/ui/src/index.tsx b/packages/ui/src/index.tsx index bd7fc14..4482bd1 100644 --- a/packages/ui/src/index.tsx +++ b/packages/ui/src/index.tsx @@ -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 ; - return {(branding.shortName || branding.name || "?").trim().charAt(0).toUpperCase()}; + if (branding.logoUrl) return ; + return {(branding.shortName || branding.name || "?").trim().charAt(0).toUpperCase()}; } /** @@ -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 (
- {branding.name} + {branding.name} {aside &&
{aside}
}
{children}
-
- {branding.name} · your church account, for all its sites and apps -
+ {footer ?? ( +
+ {branding.name} · your church account, for all its sites and apps +
+ )}
); } export function Card({ children, className }: { children: React.ReactNode; className?: string }) { - return
{children}
; + return
{children}
; } /** 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 (
- {icon && {icon}} + {icon && {icon}}
-

{children}

+

{children}

{sub &&

{sub}

}
@@ -66,7 +71,7 @@ export function Button({ variant = "primary", busy, className, children, disable link: "text-brand underline px-0 py-0", }[variant]; return ( - ); @@ -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 &&

{hint}

} @@ -106,5 +111,5 @@ export function Checkbox({ label, hint, ...rest }: React.InputHTMLAttributes{children}
; + return
{children}
; }