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:
2026-11-26 19:57:22 +02:00
co-authored by Claude Opus 5.5
parent e6c91c3705
commit dcc22a5c16
42 changed files with 1278 additions and 353 deletions
+101 -16
View File
@@ -1,33 +1,105 @@
"use client";
/** The admin's own building blocks: plain, calm, the church's colour for the main action. */
import { useCallback, useEffect, useState } from "react";
/** The admin's own building blocks: plain, calm, the church's colour for the main action (as Cross Events' dashboard). */
import Link from "next/link";
import { createContext, useCallback, useContext, useEffect, useState } from "react";
import { ArrowRight, type LucideIcon } from "lucide-react";
import { api, AdminError } from "./api";
export const cx = (...c: (string | false | null | undefined)[]) => c.filter(Boolean).join(" ");
export function Title({ children, sub, actions }: { children: React.ReactNode; sub?: React.ReactNode; actions?: React.ReactNode }) {
export function Title({ children, sub, actions, icon: Icon }: { children: React.ReactNode; sub?: React.ReactNode; actions?: React.ReactNode; icon?: LucideIcon }) {
return (
<div className="mb-6 flex flex-wrap items-end justify-between gap-4">
<div>
<h1 className="text-2xl font-semibold text-gray-900">{children}</h1>
{sub && <p className="mt-1 text-gray-600">{sub}</p>}
<div className="flex min-w-0 items-start gap-3">
{Icon && <span className="mt-0.5 hidden h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-brand/10 text-brand-text sm:flex" aria-hidden><Icon className="h-5 w-5" /></span>}
<div className="min-w-0">
<h1 className="text-2xl font-semibold text-gray-900">{children}</h1>
{sub && <p className="mt-1 text-sm text-gray-600">{sub}</p>}
</div>
</div>
{actions && <div className="flex flex-wrap gap-2">{actions}</div>}
</div>
);
}
export function Panel({ children, className, title }: { children: React.ReactNode; className?: string; title?: string }) {
/** A white card; with a title, an icon in a tile of the church's colour and a line under it. */
export function Panel({ children, className, title, icon: Icon, sub, actions }: { children: React.ReactNode; className?: string; title?: string; icon?: LucideIcon; sub?: React.ReactNode; actions?: React.ReactNode }) {
return (
<section className={cx("rounded-lg border border-gray-200 bg-white p-5 shadow-sm", className)}>
{title && <h2 className="mb-4 text-lg font-semibold text-gray-900">{title}</h2>}
<section className={cx("rounded-xl border border-gray-200 bg-white p-5 shadow-sm", className)}>
{title && (
<div className="mb-4 flex flex-wrap items-start justify-between gap-3">
<div className="flex min-w-0 items-start gap-3">
{Icon && <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>}
<div className="min-w-0">
<h2 className="text-lg font-semibold text-gray-900">{title}</h2>
{sub && <p className="mt-0.5 text-sm text-gray-500">{sub}</p>}
</div>
</div>
{actions && <div className="flex flex-wrap gap-2">{actions}</div>}
</div>
)}
{children}
</section>
);
}
type BtnProps = React.ButtonHTMLAttributes<HTMLButtonElement> & { kind?: "primary" | "secondary" | "danger" | "link"; busy?: boolean };
/** Icon tabs (as Cross Events' Site Settings): one part of a page at a time. */
export function Tabs<T extends string>({ tabs, value, onChange, label }: { tabs: { id: T; label: string; icon: LucideIcon; badge?: React.ReactNode }[]; value: T; onChange: (id: T) => void; label: string }) {
return (
<div role="tablist" aria-label={label} className="mb-4 flex flex-wrap items-center gap-2">
{tabs.map((t) => {
const Icon = t.icon;
const on = t.id === value;
return (
<button key={t.id} type="button" role="tab" aria-selected={on} onClick={() => onChange(t.id)}
className={cx("inline-flex items-center gap-1.5 rounded-lg border px-3 py-1.5 text-sm font-medium transition-colors", on ? "border-brand bg-brand text-brand-on" : "border-gray-200 bg-white text-gray-700 hover:bg-gray-50")}>
<Icon className="h-4 w-4" aria-hidden />
{t.label}
{t.badge}
</button>
);
})}
</div>
);
}
const linkClass = "mt-3 inline-flex items-center gap-1 text-xs font-medium text-brand-text hover:underline";
const TONES = { brand: "bg-brand/10 text-brand-text", amber: "bg-amber-50 text-amber-700", green: "bg-green-50 text-green-700", gray: "bg-gray-100 text-gray-600" };
/** A number on the dashboard: an icon tile, a label, the value, and where to go for more. */
export function StatCard({ icon: Icon, label, value, detail, href, linkLabel, tone = "brand" }: { icon: LucideIcon; label: string; value: React.ReactNode; detail?: React.ReactNode; href?: string; linkLabel?: string; tone?: keyof typeof TONES }) {
return (
<div className="rounded-xl border border-gray-200 bg-white p-4 shadow-sm">
<div className="flex items-center gap-3">
<span className={cx("flex h-10 w-10 shrink-0 items-center justify-center rounded-lg", TONES[tone])} aria-hidden><Icon className="h-5 w-5" /></span>
<div className="min-w-0">
<div className="text-xs leading-snug text-gray-500">{label}</div>
<div className="truncate text-xl font-semibold text-gray-900">{value}</div>
</div>
</div>
{detail && <div className="mt-2 text-xs text-gray-500">{detail}</div>}
{href && (href.startsWith("/admin")
? <Link href={href} className={linkClass}>{linkLabel ?? "Open"}<ArrowRight className="h-3 w-3" aria-hidden /></Link>
: <a href={href} className={linkClass}>{linkLabel ?? "Open"}<ArrowRight className="h-3 w-3" aria-hidden /></a>)}
</div>
);
}
/** A quick-action tile: icon, title and a line about it; the whole tile is the link. */
export function ActionTile({ icon: Icon, title, description, href }: { icon: LucideIcon; title: string; description: string; href: string }) {
return (
<Link href={href} className="flex items-start gap-3 rounded-xl border border-gray-200 bg-white p-4 shadow-sm transition hover:border-brand/40 hover:shadow">
<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-5 w-5" /></span>
<span className="min-w-0">
<span className="block text-sm font-semibold text-gray-900">{title}</span>
<span className="mt-0.5 block text-xs text-gray-500">{description}</span>
</span>
</Link>
);
}
type BtnProps = React.ButtonHTMLAttributes<HTMLButtonElement> & { kind?: "primary" | "secondary" | "danger" | "link" | "icon"; busy?: boolean };
export function Btn({ kind = "secondary", busy, className, children, disabled, ...rest }: BtnProps) {
return (
@@ -36,15 +108,17 @@ export function Btn({ kind = "secondary", busy, className, children, disabled, .
{...rest}
disabled={disabled || busy}
className={cx(
"inline-flex items-center justify-center gap-2 rounded-md px-4 py-2 text-sm font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",
"inline-flex items-center justify-center gap-2 rounded-lg text-sm font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",
kind !== "icon" && kind !== "link" && "px-4 py-2",
kind === "primary" && "bg-brand text-brand-on hover:bg-brand-dark",
kind === "secondary" && "border border-gray-300 bg-white text-gray-800 hover:bg-gray-50",
kind === "danger" && "border border-red-300 bg-white text-red-700 hover:bg-red-50",
kind === "link" && "px-0 py-0 text-brand-text underline-offset-4 hover:underline",
kind === "icon" && "h-8 w-8 border border-gray-200 bg-white text-gray-600 hover:bg-gray-50 hover:text-gray-900",
className,
)}
>
{busy ? "Working…" : children}
{busy && kind !== "icon" ? "Working…" : children}
</button>
);
}
@@ -60,11 +134,11 @@ export function Field({ label, hint, error, children }: { label: string; hint?:
);
}
export const inputClass = "w-full rounded-md border border-gray-300 px-3 py-2 text-sm text-gray-900 shadow-sm focus:border-brand focus:outline-none focus:ring-2 focus:ring-brand/30";
export const inputClass = "w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 shadow-sm focus:border-brand focus:outline-none focus:ring-2 focus:ring-brand/30";
export function Notice({ tone = "info", children }: { tone?: "info" | "error" | "success" | "warning"; children: React.ReactNode }) {
const tones = { info: "border-blue-200 bg-blue-50 text-blue-900", error: "border-red-200 bg-red-50 text-red-900", success: "border-green-200 bg-green-50 text-green-900", warning: "border-amber-200 bg-amber-50 text-amber-900" };
return <div role={tone === "error" ? "alert" : "status"} className={cx("rounded-md border px-4 py-3 text-sm", tones[tone])}>{children}</div>;
return <div role={tone === "error" ? "alert" : "status"} className={cx("rounded-lg border px-4 py-3 text-sm", tones[tone])}>{children}</div>;
}
/** Loads `path` from the admin API; `reload` fetches it again. */
@@ -88,8 +162,18 @@ export function useAdmin<T>(path: string | null) {
return { data, error, reload: load, setData };
}
/** Runs an action, keeping its busy state, message and field errors. */
/** The dashboard's numbers, shared by the frame (the change count, the setup steps) and the pages. */
export type Overview = {
pending: number;
lastPublished: { number: number; at: string } | null;
checklist: { key: string; label: string; done: boolean; href: string | null }[];
};
export const OverviewContext = createContext<{ overview: Overview | null; refresh: () => void }>({ overview: null, refresh: () => {} });
export const useOverview = () => useContext(OverviewContext);
/** Runs an action, keeping its busy state, message and field errors. Afterwards the frame's change count and steps catch up. */
export function useAction() {
const { refresh } = useOverview();
const [busy, setBusy] = useState(false);
const [message, setMessage] = useState<{ tone: "error" | "success"; text: string } | null>(null);
const [fields, setFields] = useState<Record<string, string>>({});
@@ -107,8 +191,9 @@ export function useAction() {
return null;
} finally {
setBusy(false);
refresh();
}
}, []);
}, [refresh]);
return { busy, message, fields, run, setMessage };
}