Admin home: a palette color per group of cards

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-30 14:54:39 -05:00
parent d5428297a4
commit 239c3fa293

View file

@ -11,7 +11,9 @@
Forms, Tools, and Panel, which only exists for superadmins.
It asks for the wide admin column (adminWidth.tsx), like the
editor, so the cards run three across on a wide screen.
editor, so the cards run three across on a wide screen. Each
block takes a color from the palette (GROUP_COLORS), tinting its
cards and drawing its bar, so the groups read apart at a glance.
The right-hand panel is deliberately inert. Nothing here
fetches, so the landing page can't be slow or half-broken on
@ -25,13 +27,17 @@ import { useAuth } from "../../lib/auth.tsx";
import { useWideAdminPage } from "../../lib/adminWidth.tsx";
import { SITE_VERSION } from "../../lib/version.ts";
import { ROLE_LABELS, isSuper } from "../../lib/roles.ts";
import { PALETTE } from "../../lib/color.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 }) {
/* A card's fill: its group's color, faint, over the surface. */
const tintOf = (color: string) => `color-mix(in srgb, ${color} 12%, var(--color-surface))`;
function NavCard({ item, color }) {
const to = target(item);
// Drop the child that just repeats the card's own destination:
@ -39,7 +45,10 @@ function NavCard({ item }) {
const extras = (item.children ?? []).filter((child) => child.to !== to);
return (
<div className="group relative flex flex-col border border-brand/20 bg-surface p-5 transition-all hover:border-brand/60 hover:shadow-sm">
<div
className="group relative flex flex-col border-l-4 p-5 transition-colors hover:brightness-[0.97]"
style={{ borderColor: color, background: tintOf(color) }}
>
<div className="flex items-baseline gap-3">
<h3 className="text-base font-bold text-link">
<Link
@ -78,10 +87,10 @@ function NavCard({ item }) {
);
}
function CardBlock({ title, blurb, children }) {
function CardBlock({ title, blurb, color, children }) {
return (
<div className="mt-10">
<div className="flex items-baseline gap-3">
<div className="flex items-baseline gap-3 border-b-4 pb-2" style={{ borderColor: color }}>
<h2 className="text-lg font-bold text-link">{title}</h2>
{blurb && <p className="text-sm text-muted">{blurb}</p>}
</div>
@ -101,9 +110,15 @@ function PanelSection({ title, children }) {
);
}
/* 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];
/* The header's groups, in its order, each with its palette color.
Panel is drawn separately below, since only superadmins get it. */
const GROUPS = [
{ nav: DATA_NAV, color: PALETTE.teal[0] },
{ nav: PAGES_NAV, color: PALETTE.green[0] },
{ nav: FORMS_NAV, color: PALETTE.mint[2] },
{ nav: TOOLS_NAV, color: PALETTE.ink[2] },
];
const PANEL_COLOR = PALETTE.ink[1];
const QUICK_ADD = [
{ to: "/admin/events/new", label: "New event" },
@ -125,18 +140,18 @@ export default function AdminHome() {
</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} />
{GROUPS.map(({ nav, color }) => (
<CardBlock key={nav.label} title={nav.label} blurb={nav.blurb} color={color}>
{visibleItems(nav.children, user).map((item) => (
<NavCard key={item.to} item={item} color={color} />
))}
</CardBlock>
))}
{isSuper(user) && (
<CardBlock title={PANEL_NAV.label} blurb={PANEL_NAV.blurb}>
<CardBlock title={PANEL_NAV.label} blurb={PANEL_NAV.blurb} color={PANEL_COLOR}>
{PANEL_NAV.children.map((item) => (
<NavCard key={item.to} item={item} />
<NavCard key={item.to} item={item} color={PANEL_COLOR} />
))}
</CardBlock>
)}