events 3.9.0, website 1.9.0, accounts 1.10.0: the church's details from Accounts everywhere

- Events: the Accounts profile's name, logo, icon, colours and contact details win over
  Events' own settings while Accounts is connected (pages, emails, WhatsApp, PDFs); Settings
  shows them read-only with a link to Accounts. The Accounts logo is copied for PDFs (PNG
  and JPEG). Fixes Events keeping its old church after a demo scenario load.
- Website: a background per homepage section in the church's colours; "More info" instead
  of "Register" for events without registration; the shared colour field.
- Accounts: the shared colour field in Church profile.
- @crosscode/ui 0.4.0: ColourField and isHexColour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-01 00:46:39 +02:00
co-authored by Claude Opus 5.5
parent 799c193fe1
commit 8055e1ec62
41 changed files with 843 additions and 120 deletions
+2 -2
View File
@@ -13,7 +13,7 @@ import { Prisma } from '../generated/prisma/client.js';
import { ApiError } from '../http.js';
import { BLOCK_SCHEMAS, isBlockType, rowFraming, SECTION_SCHEMAS } from '../site/sections.js';
import { cleanDesign } from '../site/snapshot.js';
import { BUTTONS, IMAGE_TREATMENTS, isVariant, SECTION_COLOURS, SECTION_TYPES, sectionTypeSchema, SPACINGS, switchTemplate, TEMPLATE_HEADERS, type SectionType } from '../site/variants.js';
import { BUTTONS, IMAGE_TREATMENTS, isVariant, SECTION_BACKGROUNDS, SECTION_COLOURS, SECTION_TYPES, sectionTypeSchema, SPACINGS, switchTemplate, TEMPLATE_HEADERS, type SectionType } from '../site/variants.js';
type Who = { id: string; role: string };
@@ -55,7 +55,7 @@ export async function getDesign(ctx: Ctx) {
const designPatch = z.object({
template: websiteTemplateSchema.optional(),
variants: z.record(z.string(), z.string()).optional(),
home: z.array(z.object({ section: sectionTypeSchema, hidden: z.boolean() })).max(SECTION_TYPES.length).optional(),
home: z.array(z.object({ section: sectionTypeSchema, hidden: z.boolean(), background: z.enum(SECTION_BACKGROUNDS).optional() })).max(SECTION_TYPES.length).optional(),
style: z.object({
sectionColour: z.enum(SECTION_COLOURS).optional(),
spacing: z.enum(SPACINGS).optional(),
+3 -2
View File
@@ -26,7 +26,8 @@ export type SiteEvent = {
/** An outside link for more information or signing up (the Website's own events). */
link: string | null;
from: 'website' | 'events' | 'app';
registration: { status: string; priceFromCents: number | null } | null;
/** From Cross Events: how it's joined (`origin`: register there; `contact`: ask the church; `none`: just come), whether it's open, and from what price. */
registration: { mode: string; status: string; priceFromCents: number | null } | null;
};
export type SiteMessage = {
@@ -147,7 +148,7 @@ async function liveEvents(ctx: Ctx): Promise<SiteEvent[]> {
return [{
title: e.title, summary: e.summary ?? null, startsAt: e.startsAt, endsAt: e.endsAt ?? null, allDay: !!e.allDay, location: e.location?.name ?? null,
image: e.imageUrl ? { url: e.imageUrl, alt: e.title, width: null, height: null } : null, url: e.origin.url, slug: null, link: null, from: e.origin.product,
registration: e.registration ? { status: e.registration.status, priceFromCents: e.registration.priceFrom?.amountCents ?? null } : null,
registration: e.registration ? { mode: e.registration.mode, status: e.registration.status, priceFromCents: e.registration.priceFrom?.amountCents ?? null } : null,
} satisfies SiteEvent];
});
return [...own, ...copies].sort((a, b) => a.startsAt.localeCompare(b.startsAt));
+9 -4
View File
@@ -11,7 +11,7 @@ import { WEBSITE_TEMPLATES, type WebsiteTemplate } from '@crosscode/contracts';
import type { Ctx } from '../context.js';
import { audit } from '../lib/audit.js';
import { parseSectionData } from './sections.js';
import { defaultDesign, isVariant, SECTION_TYPES, switchTemplate, type SectionType, type SiteDesign } from './variants.js';
import { defaultDesign, isVariant, SECTION_BACKGROUNDS, SECTION_TYPES, switchTemplate, type SectionBackground, type SectionType, type SiteDesign } from './variants.js';
export const SNAPSHOT_VERSION = 1;
@@ -34,7 +34,8 @@ export const framed = (img: Image | null, f: unknown): Image | null => {
type MediaRow = { id: string; filename: string; alt: string; width: number | null; height: number | null; sizes?: unknown };
export type SnapshotSection = { type: string; variant: string | null; data: Record<string, unknown> };
/** `background`: a homepage section's own background (variants.ts SECTION_BACKGROUNDS), when it has one. */
export type SnapshotSection = { type: string; variant: string | null; data: Record<string, unknown>; background?: SectionBackground };
export type SnapshotPage = {
kind: string;
@@ -87,7 +88,11 @@ export function cleanDesign(saved: { template: string; variants: unknown; home:
const v = (saved.variants ?? {}) as Record<string, unknown>;
for (const s of SECTION_TYPES) if (typeof v[s] === 'string' && isVariant(s, v[s] as string)) variants[s] = v[s] as string;
const home = Array.isArray(saved.home)
? (saved.home as { section?: unknown; hidden?: unknown }[]).filter((e) => SECTION_TYPES.includes(e?.section as SectionType)).map((e) => ({ section: e.section as SectionType, hidden: !!e.hidden }))
? (saved.home as { section?: unknown; hidden?: unknown; background?: unknown }[]).filter((e) => SECTION_TYPES.includes(e?.section as SectionType)).map((e) => ({
section: e.section as SectionType,
hidden: !!e.hidden,
...((SECTION_BACKGROUNDS as readonly unknown[]).includes(e.background) ? { background: e.background as SectionBackground } : {}),
}))
: base.home;
// Every section listed once: any missing one is added at the end, hidden.
for (const s of SECTION_TYPES) if (!home.some((e) => e.section === s)) home.push({ section: s, hidden: true });
@@ -176,7 +181,7 @@ export function snapshotFrom(source: Source, media: MediaRow[]): Snapshot {
const data = parseSectionData(entry.section, byType.get(entry.section)?.data);
if (!data) continue;
collect(data);
sections.push({ type: entry.section, variant: d.variants[entry.section], data });
sections.push({ type: entry.section, variant: d.variants[entry.section], data, ...(entry.background ? { background: entry.background } : {}) });
}
} else {
for (const x of p.sections) {
+18 -3
View File
@@ -104,8 +104,18 @@ export function headerIsTransparent(template: WebsiteTemplate, header: string, h
return template === 'bold' && header === 'transparent' && heroVariant !== null && ['photo', 'video', 'collage'].includes(heroVariant);
}
/** A homepage entry: the section and whether it shows. */
export type HomeEntry = { section: SectionType; hidden: boolean };
/**
* A homepage section's own background: always from the church's colours, so it stays on brand.
* Left out, the section follows the site's Section colour (style). `light` is plain white; `tint`
* and `accent` are soft washes of the main and accent colours; `brand` is the main colour itself and
* `dark` a deep shade of it, both with light text. A layout with its own background (a photo, a
* band) keeps it.
*/
export const SECTION_BACKGROUNDS = ['light', 'tint', 'accent', 'brand', 'dark'] as const;
export type SectionBackground = (typeof SECTION_BACKGROUNDS)[number];
/** A homepage entry: the section, whether it shows, and its own background when it has one. */
export type HomeEntry = { section: SectionType; hidden: boolean; background?: SectionBackground };
const order = (shown: SectionType[], hidden: SectionType[] = []): HomeEntry[] => [
...shown.map((section) => ({ section, hidden: false })),
@@ -184,7 +194,12 @@ export function switchTemplate(current: SiteDesign, to: WebsiteTemplate): { desi
}
const homeUntouched = sameOrder(current.home, TEMPLATE_HOME_ORDER[from]);
const home = homeUntouched ? target.home : current.home.map((e) => ({ ...e }));
// The order may move to the new template's; each section keeps the background it was given.
const backgrounds = new Map(current.home.flatMap((e) => (e.background ? [[e.section, e.background] as const] : [])));
const home = (homeUntouched ? target.home : current.home).map(({ background: _b, ...e }) => {
const background = backgrounds.get(e.section);
return background ? { ...e, background } : e;
});
if (homeUntouched && !sameOrder(current.home, target.home)) changes.push({ what: 'home', from: `${from} order`, to: `${to} order` });
const style = { ...current.style };