website 1.11.0: layouts and backgrounds for the blocks; a video for the top of the page

- Blocks get layouts (BLOCK_VARIANTS: text standard/centred; image and text photo left,
  right or above; quote centred/with a line; call to action centred/banner), stored on
  Section.variant and checked against the type; an unknown one draws as the default, as
  every block looked before. The demo's image-text block id is now image-left.
- Each block has its own background (Section.background, migration
  20261201000000_block_background), in the published source only when set, put back by
  Discard and Restore, drawn as the homepage's (data-bg).
- MP4 uploads up to 20 MB for the hero's Video layout: QuickTime refused, metadata boxes
  (udta, meta, uuid) blanked into free boxes of the same size so where it was filmed is
  gone and the frame offsets hold; size read from tkhd. GET /media lists mime.
- Admin: a block's Layout and Background when open; the hero's Video field (only videos;
  photo fields only photos); the media library shows and takes videos. An upload over the
  limit says so instead of "That request isn't valid."
- Tests: backend (152, three new); e2e for block layouts and a video upload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-01 09:57:02 +02:00
co-authored by Claude Opus 5.5
parent a38468ba47
commit f5f778f0d7
28 changed files with 543 additions and 69 deletions
+4 -1
View File
@@ -17,7 +17,7 @@ import { Btn, Field, inputClass } from "./ui";
type Spec = { layouts?: string[] } & (
| { key: string; kind: "text" | "textarea"; label: string; hint?: string; max?: number }
| { key: string; kind: "number"; label: string; min: number; max: number }
| { key: string; kind: "image"; label: string }
| { key: string; kind: "image" | "video"; label: string }
| { key: string; kind: "images"; label: string; max: number; count?: Record<string, number>; labels?: Record<string, string> }
| { key: string; kind: "button"; label: string }
| { key: string; kind: "group"; label: string; fields: Spec[] });
@@ -29,6 +29,7 @@ export const SECTION_FIELDS: Record<string, { name: string; fields: Spec[] }> =
hero: { name: "Top of the page (hero)", fields: [
{ key: "headline", kind: "text", label: "Headline", max: 120 },
{ key: "subline", kind: "textarea", label: "Under the headline", max: 300 },
{ key: "videoId", kind: "video", label: "Video (plays muted, on a loop)", layouts: ["video"] },
// As site/sections/Hero.tsx draws them: Photo, Video (its still) and Split one, Collage three.
{ key: "images", kind: "images", label: "Photos", max: 3, count: { photo: 1, video: 1, split: 1, collage: 3, text: 0 },
labels: { photo: "Photo", video: "Still photo (shown before the video plays, and on phones)", split: "Photo (beside the headline)", collage: "Photos (three, for the collage)" } },
@@ -83,6 +84,8 @@ export function DataForm({ fields, value, onChange, errors, prefix = "", frame,
return <Field key={f.key} label={f.label} hint={f.hint} error={err}><textarea className={inputClass} rows={f.key === "body" ? 6 : 3} value={(v as string) ?? ""} maxLength={f.max} onChange={(e) => set(f.key, e.target.value || (f.key === "body" ? "" : null))} /></Field>;
case "number":
return <Field key={f.key} label={f.label} error={err}><input type="number" className={`${inputClass} w-24`} min={f.min} max={f.max} value={(v as number) ?? f.min} onChange={(e) => set(f.key, Number(e.target.value))} /></Field>;
case "video":
return <div key={f.key}><ImagePicker kind="video" label={f.label} value={(v as string) ?? null} onChange={(id) => set(f.key, id)} />{err && <p className="text-xs text-red-700">{err}</p>}</div>;
case "image":
return <div key={f.key}><ImagePicker label={f.label} slot={{ key: f.key }} value={(v as string) ?? null} onChange={(id) => set(f.key, id)} />{err && <p className="text-xs text-red-700">{err}</p>}</div>;
case "images": {
@@ -53,6 +53,8 @@ export function frameFor(design: Design, type: string, key: string, index = 0):
}
if (type === "event") return { ratio: 16 / 10, label: "On the event's card (a little taller on its own page)" };
if (type === "invitation") return { ratio: 3, label: "Behind the invitation, darkened (the Image background layout)" };
// A block's own layout (passed in as the design's variant for its type).
if (type === "image-text" && v === "image-above") return { ratio: 16 / 9, label: "Above the text, the page's full width" };
return { ratio: 4 / 3, label: "Beside the text" };
}
@@ -31,6 +31,20 @@ export function layoutsFor(design: Design, options: DesignOptions | undefined, s
return { ordered: [...recommended, ...(ALL_VARIANTS[section] ?? []).filter((v) => !recommended.includes(v))], recommended };
}
/** The other pages' blocks' layouts, the default first (backend variants.ts BLOCK_VARIANTS). */
export const BLOCK_LAYOUTS: Record<string, { id: string; name: string }[]> = {
text: [{ id: "standard", name: "Standard" }, { id: "centred", name: "Centred" }],
"image-text": [{ id: "image-left", name: "Photo on the left" }, { id: "image-right", name: "Photo on the right" }, { id: "image-above", name: "Photo above" }],
quote: [{ id: "centred", name: "Centred" }, { id: "line", name: "With a line" }],
cta: [{ id: "centred", name: "Centred" }, { id: "banner", name: "Banner in your colour" }],
};
/** A block's layout as the site draws it: its own when it's one of its type's, else the default. */
export function blockLayout(type: string, variant: string | null): string | undefined {
const list = BLOCK_LAYOUTS[type];
return list?.some((l) => l.id === variant) ? variant! : list?.[0]?.id;
}
/** A section's own background (backend variants.ts SECTION_BACKGROUNDS), each from the church's colours; "" follows Style → Section colour. */
export const BACKGROUNDS: { id: string; name: string; swatch: string }[] = [
{ id: "", name: "As the style sets it", swatch: "repeating-linear-gradient(45deg, #fff 0 4px, rgb(var(--brand-tint)) 4px 8px)" },
+42 -18
View File
@@ -7,7 +7,7 @@ import { api } from "./api";
import { Framed, FramingDialog, useFraming } from "./framing";
import { Btn, cx, Field, inputClass, Notice, useAction, useAdmin } from "./ui";
export type MediaItem = { id: string; url: string; alt: string; width: number | null; height: number | null; bytes: number; usedIn?: string[] };
export type MediaItem = { id: string; url: string; mime?: string; alt: string; width: number | null; height: number | null; bytes: number; usedIn?: string[] };
export type Storage = { usedBytes: number; limitBytes: number; full: boolean; percent: number };
export const gb = (n: number) => `${(n / 1024 ** 3).toFixed(n < 1024 ** 3 ? 2 : 1)} GB`;
@@ -23,15 +23,28 @@ export function StorageMeter({ s }: { s: Storage }) {
);
}
/** Upload form: a photo and what it shows (alt text is required, §3 "Every image needs alt text"). */
export function Uploader({ onUploaded, disabled }: { onUploaded: (m: MediaItem) => void; disabled?: boolean }) {
/** What a picker or upload takes: photos, a video (MP4, for the top of the page's Video layout), or either (the library). */
export type MediaKind = "image" | "video" | "any";
/** Whether a library item is a video (by its type; items listed before videos existed are photos). */
export const isVideo = (m: Pick<MediaItem, "mime">) => !!m.mime?.startsWith("video/");
const UPLOAD = {
image: { label: "Photo", accept: "image/jpeg,image/png,image/webp", hint: "JPEG, PNG or WebP, up to 15 MB. Landscape photos of people work best for the top of a page.", noun: "photo" },
video: { label: "Video", accept: "video/mp4", hint: "MP4, up to 20 MB. A short, quiet clip (10 to 20 seconds) works best: it plays muted, on a loop.", noun: "video" },
any: { label: "Photo or video", accept: "image/jpeg,image/png,image/webp,video/mp4", hint: "Photos as JPEG, PNG or WebP, up to 15 MB; a video for the top of the page as MP4, up to 20 MB.", noun: "file" },
} as const;
/** Upload form: a photo or video and what it shows (alt text is required, §3 "Every image needs alt text"). */
export function Uploader({ onUploaded, disabled, kind = "image" }: { onUploaded: (m: MediaItem) => void; disabled?: boolean; kind?: MediaKind }) {
const file = useRef<HTMLInputElement>(null);
const [alt, setAlt] = useState("");
const { busy, message, run } = useAction();
const u = UPLOAD[kind];
const go = () => run(async () => {
const f = file.current?.files?.[0];
if (!f) throw new Error("Choose a photo first.");
if (!alt.trim()) throw new Error("Say what the photo shows (for people who can't see it).");
if (!f) throw new Error(`Choose a ${u.noun} first.`);
if (!alt.trim()) throw new Error(`Say what the ${u.noun === "file" ? "photo or video" : u.noun} shows (for people who can't see it).`);
const m = await api<MediaItem & { filename: string }>(`/media?alt=${encodeURIComponent(alt.trim())}`, { raw: f });
setAlt("");
if (file.current) file.current.value = "";
@@ -39,10 +52,10 @@ export function Uploader({ onUploaded, disabled }: { onUploaded: (m: MediaItem)
}, "Uploaded.");
return (
<div className="space-y-3">
<Field label="Photo" hint="JPEG, PNG or WebP, up to 15 MB. Landscape photos of people work best for the top of a page.">
<input ref={file} type="file" accept="image/jpeg,image/png,image/webp" className="block text-sm" disabled={disabled} />
<Field label={u.label} hint={u.hint}>
<input ref={file} type="file" accept={u.accept} className="block text-sm" disabled={disabled} />
</Field>
<Field label="What the photo shows" hint="Read out to people who can't see it, e.g. “Families at the church picnic”.">
<Field label={kind === "video" ? "What the video shows" : "What the photo shows"} hint="Read out to people who can't see it, e.g. “Families at the church picnic”.">
<input className={inputClass} value={alt} onChange={(e) => setAlt(e.target.value)} maxLength={500} disabled={disabled} />
</Field>
<Btn kind="primary" onClick={go} busy={busy} disabled={disabled}>Upload</Btn>
@@ -51,17 +64,27 @@ export function Uploader({ onUploaded, disabled }: { onUploaded: (m: MediaItem)
);
}
/** A library item small: the photo, or the video's first frame (muted, never playing). */
export function MediaThumb({ m, className, alt = m.alt }: { m: MediaItem; className?: string; alt?: string }) {
return isVideo(m)
? <video src={`${m.url}#t=0.1`} muted playsInline preload="metadata" aria-label={alt || undefined} className={className} />
: <img src={m.url} alt={alt} className={className} />;
}
/**
* One image field: shows the chosen image, with Choose and Remove. In a section (`slot` and a
* FramingContext), it's shown in the shape of its frame on the site, with Move and zoom.
* One image field (or, with `kind="video"`, a video field): shows the chosen one, with Choose and
* Remove, and only offers its kind from the library. In a section (`slot` and a FramingContext), a
* photo is shown in the shape of its frame on the site, with Move and zoom.
*/
export function ImagePicker({ value, onChange, label, slot }: { value: string | null; onChange: (id: string | null) => void; label: string; slot?: { key: string; index?: number } }) {
export function ImagePicker({ value, onChange, label, slot, kind = "image" }: { value: string | null; onChange: (id: string | null) => void; label: string; slot?: { key: string; index?: number }; kind?: "image" | "video" }) {
const [open, setOpen] = useState(false);
const [framingOpen, setFramingOpen] = useState(false);
const { data, reload } = useAdmin<{ storage: Storage; items: MediaItem[] }>(open || value ? "/media" : null);
const chosen = data?.items.find((m) => m.id === value);
const framing = useFraming();
const frame = framing && slot ? framing.frame(slot.key, slot.index) : null;
const frame = framing && slot && kind === "image" ? framing.frame(slot.key, slot.index) : null;
const items = data?.items.filter((m) => isVideo(m) === (kind === "video"));
const noun = kind === "video" ? "video" : "image";
const focus = value ? framing?.get(value) : undefined;
return (
<div>
@@ -74,7 +97,7 @@ export function ImagePicker({ value, onChange, label, slot }: { value: string |
</button>
) : (
<div className="h-16 w-24 shrink-0 overflow-hidden rounded border border-gray-200 bg-gray-50">
{chosen ? <img src={chosen.url} alt={chosen.alt} className="h-full w-full object-cover" /> : <span className="flex h-full items-center justify-center text-xs text-gray-600">No image</span>}
{chosen ? <MediaThumb m={chosen} className="h-full w-full object-cover" /> : <span className="flex h-full items-center justify-center text-xs text-gray-600">No {noun}</span>}
</div>
)}
<Btn onClick={() => setOpen(true)}>{value ? "Change" : "Choose"}</Btn>
@@ -87,17 +110,18 @@ export function ImagePicker({ value, onChange, label, slot }: { value: string |
onDone={(f) => { framing.set(chosen.id, f); setFramingOpen(false); }} onClose={() => setFramingOpen(false)} />
)}
{open && (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4" role="dialog" aria-modal="true" aria-label="Choose an image">
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4" role="dialog" aria-modal="true" aria-label={`Choose ${kind === "video" ? "a video" : "an image"}`}>
<div className="max-h-[90vh] w-full max-w-3xl overflow-y-auto rounded-lg bg-white p-6 shadow-xl">
<div className="mb-4 flex items-center justify-between">
<h2 className="text-lg font-semibold">Choose an image</h2>
<h2 className="text-lg font-semibold">Choose {kind === "video" ? "a video" : "an image"}</h2>
<Btn onClick={() => setOpen(false)}>Close</Btn>
</div>
<div className="grid grid-cols-3 gap-3 sm:grid-cols-4">
{data?.items.map((m) => (
{items?.length === 0 && <p className="col-span-full text-sm text-gray-600">No {noun}s in your library yet: upload one below.</p>}
{items?.map((m) => (
<button key={m.id} type="button" onClick={() => { onChange(m.id); setOpen(false); }}
className={cx("overflow-hidden rounded border-2 text-left", m.id === value ? "border-brand" : "border-transparent hover:border-gray-300")}>
<img src={m.url} alt="" className="aspect-[4/3] w-full object-cover" />
<MediaThumb m={m} alt="" className="aspect-[4/3] w-full object-cover" />
<span className="block truncate p-1 text-xs text-gray-600">{m.alt || "No description"}</span>
</button>
))}
@@ -105,7 +129,7 @@ export function ImagePicker({ value, onChange, label, slot }: { value: string |
<div className="mt-6 border-t border-gray-200 pt-4">
<h3 className="mb-2 font-semibold">Upload a new one</h3>
{data?.storage.full && <Notice tone="warning">Your storage is full, so uploads have stopped. An Owner or Admin can get more under Media library.</Notice>}
<Uploader disabled={data?.storage.full} onUploaded={(m) => { reload(); onChange(m.id); setOpen(false); }} />
<Uploader kind={kind} disabled={data?.storage.full} onUploaded={(m) => { reload(); onChange(m.id); setOpen(false); }} />
</div>
</div>
</div>
@@ -2,7 +2,7 @@
import { useState } from "react";
import { api, canEdit } from "@/admin/api";
import { gb, StorageMeter, Uploader, type MediaItem, type Storage } from "@/admin/media";
import { gb, MediaThumb, StorageMeter, Uploader, type MediaItem, type Storage } from "@/admin/media";
import { Btn, inputClass, Loading, Notice, Panel, Title, useAction, useAdmin, when } from "@/admin/ui";
import { Image as ImageIcon, Trash2 } from "lucide-react";
@@ -19,15 +19,15 @@ export default function Media() {
const s = data.storage;
return (
<>
<Title icon={ImageIcon} sub="Photos for your pages. Sermon audio and video are linked (YouTube, Spotify), never uploaded.">Media library</Title>
<Title icon={ImageIcon} sub="Photos for your pages, and a short video for the top of your home page. Sermon audio and video are linked (YouTube, Spotify), never uploaded.">Media library</Title>
<div className="grid gap-6 lg:grid-cols-[2fr_1fr]">
<Panel>
{message && <div className="mb-3"><Notice tone={message.tone}>{message.text}</Notice></div>}
{data.items.length === 0 && <p className="text-gray-600">No photos yet.</p>}
{data.items.length === 0 && <p className="text-gray-600">No photos or videos yet.</p>}
<ul className="grid gap-4 sm:grid-cols-2">
{data.items.map((m) => (
<li key={m.id} className="space-y-2">
<img src={m.url} alt={m.alt} className="aspect-[4/3] w-full rounded object-cover" />
<MediaThumb m={m} className="aspect-[4/3] w-full rounded object-cover" />
<label className="block text-xs text-gray-600">What it shows
<input className={inputClass} value={alts[m.id] ?? m.alt} maxLength={500} onChange={(e) => setAlts({ ...alts, [m.id]: e.target.value })} />
</label>
@@ -70,7 +70,7 @@ export default function Media() {
</div>
</Panel>
<Panel title="Upload a photo">
{s.full ? <Notice tone="warning">Uploads have stopped: your storage is full.</Notice> : <Uploader onUploaded={() => reload()} />}
{s.full ? <Notice tone="warning">Uploads have stopped: your storage is full.</Notice> : <Uploader kind="any" onUploaded={() => reload()} />}
</Panel>
</div>
</div>
@@ -18,11 +18,11 @@ import { api } from "@/admin/api";
import { BLOCK_FIELDS, DataForm, SECTION_FIELDS } from "@/admin/fields";
import { frameFor, type Framing } from "@/admin/framing";
import { WithPreview } from "@/admin/LivePreview";
import { BACKGROUNDS, layoutsFor, moved, TEMPLATE_NAMES, VARIANT_NAMES, withBackground, withShown, type Design, type DesignOptions, type HomeEntry } from "@/admin/layouts";
import { BACKGROUNDS, BLOCK_LAYOUTS, blockLayout, layoutsFor, moved, TEMPLATE_NAMES, VARIANT_NAMES, withBackground, withShown, type Design, type DesignOptions, type HomeEntry } from "@/admin/layouts";
import { ImagePicker } from "@/admin/media";
import { Btn, cx, Field, inputClass, Loading, Notice, Panel, Tabs, Title, useAction, useAdmin } from "@/admin/ui";
type Section = { id: string; type: string; variant: string | null; hidden: boolean; data: Record<string, unknown>; updatedAt: string };
type Section = { id: string; type: string; variant: string | null; hidden: boolean; background: string | null; data: Record<string, unknown>; updatedAt: string };
type PageData = { id: string; kind: string; slug: string; title: string; seoTitle: string | null; description: string | null; navLabel: string | null; inNav: boolean; imageId: string | null; updatedAt: string; sections: Section[] };
const HOME_ORDER = ["hero", "serviceTimes", "welcome", "ministries", "team", "events", "latestMessage", "invitation"];
@@ -50,11 +50,25 @@ const summary = (data: Record<string, unknown>) => {
return null;
};
function SectionEditor({ type, title, fields, initial, onSave, hidden, extra, frame, layout, settings }: {
/** A section's or block's own background, from the church's colours ("" follows the style). */
function BackgroundField({ name, value, busy, onChange }: { name: string; value: string; busy: boolean; onChange: (background: string) => void }) {
return (
<Field label="Background" hint="From your church's colours. A layout with a photo or band keeps its own.">
<span className="flex items-center gap-2">
<span className="h-9 w-9 shrink-0 rounded border border-gray-300" style={{ background: BACKGROUNDS.find((b) => b.id === value)?.swatch }} aria-hidden />
<select aria-label={`${name}: background`} className={inputClass} value={value} disabled={busy} onChange={(ev) => onChange(ev.target.value)}>
{BACKGROUNDS.map((b) => <option key={b.id} value={b.id}>{b.name}</option>)}
</select>
</span>
</Field>
);
}
function SectionEditor({ type, title, fields, initial, onSave, hidden, extra, frame, layout, layoutName, settings }: {
type: string; title: string; fields: Parameters<typeof DataForm>[0]["fields"]; initial: Record<string, unknown>; frame?: Framing["frame"];
onSave: (data: Record<string, unknown>) => Promise<unknown>; hidden?: React.ReactNode; extra?: React.ReactNode;
/** A home page section's layout (only its fields are offered) and its layout and background controls. */
layout?: string; settings?: React.ReactNode;
layout?: string; layoutName?: string; settings?: React.ReactNode;
}) {
const [value, setValue] = useState(initial);
const [open, setOpen] = useState(false);
@@ -68,7 +82,7 @@ function SectionEditor({ type, title, fields, initial, onSave, hidden, extra, fr
<span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-brand/10 text-brand-text" aria-hidden><Icon className="h-[18px] w-[18px]" /></span>
<span className="min-w-0 flex-1">
<span className="flex flex-wrap items-center gap-2 font-semibold text-gray-900">{title}{hidden}</span>
<span className="block truncate text-xs text-gray-500">{layout && `${VARIANT_NAMES[layout] ?? layout} · `}{line ?? "Nothing written yet"}</span>
<span className="block truncate text-xs text-gray-500">{layout && `${layoutName ?? VARIANT_NAMES[layout] ?? layout} · `}{line ?? "Nothing written yet"}</span>
</span>
{open ? <ChevronDown className="h-4 w-4 shrink-0 text-gray-400" aria-hidden /> : <ChevronRight className="h-4 w-4 shrink-0 text-gray-400" aria-hidden />}
<span className="sr-only">{open ? "Close" : "Edit"}</span>
@@ -196,16 +210,7 @@ export default function EditPage() {
</select>
</Field>
{/* The top of the page draws its own background (photo, colour or plain). */}
{type !== "hero" && (
<Field label="Background" hint="From your church's colours. A layout with a photo or band keeps its own.">
<span className="flex items-center gap-2">
<span className="h-9 w-9 shrink-0 rounded border border-gray-300" style={{ background: BACKGROUNDS.find((b) => b.id === background)?.swatch }} aria-hidden />
<select aria-label={`${spec.name}: background`} className={inputClass} value={background} disabled={layouts.busy} onChange={(ev) => saveDesign({ home: withBackground(home, type, ev.target.value) })}>
{BACKGROUNDS.map((b) => <option key={b.id} value={b.id}>{b.name}</option>)}
</select>
</span>
</Field>
)}
{type !== "hero" && <BackgroundField name={spec.name} value={background} busy={layouts.busy} onChange={(b) => saveDesign({ home: withBackground(home, type, b) })} />}
</div>
);
return <SectionEditor key={type} type={type} title={spec.name} fields={spec.fields} initial={s?.data ?? {}} frame={(key, n) => frameFor(saved, type, key, n)}
@@ -226,8 +231,25 @@ export default function EditPage() {
{page.sections.map((s, i) => {
const spec = BLOCK_FIELDS[s.type];
if (!spec) return null;
// A block's layout and background are its own (saved on it straight away, like hiding it).
const layout = blockLayout(s.type, s.variant);
const options = BLOCK_LAYOUTS[s.type] ?? [];
const name = `${spec.name} block ${i + 1}`;
const settings = (
<div className="grid gap-4 rounded-lg bg-gray-50 p-3 sm:grid-cols-2">
{options.length > 1 && (
<Field label="Layout">
<select aria-label={`${name}: layout`} className={inputClass} value={layout} disabled={blocks.busy} onChange={(ev) => blockCall(`/blocks/${s.id}`, "PUT", { variant: ev.target.value })}>
{options.map((l) => <option key={l.id} value={l.id}>{l.name}</option>)}
</select>
</Field>
)}
<BackgroundField name={name} value={s.background ?? ""} busy={blocks.busy} onChange={(b) => blockCall(`/blocks/${s.id}`, "PUT", { background: b || null })} />
</div>
);
return (
<SectionEditor key={s.id} type={s.type} title={spec.name} fields={spec.fields} initial={s.data} frame={(key, i) => frameFor(design.data?.design, s.type, key, i)}
<SectionEditor key={s.id} type={s.type} title={spec.name} fields={spec.fields} initial={s.data} layout={layout} layoutName={options.find((l) => l.id === layout)?.name} settings={settings}
frame={(key, n) => frameFor(design.data?.design && { ...design.data.design, variants: { ...design.data.design.variants, [s.type]: layout ?? "" } }, s.type, key, n)}
hidden={s.hidden && <span className="inline-flex items-center gap-1 rounded-full bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-600"><EyeOff className="h-3 w-3" aria-hidden />Hidden</span>}
onSave={async (data) => setData(await api<PageData>(`/pages/${id}/blocks/${s.id}`, { method: "PUT", body: { data, ifUpdatedAt: s.updatedAt } }))}
extra={<>
@@ -430,27 +430,55 @@ function Invitation(p: SectionProps) {
);
}
// ─── Blocks on the other pages ──────────────────────────────────────────────────
// ─── Blocks on the other pages, each in its layouts (backend variants.ts BLOCK_VARIANTS) ──
// Text: Standard · Centred
function TextBlock(p: SectionProps) {
const d = p.section.data as { heading: string | null; body: string };
return <Section p={p}><div className="cc-wrap"><div className="cc-text">{d.heading && <h2 className="cc-h2 mb-6">{d.heading}</h2>}<Paragraphs text={d.body} /></div></div></Section>;
return <Section p={p}><div className="cc-wrap"><div className={cx("cc-text", p.section.variant === "centred" && "text-center")}>{d.heading && <h2 className="cc-h2 mb-6">{d.heading}</h2>}<Paragraphs text={d.body} /></div></div></Section>;
}
// Image and text: Photo on the left · Photo on the right · Photo above
function ImageTextBlock(p: SectionProps) {
const d = p.section.data as { heading: string | null; body: string; imageId: string | null; button: ButtonData };
const image = media(p.site, d.imageId, p.section.data);
const round = p.template === "community" && "rounded-[2rem]";
const words = <>{d.heading && <h2 className="cc-h2 mb-6">{d.heading}</h2>}<Paragraphs text={d.body} /><div className="mt-6"><Button button={d.button} /></div></>;
if (p.section.variant === "image-above") {
return (
<Section p={p}>
<div className="cc-wrap">
<Img image={image} ratio="aspect-[16/9]" sizes="(min-width: 1280px) 1200px, 100vw" className={cx(round)} />
<div className="cc-text mt-10">{words}</div>
</div>
</Section>
);
}
return (
<Section p={p}>
<div className="cc-wrap grid items-center gap-10 md:grid-cols-2">
<Img image={media(p.site, d.imageId, p.section.data)} className={cx(p.template === "community" && "rounded-[2rem]")} />
<div>{d.heading && <h2 className="cc-h2 mb-6">{d.heading}</h2>}<Paragraphs text={d.body} /><div className="mt-6"><Button button={d.button} /></div></div>
<Img image={image} className={cx(round, p.section.variant === "image-right" && "md:order-2")} />
<div>{words}</div>
</div>
</Section>
);
}
// Quote: Centred · With a line
function QuoteBlock(p: SectionProps) {
const d = p.section.data as { quote: string; by: string | null };
if (p.section.variant === "line") {
return (
<Section p={p}>
<div className="cc-wrap">
<figure className="cc-text border-l-4 border-accent pl-6">
<blockquote className="font-heading text-2xl leading-snug sm:text-3xl">“{d.quote}”</blockquote>
{str(d.by) && <figcaption className="cc-muted mt-4">{d.by}</figcaption>}
</figure>
</div>
</Section>
);
}
return (
<Section p={p}>
<figure className="cc-wrap text-center">
@@ -461,8 +489,9 @@ function QuoteBlock(p: SectionProps) {
);
}
// Call to action: Centred · Banner (the invitation's, without a photo)
function CtaBlock(p: SectionProps) {
return <Invitation {...p} section={{ ...p.section, variant: "centred", data: { ...p.section.data, imageId: null } }} />;
return <Invitation {...p} section={{ ...p.section, variant: p.section.variant === "banner" ? "banner" : "centred", data: { ...p.section.data, imageId: null } }} />;
}
const SECTIONS: Record<string, (p: SectionProps) => React.ReactNode> = {