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

@ -38,9 +38,10 @@ import { NAV_ACTIONS, PAGE_LINKS, PAGE_SECTIONS } from '../../navConfig.ts'
import { awardHref, blogHref, eventHref, orgHref, personHref, teamHref } from '../../lib/hrefs.ts'
import { siteUrl } from '../../lib/site.ts'
import { useDirectory, type Directory } from '../../lib/useContent.ts'
import { accentText } from '../../lib/color.ts'
const TEAL = '#0f7183'
const MUTED = '#4a6b72'
const MUTED = 'var(--color-muted)'
/* PNG download size in pixels. Plenty for print at a few inches;
anything bigger should use the SVG. */
@ -316,7 +317,7 @@ export default function QrCodeMaker() {
{kind === 'custom' ? (
<div>
<label htmlFor="qr-custom" className="block text-sm font-medium text-[#26454c]">
<label htmlFor="qr-custom" className="block text-sm font-medium text-body">
Link
</label>
<input
@ -337,7 +338,7 @@ export default function QrCodeMaker() {
) : needsDirectory && loading && !directory ? (
<p style={{ color: MUTED }}>Loading the list…</p>
) : needsDirectory && error ? (
<p className="text-[#b3261e]">Couldn't load the list of pages. {error}</p>
<p className="text-danger">Couldn't load the list of pages. {error}</p>
) : choices.length === 0 ? (
<p style={{ color: MUTED }}>Nothing published here yet.</p>
) : (
@ -390,7 +391,7 @@ export default function QrCodeMaker() {
</Select>
<fieldset>
<legend className="text-sm font-medium text-[#26454c]">Colours</legend>
<legend className="text-sm font-medium text-body">Colours</legend>
<div className="mt-2 flex flex-wrap items-end gap-5">
<ColourInput id="qr-ink" label="Code" value={ink} onChange={setInk} />
<ColourInput id="qr-paper" label="Background" value={paper} onChange={setPaper} />
@ -406,14 +407,14 @@ export default function QrCodeMaker() {
setDoveColor(QR_DOVE)
}}
className="pb-2 text-sm underline"
style={{ color: TEAL }}
style={{ color: accentText(TEAL) }}
>
Reset colours
</button>
)}
</div>
{warning && (
<p role="status" className="mt-2 rounded-lg bg-[#fdf3f2] px-3 py-2 text-sm text-[#b3261e]">
<p role="status" className="mt-2 rounded-lg bg-danger-tint px-3 py-2 text-sm text-danger">
{warning}
</p>
)}
@ -421,16 +422,16 @@ export default function QrCodeMaker() {
{url && (
<div>
<p className="text-sm font-medium text-[#26454c]">Links to</p>
<p className="text-sm font-medium text-body">Links to</p>
<div className="mt-2 flex flex-wrap items-center gap-3">
<code className="break-all rounded-lg bg-white px-3 py-2 text-sm text-[#26454c] ring-1 ring-[#4a6b72]/20">
<code className="break-all rounded-lg bg-surface px-3 py-2 text-sm text-body ring-1 ring-muted/20">
{url}
</code>
<button
type="button"
onClick={copy}
className="rounded-full border px-4 py-2 text-sm font-semibold transition-colors hover:bg-[#138ba0]/10"
style={{ borderColor: TEAL, color: TEAL }}
className="rounded-full border px-4 py-2 text-sm font-semibold transition-colors hover:bg-brand/10"
style={{ borderColor: TEAL, color: accentText(TEAL) }}
>
{copied ? 'Copied ✓' : 'Copy link'}
</button>
@ -442,7 +443,7 @@ export default function QrCodeMaker() {
<div className="flex flex-col items-center gap-5">
{url ? (
<>
<div className="w-full max-w-sm rounded-3xl bg-white p-6 shadow-lg ring-1 ring-[#4a6b72]/10">
<div className="w-full max-w-sm rounded-3xl bg-white p-6 shadow-lg ring-1 ring-muted/10">
<QrCode
ref={svgRef}
value={url}
@ -467,7 +468,7 @@ export default function QrCodeMaker() {
</p>
</>
) : (
<div className="aspect-square w-full max-w-sm rounded-3xl bg-white/60 ring-1 ring-[#4a6b72]/10" />
<div className="aspect-square w-full max-w-sm rounded-3xl bg-white/60 ring-1 ring-muted/10" />
)}
</div>
</div>
@ -479,7 +480,7 @@ function DownloadButton({ onClick, children }: { onClick: () => void; children:
<button
type="button"
onClick={onClick}
className="rounded-full bg-[#0f7183] px-6 py-3 font-semibold text-white transition-colors hover:bg-[#0b5c6a] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#138ba0]/40"
className="rounded-full bg-action px-6 py-3 font-semibold text-white transition-colors hover:bg-action-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand/40"
>
{children}
</button>
@ -487,8 +488,8 @@ function DownloadButton({ onClick, children }: { onClick: () => void; children:
}
const inputClass =
'w-full rounded-xl border border-[#4a6b72]/25 bg-white px-4 py-3 text-[#26454c] ' +
'outline-none transition-colors focus:border-[#138ba0] focus:ring-2 focus:ring-[#138ba0]/25'
'w-full rounded-xl border border-muted/25 bg-surface px-4 py-3 text-body ' +
'outline-none transition-colors focus:border-brand focus:ring-2 focus:ring-brand/25'
/* A colour well with its hex beside it, both editable. */
function ColourInput({
@ -515,7 +516,7 @@ function ColourInput({
type="color"
value={value}
onChange={(e) => onChange(e.target.value)}
className="h-9 w-11 cursor-pointer rounded border border-[#4a6b72]/25 bg-white"
className="h-9 w-11 cursor-pointer rounded border border-muted/25 bg-white"
/>
<input
type="text"
@ -525,7 +526,7 @@ function ColourInput({
setText(e.target.value)
if (/^#[0-9a-f]{6}$/i.test(e.target.value)) onChange(e.target.value.toLowerCase())
}}
className="w-24 rounded-lg border border-[#4a6b72]/25 bg-white px-2 py-1.5 font-mono text-sm text-[#26454c] outline-none focus:border-[#138ba0]"
className="w-24 rounded-lg border border-muted/25 bg-surface px-2 py-1.5 font-mono text-sm text-body outline-none focus:border-brand"
/>
</div>
</div>
@ -533,8 +534,8 @@ function ColourInput({
}
const selectClass =
'w-full appearance-none rounded-xl border border-[#4a6b72]/25 bg-white px-4 py-3 pr-10 text-[#26454c] ' +
'outline-none transition-colors focus:border-[#138ba0] focus:ring-2 focus:ring-[#138ba0]/25'
'w-full appearance-none rounded-xl border border-muted/25 bg-surface px-4 py-3 pr-10 text-body ' +
'outline-none transition-colors focus:border-brand focus:ring-2 focus:ring-brand/25'
function Select({
id,
@ -551,7 +552,7 @@ function Select({
}) {
return (
<div>
<label htmlFor={id} className="block text-sm font-medium text-[#26454c]">
<label htmlFor={id} className="block text-sm font-medium text-body">
{label}
</label>
<div className="relative mt-2">