"use client"; /** * Template and style (WEBSITE-1.0-PLAN §3): the template, each homepage section's layout * (recommended first), the homepage order, and the style settings. Fonts and corners are the * church's brand style, shared with its other sites, so they're set in its church profile. */ import { api } from "@/admin/api"; import { Btn, cx, Field, inputClass, Loading, Notice, Panel, Title, useAction, useAdmin } from "@/admin/ui"; type Design = { template: string; variants: Record; home: { section: string; hidden: boolean }[]; style: Record }; type Options = { variants: Record>; headers: Record }; const TEMPLATES = [ { id: "heritage", name: "Heritage", text: "Traditional and dignified: centred, framed images, serif headings." }, { id: "bold", name: "Bold", text: "Modern and energetic: full-screen photos, big headlines, bands." }, { id: "community", name: "Community", text: "Warm and friendly: cards, rounded shapes, faces up front." }, { id: "clean", name: "Clean", text: "Minimal and calm: lots of space, good without photos." }, ]; const SECTIONS: Record = { hero: "Top of the page", serviceTimes: "Service times", welcome: "Welcome", ministries: "Ministries", team: "Team", events: "Upcoming events", latestMessage: "Latest message", invitation: "Invitation" }; const VARIANT_NAMES: Record = { photo: "Photo", video: "Video", collage: "Collage", split: "Split", text: "Text only", panel: "Panel", strip: "Inline strip", map: "With map", "image-text": "Image and text", pastor: "With pastor", cards: "Cards", list: "List", bands: "Alternating bands", faces: "Faces", featured: "Featured", calendar: "Calendar strip", compact: "Compact", banner: "Banner", centred: "Centred", image: "Image background", }; const ALL_VARIANTS: Record = { hero: ["photo", "video", "collage", "split", "text"], serviceTimes: ["panel", "strip", "map"], welcome: ["text", "image-text", "pastor"], ministries: ["cards", "list", "bands"], team: ["faces", "list", "featured"], events: ["cards", "list", "calendar"], latestMessage: ["video", "card", "compact"], invitation: ["banner", "centred", "image"], }; const HEADER_NAMES: Record = { centred: "Centred", "centred-top-bar": "Centred, with a top bar", transparent: "Over the photo, solid when scrolling", solid: "Solid", "logo-left-button": "Logo left, with a Plan your visit button", "logo-left-tinted": "Logo left, on a tinted bar", small: "Small", "small-menu": "Small, menu on every screen", }; const STYLE = [ { key: "sectionColour", label: "Section colour", options: { light: "Light", tinted: "Tinted (your colour, softly)", mixed: "Mixed, with dark bands" } }, { key: "spacing", label: "Spacing", options: { airy: "Airy", compact: "Compact" } }, { key: "buttons", label: "Buttons", options: { solid: "Solid", outline: "Outline", pill: "Pill" } }, { key: "images", label: "Photos", options: { natural: "Natural", mono: "Black and white", duotone: "Duotone in your colour" } }, ]; export default function TemplatePage() { const { data, error, setData } = useAdmin<{ design: Design; options: Options }>("/design"); const { busy, message, run } = useAction(); if (!data) return ; const { design, options } = data; const save = (patch: Partial & { template?: string }, done = "Saved. Preview to see it, then publish.") => run(async () => { const r = await api<{ design: Design; moved: { what: string }[] }>("/design", { method: "PUT", body: patch }); setData({ ...data, design: r.design }); return r; }, done); const move = (i: number, d: -1 | 1) => { const home = [...design.home]; const j = i + d; if (j < 0 || j >= home.length) return; [home[i], home[j]] = [home[j]!, home[i]!]; save({ home }); }; return ( <> Template and style {message &&
{message.text}
}
{TEMPLATES.map((t) => (
{t.name}{t.id === design.template && " (in use)"} {t.text} {t.id !== design.template && (
Preview with your content save({ template: t.id }, `Switched to ${t.name}. Your own choices are kept; the rest moved to ${t.name}'s defaults.`)}>Use {t.name}
)}
))}

Every layout works in every template; the first ones listed suit {TEMPLATES.find((t) => t.id === design.template)?.name} best.

    {design.home.map((e, i) => { const recommended = options.variants[design.template]?.[e.section] ?? []; const ordered = [...recommended, ...ALL_VARIANTS[e.section]!.filter((v) => !recommended.includes(v))]; return (
  • {SECTIONS[e.section]} move(i, -1)} disabled={busy || i === 0} aria-label={`Move ${SECTIONS[e.section]} up`}>↑ move(i, 1)} disabled={busy || i === design.home.length - 1} aria-label={`Move ${SECTIONS[e.section]} down`}>↓
  • ); })}
{STYLE.map((s) => ( ))}

Fonts and corners are your church's brand style, shared with your Events and sign-in pages: change them in your church profile.

); }