- Dark mode: the countdown card, timeline section, Giving text, error text, the Leadership button, skeletons and the admin's dark text all follow the tokens; logos get a light plate in dark mode - One BRAND accent (the button token, so the admin palette reaches every page) and one ACCENTS family in color.ts, replacing 20 local teal constants and the purple, ochre and rust section colours; neon green and gold become mint and brand green - Shadows are tinted with the site's ink; glow shadows are gone - One giving label, Give, in the nav, footer and Giving page - Phosphor icons replace the hand-drawn SVGs and the glyph icons; Pathfinder paths pick a named icon (emoji still shown) and lose the watermark - Home keeps two eyebrows; StatsBand's title is a real heading; section headings step down under the page title - Nav links switch to the menu below lg, so they never wrap; jump links land clear of the header; press feedback on buttons - Empty sections say what's coming and who to ask; loading is a skeleton; form placeholders and borders are readable; one corner-radius rule; theme-color for both modes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
183 lines
6.9 KiB
TypeScript
183 lines
6.9 KiB
TypeScript
/* ═══════════════════════════════════════════════════════════════
|
|
ADMIN HOME
|
|
|
|
Where login lands. Two columns: the cards are the navigation
|
|
(the header deliberately drops its tab row here so the same links
|
|
aren't drawn twice), and a standing info panel on the right.
|
|
|
|
The cards come from adminNav.ts, the same list the CMS header
|
|
reads, so a new entity shows up here the moment it's registered.
|
|
One block per header group, in the same order: Data, Pages,
|
|
Forms, Tools, and Panel, which only exists for superadmins.
|
|
|
|
The right-hand panel is deliberately inert. Nothing here
|
|
fetches, so the landing page can't be slow or half-broken on
|
|
arrival; anything live (open feedback count, last-edited
|
|
record) wants to be a separate component that fails on its own.
|
|
═══════════════════════════════════════════════════════════════ */
|
|
|
|
import { ArrowRight, ArrowUpRight } from "@phosphor-icons/react";
|
|
import { Link } from "react-router-dom";
|
|
import { useAuth } from "../../lib/auth.tsx";
|
|
import { SITE_VERSION } from "../../lib/version.ts";
|
|
import { ROLE_LABELS, isSuper } from "../../lib/roles.ts";
|
|
import { DATA_NAV, FORMS_NAV, PAGES_NAV, PANEL_NAV, TOOLS_NAV, target, visibleItems } from "./adminNav.ts";
|
|
|
|
/* One card. The title link is stretched over the whole card with
|
|
`after:absolute`, which makes the card clickable without nesting
|
|
an anchor inside an anchor; the sub-links sit above it on z-10 so
|
|
they stay separately clickable. */
|
|
function NavCard({ item }) {
|
|
const to = target(item);
|
|
|
|
// Drop the child that just repeats the card's own destination:
|
|
// "All organizations" under Organizations.
|
|
const extras = (item.children ?? []).filter((child) => child.to !== to);
|
|
|
|
return (
|
|
<div className="group relative flex flex-col rounded-2xl border border-brand/20 bg-surface p-5 transition-all hover:border-brand/60 hover:shadow-sm">
|
|
<div className="flex items-baseline gap-3">
|
|
<h3 className="text-base font-semibold text-link">
|
|
<Link
|
|
to={to}
|
|
className="after:absolute after:inset-0 after:rounded-2xl after:content-['']"
|
|
>
|
|
{item.label}
|
|
</Link>
|
|
</h3>
|
|
<span
|
|
aria-hidden="true"
|
|
className="ml-auto text-link opacity-0 transition-opacity group-hover:opacity-100"
|
|
>
|
|
<ArrowRight size="1em" weight="bold" className="inline align-[-0.125em]" aria-hidden="true" />
|
|
</span>
|
|
</div>
|
|
|
|
{item.blurb && (
|
|
<p className="mt-1.5 text-sm leading-relaxed text-muted">{item.blurb}</p>
|
|
)}
|
|
|
|
{extras.length > 0 && (
|
|
<div className="relative z-10 mt-4 flex flex-wrap gap-x-4 gap-y-1 border-t border-brand/10 pt-3 text-sm">
|
|
{extras.map((child) => (
|
|
<Link
|
|
key={child.to}
|
|
to={child.to}
|
|
className="text-muted underline-offset-4 transition-colors hover:text-link hover:underline"
|
|
>
|
|
{child.label}
|
|
</Link>
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function CardBlock({ title, blurb, children }) {
|
|
return (
|
|
<div className="mt-10">
|
|
<div className="flex items-baseline gap-3">
|
|
<h2 className="text-lg font-semibold text-link">{title}</h2>
|
|
{blurb && <p className="text-sm text-muted">{blurb}</p>}
|
|
</div>
|
|
<div className="mt-4 grid gap-4 sm:grid-cols-2">{children}</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function PanelSection({ title, children }) {
|
|
return (
|
|
<section className="border-b border-brand/10 px-5 py-4 last:border-b-0">
|
|
<h2 className="text-xs font-semibold uppercase tracking-wider text-muted/70">
|
|
{title}
|
|
</h2>
|
|
<div className="mt-2.5 text-sm text-muted">{children}</div>
|
|
</section>
|
|
);
|
|
}
|
|
|
|
/* The header's groups, in its order. Panel is drawn separately
|
|
below, since only superadmins get it. */
|
|
const GROUPS = [DATA_NAV, PAGES_NAV, FORMS_NAV, TOOLS_NAV];
|
|
|
|
const QUICK_ADD = [
|
|
{ to: "/admin/events/new", label: "New event" },
|
|
{ to: "/admin/people/new", label: "New person" },
|
|
{ to: "/admin/organizations/new", label: "New organization" },
|
|
{ to: "/admin/timeline/new", label: "New timeline entry" },
|
|
];
|
|
|
|
export default function AdminHome() {
|
|
const { user } = useAuth();
|
|
const role = ROLE_LABELS[user?.role] ?? user?.role;
|
|
|
|
return (
|
|
<div className="grid gap-8 lg:grid-cols-[1fr_17rem] lg:items-start">
|
|
<div>
|
|
<h1 className="text-2xl font-bold text-link">
|
|
{user?.name ? `Welcome back, ${user.name.split(" ")[0]}.` : "Welcome back."}
|
|
</h1>
|
|
<p className="mt-1 text-muted">Pick a section to work in.</p>
|
|
|
|
{GROUPS.map((group) => (
|
|
<CardBlock key={group.label} title={group.label} blurb={group.blurb}>
|
|
{visibleItems(group.children, user).map((item) => (
|
|
<NavCard key={item.to} item={item} />
|
|
))}
|
|
</CardBlock>
|
|
))}
|
|
|
|
{isSuper(user) && (
|
|
<CardBlock title={PANEL_NAV.label} blurb={PANEL_NAV.blurb}>
|
|
{PANEL_NAV.children.map((item) => (
|
|
<NavCard key={item.to} item={item} />
|
|
))}
|
|
</CardBlock>
|
|
)}
|
|
</div>
|
|
|
|
{/* Sticky so it stays put once the card column outgrows it. */}
|
|
<aside className="divide-y divide-brand/10 rounded-2xl border border-brand/20 bg-surface lg:sticky lg:top-6">
|
|
<PanelSection title="Signed in">
|
|
<p className="font-medium text-ink">{user?.name || user?.email}</p>
|
|
{user?.name && user?.email && (
|
|
<p className="mt-0.5 break-all text-xs text-muted/80">{user.email}</p>
|
|
)}
|
|
{role && (
|
|
<span className="mt-2 inline-block rounded-full bg-tint px-2.5 py-0.5 text-xs font-medium text-link">
|
|
{role}
|
|
</span>
|
|
)}
|
|
</PanelSection>
|
|
|
|
<PanelSection title="Start something">
|
|
<ul className="space-y-1.5">
|
|
{QUICK_ADD.map((link) => (
|
|
<li key={link.to}>
|
|
<Link
|
|
to={link.to}
|
|
className="underline-offset-4 transition-colors hover:text-link hover:underline"
|
|
>
|
|
{link.label}
|
|
</Link>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</PanelSection>
|
|
|
|
<PanelSection title="Site">
|
|
<p className="font-mono text-xs text-muted/80">{SITE_VERSION}</p>
|
|
<a
|
|
href="/"
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
className="mt-2 inline-block underline-offset-4 transition-colors hover:text-link hover:underline"
|
|
>
|
|
View the public site <ArrowUpRight size="1em" weight="bold" className="inline align-[-0.125em]" aria-hidden="true" />
|
|
</a>
|
|
</PanelSection>
|
|
</aside>
|
|
</div>
|
|
);
|
|
}
|