Accounts 1.8.0, Website 1.1.0: admins redesigned as Cross Events' dashboard and settings
- Website: an icon sidebar in groups (Your site, Content, Go live, Team), a dashboard with cards and a tile per part of the admin, steps to the first publish across the top of every admin page, and a live preview beside the page editor and Template and style (computer or phone width, folds away, reloads on save). A framed request (Sec-Fetch-Dest: iframe) with an admin session reads the drafts, so no preview cookie is set. /preview/start takes ?to=. The page editor has Content and Page details tabs. - Accounts: /admin is an overview (cards, "Needs you", a tile per section); People moved to /admin/people; the sidebar shows the part you're in, grouped, with a count on Deletion requests; People redesigned, with a confirm before Deactivate; Email and WhatsApp split into two cards. - Both: darker grey labels for contrast; lucide-react in the Website. - e2e: the live preview shows drafts while the site stays live; axe on the page editor. - docs: VERSIONS, changelogs, WHATS-NEW. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,8 +5,12 @@
|
||||
* (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 Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import { ArrowDown, ArrowUp, Check, Eye, LayoutTemplate, ListOrdered, Palette, SlidersHorizontal } from "lucide-react";
|
||||
import { api } from "@/admin/api";
|
||||
import { Btn, cx, Field, inputClass, Loading, Notice, Panel, Title, useAction, useAdmin } from "@/admin/ui";
|
||||
import { WithPreview } from "@/admin/LivePreview";
|
||||
import { Btn, cx, Field, inputClass, Loading, Notice, Panel, Tabs, Title, useAction, useAdmin } from "@/admin/ui";
|
||||
|
||||
type Design = { template: string; variants: Record<string, string>; home: { section: string; hidden: boolean }[]; style: Record<string, string> };
|
||||
type Options = { variants: Record<string, Record<string, string[]>>; headers: Record<string, string[]> };
|
||||
@@ -42,6 +46,7 @@ const STYLE = [
|
||||
export default function TemplatePage() {
|
||||
const { data, error, setData } = useAdmin<{ design: Design; options: Options }>("/design");
|
||||
const { busy, message, run } = useAction();
|
||||
const [tab, setTab] = useState<"template" | "home" | "style">("template");
|
||||
if (!data) return <Loading error={error} />;
|
||||
const { design, options } = data;
|
||||
const save = (patch: Partial<Design> & { template?: string }, done = "Saved. Preview to see it, then publish.") => run(async () => {
|
||||
@@ -57,37 +62,48 @@ export default function TemplatePage() {
|
||||
save({ home });
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<Title sub="Changes here are drafts: preview them, then publish.">Template and style</Title>
|
||||
<WithPreview path="/" version={JSON.stringify(design)}>
|
||||
<Title icon={Palette} sub="How your whole site looks. Changes here are drafts: the preview shows them, then publish.">Template and style</Title>
|
||||
{message && <div className="mb-4"><Notice tone={message.tone}>{message.text}</Notice></div>}
|
||||
<div className="space-y-6">
|
||||
<Panel title="Template">
|
||||
<Tabs label="Template and style" value={tab} onChange={setTab} tabs={[
|
||||
{ id: "template", label: "Template", icon: LayoutTemplate },
|
||||
{ id: "home", label: "Home page layout", icon: ListOrdered },
|
||||
{ id: "style", label: "Style", icon: SlidersHorizontal },
|
||||
]} />
|
||||
|
||||
{tab === "template" && (
|
||||
<Panel title="Template" icon={LayoutTemplate} sub="Your content stays the same whichever you choose; only the look changes.">
|
||||
<div className="grid gap-3 sm:grid-cols-2">
|
||||
{TEMPLATES.map((t) => (
|
||||
<div key={t.id} className={cx("rounded-lg border-2 p-4", t.id === design.template ? "border-brand bg-brand-tint" : "border-gray-200")}>
|
||||
<span className="block font-semibold">{t.name}{t.id === design.template && " (in use)"}</span>
|
||||
<span className="mt-1 block text-sm text-gray-600">{t.text}</span>
|
||||
{t.id !== design.template && (
|
||||
<div className="mt-3 flex flex-wrap gap-2">
|
||||
<a href={`/preview/start?template=${t.id}`} className="rounded-md border border-gray-300 bg-white px-3 py-1.5 text-sm font-semibold hover:bg-gray-50">Preview with your content</a>
|
||||
<Btn busy={busy} onClick={() => save({ template: t.id }, `Switched to ${t.name}. Your own choices are kept; the rest moved to ${t.name}'s defaults.`)}>Use {t.name}</Btn>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
{TEMPLATES.map((t) => {
|
||||
const inUse = t.id === design.template;
|
||||
return (
|
||||
<div key={t.id} className={cx("rounded-xl border-2 p-4", inUse ? "border-brand bg-brand-tint" : "border-gray-200")}>
|
||||
<span className="flex items-center justify-between gap-2 font-semibold">{t.name}{inUse && <span className="inline-flex items-center gap-1 rounded-full bg-brand px-2 py-0.5 text-xs text-brand-on"><Check className="h-3 w-3" aria-hidden />In use</span>}</span>
|
||||
<span className="mt-1 block text-sm text-gray-600">{t.text}</span>
|
||||
{!inUse && (
|
||||
<div className="mt-3 flex flex-wrap gap-2">
|
||||
<a href={`/preview/start?template=${t.id}`} className="inline-flex items-center gap-1.5 rounded-lg border border-gray-300 bg-white px-3 py-1.5 text-sm font-semibold hover:bg-gray-50"><Eye className="h-4 w-4" aria-hidden />Try it with your content</a>
|
||||
<Btn busy={busy} onClick={() => save({ template: t.id }, `Switched to ${t.name}. Your own choices are kept; the rest moved to ${t.name}'s defaults.`)}>Use {t.name}</Btn>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</Panel>
|
||||
)}
|
||||
|
||||
<Panel title="Home page: sections and layouts">
|
||||
<p className="mb-4 text-sm text-gray-600">Every layout works in every template; the first ones listed suit {TEMPLATES.find((t) => t.id === design.template)?.name} best.</p>
|
||||
<ul className="divide-y divide-gray-200">
|
||||
{tab === "home" && (
|
||||
<Panel title="Home page: sections and layouts" icon={ListOrdered} sub={<>Every layout works in every template; the first ones listed suit {TEMPLATES.find((t) => t.id === design.template)?.name} best. What each section says is on the home page, under Pages.</>}>
|
||||
<ul className="divide-y divide-gray-100">
|
||||
{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 (
|
||||
<li key={e.section} className="flex flex-wrap items-center gap-3 py-3">
|
||||
<span className="w-40 font-medium">{SECTIONS[e.section]}</span>
|
||||
<select aria-label={`${SECTIONS[e.section]} layout`} className={`${inputClass} w-56`} value={design.variants[e.section]} disabled={busy}
|
||||
<li key={e.section} className={cx("flex flex-wrap items-center gap-3 py-3", e.hidden && "opacity-60")}>
|
||||
<span className="flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-gray-100 text-xs font-semibold text-gray-600" aria-hidden>{i + 1}</span>
|
||||
<span className="w-36 font-medium">{SECTIONS[e.section]}</span>
|
||||
<select aria-label={`${SECTIONS[e.section]} layout`} className={`${inputClass} w-52`} value={design.variants[e.section]} disabled={busy}
|
||||
onChange={(ev) => save({ variants: { [e.section]: ev.target.value } })}>
|
||||
{ordered.map((v) => <option key={v} value={v}>{VARIANT_NAMES[v]}{recommended.includes(v) ? " (suits this template)" : ""}</option>)}
|
||||
</select>
|
||||
@@ -96,33 +112,35 @@ export default function TemplatePage() {
|
||||
Show
|
||||
</label>
|
||||
<span className="ml-auto flex gap-1">
|
||||
<Btn onClick={() => move(i, -1)} disabled={busy || i === 0} aria-label={`Move ${SECTIONS[e.section]} up`}>↑</Btn>
|
||||
<Btn onClick={() => move(i, 1)} disabled={busy || i === design.home.length - 1} aria-label={`Move ${SECTIONS[e.section]} down`}>↓</Btn>
|
||||
<Btn kind="icon" onClick={() => move(i, -1)} disabled={busy || i === 0} aria-label={`Move ${SECTIONS[e.section]} up`} title="Move up"><ArrowUp className="h-4 w-4" aria-hidden /></Btn>
|
||||
<Btn kind="icon" onClick={() => move(i, 1)} disabled={busy || i === design.home.length - 1} aria-label={`Move ${SECTIONS[e.section]} down`} title="Move down"><ArrowDown className="h-4 w-4" aria-hidden /></Btn>
|
||||
</span>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</Panel>
|
||||
)}
|
||||
|
||||
<Panel title="Style">
|
||||
{tab === "style" && (
|
||||
<Panel title="Style" icon={SlidersHorizontal} sub="The finishing touches, on every page.">
|
||||
<div className="grid gap-4 sm:grid-cols-2">
|
||||
<Field label="Header">
|
||||
<select className={inputClass} value={design.style.header} disabled={busy} onChange={(e) => save({ style: { header: e.target.value } })}>
|
||||
{(options.headers[design.template] ?? []).map((h) => <option key={h} value={h}>{HEADER_NAMES[h] ?? h}</option>)}
|
||||
</select>
|
||||
</Field>
|
||||
{STYLE.map((s) => (
|
||||
<Field key={s.key} label={s.label}>
|
||||
<select className={inputClass} value={design.style[s.key]} disabled={busy} onChange={(e) => save({ style: { [s.key]: e.target.value } })}>
|
||||
{Object.entries(s.options).map(([v, label]) => <option key={v} value={v}>{label}</option>)}
|
||||
{STYLE.map((st) => (
|
||||
<Field key={st.key} label={st.label}>
|
||||
<select className={inputClass} value={design.style[st.key]} disabled={busy} onChange={(e) => save({ style: { [st.key]: e.target.value } })}>
|
||||
{Object.entries(st.options).map(([v, label]) => <option key={v} value={v}>{label}</option>)}
|
||||
</select>
|
||||
</Field>
|
||||
))}
|
||||
</div>
|
||||
<p className="mt-4 text-sm text-gray-600">Fonts and corners are your church's brand style, shared with your Events and sign-in pages: change them in your church profile.</p>
|
||||
<p className="mt-4 text-sm text-gray-600">Colours, fonts and corners are your church's brand style, shared with your Events and sign-in pages: change them in <Link href="/admin/church" className="font-semibold underline">Church details</Link>.</p>
|
||||
</Panel>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</WithPreview>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user