Add colour tokens, dark mode and drop gradients

- Colour tokens in index.css named by role (ink, body, muted, link,
  brand, action, surface, tint, danger), used everywhere instead of hex
- Dark mode: follows the system, a header toggle (site and admin)
  overrides it and is remembered; set before first paint in index.html
- Data colours go through src/lib/color.ts: withAlpha for tints,
  accentText (lighter on dark) for text in an accent, readableOn for
  text on one, so an admin's pale colour still reads
- Migration 040 drops events.gradient: a card is its photo or plain,
  with its colour as the border; other decorative gradients are solid
- The countdown and a hero event without a photo mix their colour
  toward ink behind white text

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-28 22:42:59 -05:00
parent ee61568911
commit c74ad746f5
70 changed files with 829 additions and 596 deletions

View file

@ -49,8 +49,8 @@ export type MediaItem = {
};
const button =
"rounded-full border border-[#138ba0] px-3 py-1 text-sm font-medium text-[#0f7183] " +
"transition-colors hover:bg-[#eef9fb] disabled:cursor-default disabled:opacity-50";
"rounded-full border border-brand px-3 py-1 text-sm font-medium text-link " +
"transition-colors hover:bg-tint disabled:cursor-default disabled:opacity-50";
/* A light checkerboard, so a white logo on a transparent background
is still visible in its thumbnail. */
@ -166,18 +166,18 @@ export function UploadButton({
className="hidden"
onChange={(e) => send(e.target.files)}
/>
<label htmlFor={keepId} className="flex items-center gap-1.5 text-xs text-[#4a6b72]">
<label htmlFor={keepId} className="flex items-center gap-1.5 text-xs text-muted">
<input
id={keepId}
type="checkbox"
checked={keepOriginal}
onChange={(e) => setKeepOriginal(e.target.checked)}
className="h-3.5 w-3.5 rounded border-[#4a6b72]/40 text-[#0f7183]"
className="h-3.5 w-3.5 rounded border-muted/40 text-link"
/>
Keep original
</label>
</div>
{error && <p className="mt-1 text-xs text-[#b3261e]">{error}</p>}
{error && <p className="mt-1 text-xs text-danger">{error}</p>}
</div>
);
}
@ -200,7 +200,7 @@ export function MediaGrid({
renderActions?: (item: MediaItem) => ReactNode;
}) {
if (items.length === 0) {
return <p className="text-sm text-[#4a6b72]">Nothing here yet.</p>;
return <p className="text-sm text-muted">Nothing here yet.</p>;
}
return (
@ -214,7 +214,7 @@ export function MediaGrid({
// A still of the first frame; metadata only, not the file.
<video src={item.url} preload="metadata" muted className="h-full w-full bg-black object-contain" />
) : item.content_type.startsWith("audio/") ? (
<div className="flex h-full w-full items-center justify-center bg-[#eef9fb] text-3xl" aria-hidden="true">
<div className="flex h-full w-full items-center justify-center bg-tint text-3xl" aria-hidden="true">
♪
</div>
) : (
@ -226,18 +226,18 @@ export function MediaGrid({
/>
)}
</div>
<p className="mt-1.5 truncate text-xs font-medium text-[#26454c]" title={item.original_name}>
<p className="mt-1.5 truncate text-xs font-medium text-body" title={item.original_name}>
{item.original_name}
</p>
<p className="text-xs text-[#4a6b72]/80">{mediaSize(item)}</p>
<p className="text-xs text-muted/80">{mediaSize(item)}</p>
</>
);
return (
<li
key={item.id}
className={`rounded-xl border bg-white p-2 ${
isSelected ? "border-[#138ba0] ring-2 ring-[#138ba0]/30" : "border-[#4a6b72]/20"
className={`rounded-xl border bg-surface p-2 ${
isSelected ? "border-brand ring-2 ring-brand/30" : "border-muted/20"
}`}
>
{onPick ? (
@ -292,27 +292,27 @@ export function MediaPicker({
className="w-[min(56rem,calc(100vw-2rem))] rounded-2xl p-0 backdrop:bg-[#0f2f36]/40"
>
<div className="flex max-h-[85vh] flex-col">
<div className="flex flex-wrap items-center gap-3 border-b border-[#138ba0]/15 px-5 py-4">
<h2 className="text-lg font-semibold text-[#0f7183]">Choose an image</h2>
<div className="flex flex-wrap items-center gap-3 border-b border-brand/15 px-5 py-4">
<h2 className="text-lg font-semibold text-link">Choose an image</h2>
<input
type="search"
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="Search by file name"
className="ml-auto w-56 rounded-lg border border-[#4a6b72]/25 px-3 py-1.5 text-sm outline-none focus:border-[#138ba0]"
className="ml-auto w-56 rounded-lg border border-muted/25 px-3 py-1.5 text-sm outline-none focus:border-brand"
/>
<button
type="button"
onClick={() => dialogRef.current?.close()}
aria-label="Close"
className="h-8 w-8 rounded-full text-[#4a6b72] hover:bg-[#eef9fb]"
className="h-8 w-8 rounded-full text-muted hover:bg-tint"
>
✕
</button>
</div>
{roleCanWrite(user) && (
<div className="border-b border-[#138ba0]/10 px-5 py-3">
<div className="border-b border-brand/10 px-5 py-3">
<UploadButton
label="Upload new"
onUploaded={(item) => {
@ -321,15 +321,15 @@ export function MediaPicker({
dialogRef.current?.close();
}}
/>
<p className="mt-1 text-xs text-[#4a6b72]">{UPLOAD_HELP}</p>
<p className="mt-1 text-xs text-muted">{UPLOAD_HELP}</p>
</div>
)}
<div className="overflow-y-auto px-5 py-4">
{error ? (
<p className="text-sm text-[#b3261e]">{error}</p>
<p className="text-sm text-danger">{error}</p>
) : items === null ? (
<p className="text-sm text-[#4a6b72]">Loading…</p>
<p className="text-sm text-muted">Loading…</p>
) : (
<MediaGrid
items={items}
@ -375,13 +375,13 @@ export function ImageInput({
return (
<div className="flex gap-3">
<div
className="flex h-20 w-20 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-[#4a6b72]/20"
className="flex h-20 w-20 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-muted/20"
style={CHECKER}
>
{src && !broken ? (
<img src={src} alt="" className="h-full w-full object-contain" onError={() => setBroken(true)} />
) : (
<span className="px-1 text-center text-[10px] text-[#4a6b72]/70">
<span className="px-1 text-center text-[10px] text-muted/70">
{src ? "Not found" : "No image"}
</span>
)}
@ -406,7 +406,7 @@ export function ImageInput({
<button
type="button"
onClick={() => onChange("")}
className="px-2 py-1 text-sm text-[#4a6b72] hover:text-[#b3261e]"
className="px-2 py-1 text-sm text-muted hover:text-danger"
>
Clear
</button>
@ -498,7 +498,7 @@ export function LinkPreviewInput({
{busy ? "Fetching…" : "Fetch preview"}
</button>
{note && (
<span className={`text-xs ${note.tone === "ok" ? "text-[#0f7183]" : "text-[#b3261e]"}`}>
<span className={`text-xs ${note.tone === "ok" ? "text-link" : "text-danger"}`}>
{note.text}
</span>
)}

View file

@ -71,10 +71,10 @@ function Label({ section }: { section: EditorSection }) {
<>
<span className="truncate">{section.label}</span>
{section.count != null && (
<span className="text-xs text-[#4a6b72]/70">({section.count})</span>
<span className="text-xs text-muted/70">({section.count})</span>
)}
{section.hasError && (
<span aria-label="needs attention" className="h-1.5 w-1.5 shrink-0 rounded-full bg-[#b3261e]" />
<span aria-label="needs attention" className="h-1.5 w-1.5 shrink-0 rounded-full bg-danger" />
)}
</>
);
@ -87,10 +87,10 @@ export function SectionNav({ sections }: { sections: EditorSection[] }) {
return (
<nav aria-label="Sections" className="hidden max-h-[calc(100vh-8rem)] overflow-y-auto lg:block">
<p className="mb-2 px-3 text-xs font-semibold uppercase tracking-wider text-[#4a6b72]/70">
<p className="mb-2 px-3 text-xs font-semibold uppercase tracking-wider text-muted/70">
On this page
</p>
<ul className="space-y-0.5 border-l border-[#138ba0]/15">
<ul className="space-y-0.5 border-l border-brand/15">
{sections.map((section) => {
const lit = section.id === active;
return (
@ -101,8 +101,8 @@ export function SectionNav({ sections }: { sections: EditorSection[] }) {
aria-current={lit ? "location" : undefined}
className={`-ml-px flex w-full items-center gap-1.5 border-l-2 px-3 py-1.5 text-left text-sm transition-colors ${
lit
? "border-[#138ba0] font-semibold text-[#0f7183]"
: "border-transparent text-[#4a6b72] hover:border-[#138ba0]/40 hover:text-[#0f7183]"
? "border-brand font-semibold text-link"
: "border-transparent text-muted hover:border-brand/40 hover:text-link"
}`}
>
<Label section={section} />
@ -120,13 +120,13 @@ export function SectionJump({ sections }: { sections: EditorSection[] }) {
const active = useActiveSection(sections);
return (
<div className="sticky top-0 z-20 -mx-6 mt-4 mb-2 border-b border-[#138ba0]/15 bg-[#f6fbfc]/95 px-6 py-2 backdrop-blur lg:hidden">
<label className="flex items-center gap-3 text-sm text-[#4a6b72]">
<div className="sticky top-0 z-20 -mx-6 mt-4 mb-2 border-b border-brand/15 bg-tint-soft/95 px-6 py-2 backdrop-blur lg:hidden">
<label className="flex items-center gap-3 text-sm text-muted">
<span className="shrink-0">Jump to</span>
<select
value={active ?? ""}
onChange={(e) => jump(e.target.value)}
className="w-full rounded-lg border border-[#4a6b72]/25 bg-white px-3 py-1.5 text-sm text-[#26454c] outline-none focus:border-[#138ba0]"
className="w-full rounded-lg border border-muted/25 bg-surface px-3 py-1.5 text-sm text-body outline-none focus:border-brand"
>
{sections.map((section) => (
<option key={section.id} value={section.id}>

View file

@ -104,24 +104,24 @@ const PREVIEWS = {
};
const input =
"w-full rounded-lg border border-[#4a6b72]/25 bg-white px-3 py-2 text-sm text-[#26454c] " +
"outline-none transition-colors focus:border-[#138ba0] focus:ring-2 focus:ring-[#138ba0]/25";
"w-full rounded-lg border border-muted/25 bg-surface px-3 py-2 text-sm text-body " +
"outline-none transition-colors focus:border-brand focus:ring-2 focus:ring-brand/25";
/* Same box, but lit by the real input nested inside it. */
const inputShell =
"flex w-full items-center rounded-lg border border-[#4a6b72]/25 bg-white px-3 py-2 text-sm " +
"text-[#26454c] transition-colors focus-within:border-[#138ba0] focus-within:ring-2 " +
"focus-within:ring-[#138ba0]/25";
"flex w-full items-center rounded-lg border border-muted/25 bg-surface px-3 py-2 text-sm " +
"text-body transition-colors focus-within:border-brand focus-within:ring-2 " +
"focus-within:ring-brand/25";
const inputError = "border-[#b3261e] focus:border-[#b3261e] focus:ring-[#b3261e]/20";
const inputError = "border-danger focus:border-danger focus:ring-danger/20";
const shellError =
"border-[#b3261e] focus-within:border-[#b3261e] focus-within:ring-[#b3261e]/20";
"border-danger focus-within:border-danger focus-within:ring-danger/20";
/* Reads as settled fact rather than as an empty box someone forgot
to fill in. */
const inputLocked =
"w-full rounded-lg border border-[#4a6b72]/20 bg-[#f6fbfc] px-3 py-2 text-sm " +
"text-[#4a6b72] outline-none cursor-default focus:border-[#4a6b72]/40";
"w-full rounded-lg border border-muted/20 bg-tint-soft px-3 py-2 text-sm " +
"text-muted outline-none cursor-default focus:border-muted/40";
/* ── Dotted paths ────────────────────────────────────────────── */
@ -226,21 +226,21 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
return (
<div className={field.full ? "sm:col-span-2" : ""}>
<label htmlFor={id} className="block text-sm font-medium text-[#26454c]">
<label htmlFor={id} className="block text-sm font-medium text-body">
{typeof field.label === "function" ? field.label(row) : field.label}
{field.required && !locked && <span className="ml-1 text-[#b3261e]">*</span>}
{field.required && !locked && <span className="ml-1 text-danger">*</span>}
</label>
<div className="mt-1.5">
{widget === "checkbox" ? (
<label className="flex items-center gap-2 text-sm text-[#4a6b72]">
<label className="flex items-center gap-2 text-sm text-muted">
<input
id={id}
type="checkbox"
checked={value === 1 || value === true}
disabled={locked}
onChange={(e) => onChange(e.target.checked ? 1 : 0)}
className="h-4 w-4 rounded border-[#4a6b72]/40 text-[#0f7183] focus:ring-[#138ba0]/40 disabled:opacity-50"
className="h-4 w-4 rounded border-muted/40 text-link focus:ring-brand/40 disabled:opacity-50"
/>
{helpText(field, row) ?? "Yes"}
</label>
@ -277,7 +277,7 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
value={/^#[0-9a-f]{6}$/i.test(value ?? "") ? value : "#138ba0"}
disabled={locked}
onChange={(e) => onChange(e.target.value)}
className="h-9 w-12 shrink-0 rounded border border-[#4a6b72]/25 bg-white disabled:opacity-50"
className="h-9 w-12 shrink-0 rounded border border-muted/25 bg-surface disabled:opacity-50"
/>
<input
{...common}
@ -318,7 +318,7 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
<span
aria-hidden="true"
className={`shrink-0 select-none ${
field.prefixPending ? "text-[#4a6b72]/45" : "text-[#4a6b72]"
field.prefixPending ? "text-muted/45" : "text-muted"
}`}
>
{field.prefix}
@ -329,7 +329,7 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
value={value ?? ""}
onChange={(e) => onChange(e.target.value)}
placeholder={field.placeholder}
className="w-full border-0 bg-transparent p-0 text-[#26454c] outline-none placeholder:text-[#4a6b72]/45"
className="w-full border-0 bg-transparent p-0 text-body outline-none placeholder:text-muted/45"
/>
</div>
) : (
@ -347,15 +347,15 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
</div>
{error ? (
<p className="mt-1 text-xs text-[#b3261e]">{error}</p>
<p className="mt-1 text-xs text-danger">{error}</p>
) : orphaned && !locked ? (
<p className="mt-1 text-xs text-[#b3261e]">
<p className="mt-1 text-xs text-danger">
This points at something that has been deleted. Pick a replacement before saving.
</p>
) : (
helpText(field, row) &&
widget !== "checkbox" && (
<p className="mt-1 text-xs text-[#4a6b72]">{helpText(field, row)}</p>
<p className="mt-1 text-xs text-muted">{helpText(field, row)}</p>
)
)}
</div>
@ -467,25 +467,25 @@ export function Repeater({
return (
<section className={className}>
<div className="flex flex-wrap items-center gap-3">
<h3 className="text-base font-semibold text-[#26454c]">
<h3 className="text-base font-semibold text-body">
{spec.label}
{list.length > 0 && (
<span className="ml-2 text-sm font-normal text-[#4a6b72]/80">{list.length}</span>
<span className="ml-2 text-sm font-normal text-muted/80">{list.length}</span>
)}
</h3>
{list.length > 1 && (
<div className="flex gap-3 text-xs text-[#4a6b72]">
<div className="flex gap-3 text-xs text-muted">
<button
type="button"
onClick={() => setOpen(new Set(list.map((_, i) => i)))}
className="hover:text-[#0f7183] hover:underline"
className="hover:text-link hover:underline"
>
Expand all
</button>
<button
type="button"
onClick={() => setOpen(new Set())}
className="hover:text-[#0f7183] hover:underline"
className="hover:text-link hover:underline"
>
Collapse all
</button>
@ -494,15 +494,15 @@ export function Repeater({
<button
type="button"
onClick={add}
className="ml-auto rounded-full border border-[#138ba0] px-3 py-1 text-sm font-medium text-[#0f7183] transition-colors hover:bg-[#eef9fb]"
className="ml-auto rounded-full border border-brand px-3 py-1 text-sm font-medium text-link transition-colors hover:bg-tint"
>
{spec.addLabel ?? "Add"}
</button>
</div>
{spec.note && <p className="mt-1 text-sm text-[#4a6b72]">{spec.note}</p>}
{spec.note && <p className="mt-1 text-sm text-muted">{spec.note}</p>}
{list.length === 0 && <p className="mt-2 text-sm text-[#4a6b72]">None yet.</p>}
{list.length === 0 && <p className="mt-2 text-sm text-muted">None yet.</p>}
<div className="mt-3 space-y-3">
{list.map((row, index) => {
@ -533,10 +533,10 @@ export function Repeater({
endDrag();
}}
className={
`rounded-xl border bg-[#f6fbfc] ${expanded ? "p-4" : "px-4 py-2.5"} transition-colors ` +
`rounded-xl border bg-tint-soft ${expanded ? "p-4" : "px-4 py-2.5"} transition-colors ` +
(over
? "border-[#138ba0] ring-2 ring-[#138ba0]/25 "
: "border-[#4a6b72]/20 ") +
? "border-brand ring-2 ring-brand/25 "
: "border-muted/20 ") +
(dragging ? "opacity-50" : "")
}
>
@ -556,7 +556,7 @@ export function Repeater({
onDragEnd={endDrag}
title="Drag to reorder"
aria-hidden="true"
className="cursor-grab select-none px-1 text-[#4a6b72]/60 active:cursor-grabbing"
className="cursor-grab select-none px-1 text-muted/60 active:cursor-grabbing"
>
⠿
</span>
@ -565,11 +565,11 @@ export function Repeater({
type="button"
onClick={() => toggle(index)}
aria-expanded={expanded}
className="flex min-w-0 flex-1 items-center gap-2 text-left text-sm font-medium text-[#26454c] hover:text-[#0f7183]"
className="flex min-w-0 flex-1 items-center gap-2 text-left text-sm font-medium text-body hover:text-link"
>
<span
aria-hidden="true"
className={`inline-block text-xs text-[#4a6b72] transition-transform ${
className={`inline-block text-xs text-muted transition-transform ${
expanded ? "rotate-90" : ""
}`}
>
@ -579,7 +579,7 @@ export function Repeater({
{spec.title ? spec.title(row, options) : `#${index + 1}`}
</span>
{!expanded && hasError(index) && (
<span className="text-xs text-[#b3261e]">needs attention</span>
<span className="text-xs text-danger">needs attention</span>
)}
</button>
@ -642,7 +642,7 @@ export function Repeater({
{(spec.children ?? [])
.filter((nested) => fieldShown(nested, row, parentRow))
.map((nested) => (
<div key={nested.key} className="mt-4 border-t border-[#4a6b72]/15 pt-4">
<div key={nested.key} className="mt-4 border-t border-muted/15 pt-4">
<Repeater
spec={nested}
rows={row[nested.key]}
@ -657,8 +657,8 @@ export function Repeater({
))}
{spec.preview && PREVIEWS[spec.preview] && (
<div className="mt-4 rounded-lg border border-dashed border-[#138ba0]/30 bg-white p-4">
<p className="mb-3 text-xs font-semibold uppercase tracking-wider text-[#4a6b72]/70">
<div className="mt-4 rounded-lg border border-dashed border-brand/30 bg-surface p-4">
<p className="mb-3 text-xs font-semibold uppercase tracking-wider text-muted/70">
Preview
</p>
{PREVIEWS[spec.preview](row, options)}
@ -685,10 +685,10 @@ function IconButton({ label, onClick, danger = false, disabled = false, children
className={
"h-7 w-7 rounded-full border text-sm leading-none transition-colors " +
(disabled
? "cursor-default border-[#4a6b72]/20 text-[#4a6b72]/40"
? "cursor-default border-muted/20 text-muted/40"
: danger
? "border-[#b3261e]/30 text-[#b3261e] hover:bg-[#fdf3f2]"
: "border-[#4a6b72]/30 text-[#4a6b72] hover:bg-white")
? "border-danger/30 text-danger hover:bg-danger-tint"
: "border-muted/30 text-muted hover:bg-surface")
}
>
{children}