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

@ -47,6 +47,7 @@ import { EVENT_TYPES, eventTypeLabel, type EventType } from '../../lib/eventType
import { firstOccurrenceFrom, occurrencesBetween, seriesTimes } from '../../lib/eventSeries.ts'
import { eventHref } from '../../lib/hrefs.ts'
import type { EventListItem } from '../../lib/useContent.ts'
import { withAlpha, accentText, readableOn } from '../../lib/color.ts'
export type CalendarControl = 'scope' | 'type' | 'online' | 'search'
export type CalendarView = 'month' | 'list'
@ -57,8 +58,8 @@ const ALL_CONTROLS: CalendarControl[] = ['scope', 'type', 'online', 'search']
const MAX_LANES = 3
const TEAL = '#0f7183'
const INK = '#073d4a'
const BODY = '#4a6b72'
const INK = 'var(--color-ink)'
const BODY = 'var(--color-muted)'
const WEEKDAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
@ -326,8 +327,8 @@ export default function EventCalendar({
<button
type="button"
onClick={() => go(monthKey(today))}
className="rounded-full border px-3 py-1 text-sm font-semibold hover:bg-white"
style={{ borderColor: accent, color: accent }}
className="rounded-full border px-3 py-1 text-sm font-semibold hover:bg-surface"
style={{ borderColor: accent, color: accentText(accent) }}
>
Today
</button>
@ -348,8 +349,8 @@ export default function EventCalendar({
className="px-4 py-1.5 text-sm font-semibold capitalize transition-colors"
style={
view === option
? { background: accent, color: '#ffffff' }
: { color: accent }
? { background: accent, color: readableOn(accent) }
: { color: accentText(accent) }
}
>
{option}
@ -380,7 +381,7 @@ export default function EventCalendar({
/>
)}
{show('online') && (
<label className="flex cursor-pointer items-center gap-2 rounded-full border border-[#138ba0]/25 bg-white px-4 py-2 text-sm">
<label className="flex cursor-pointer items-center gap-2 rounded-full border border-brand/25 bg-surface px-4 py-2 text-sm">
<input
type="checkbox"
checked={onlineOnly}
@ -398,7 +399,7 @@ export default function EventCalendar({
onChange={(e) => setQuery(e.target.value)}
placeholder="Search events"
aria-label="Search events"
className="min-w-[12rem] flex-1 rounded-full border border-[#138ba0]/25 bg-white px-4 py-2 text-sm outline-none focus:border-[#0f7183] focus:ring-2 focus:ring-[#0f7183]/40 md:max-w-xs"
className="min-w-[12rem] flex-1 rounded-full border border-brand/25 bg-surface px-4 py-2 text-sm outline-none focus:border-link focus:ring-2 focus:ring-link/40 md:max-w-xs"
/>
)}
{filtering && (
@ -406,7 +407,7 @@ export default function EventCalendar({
type="button"
onClick={clearFilters}
className="text-sm font-semibold hover:underline"
style={{ color: accent }}
style={{ color: accentText(accent) }}
>
Clear filters
</button>
@ -417,7 +418,7 @@ export default function EventCalendar({
{/* ── Body ── */}
<div className="mt-6">
{error ? (
<p className="rounded-2xl bg-white p-6 text-[#b3261e]">
<p className="rounded-2xl bg-surface p-6 text-danger">
Couldn’t load events. {error.message}
</p>
) : loading ? (
@ -457,7 +458,7 @@ export default function EventCalendar({
type="button"
onClick={() => go(monthKey(next))}
className="font-semibold hover:underline"
style={{ color: accent }}
style={{ color: accentText(accent) }}
>
Jump to the next event, {monthTitle(monthKey(next))} →
</button>
@ -494,8 +495,8 @@ type MonthGridProps = {
function MonthGrid({ weeks, month, today, occurrences, selected, onSelect, accent }: MonthGridProps) {
return (
<div className="overflow-hidden rounded-3xl border border-[#138ba0]/15 bg-white shadow-sm">
<div className="grid grid-cols-7 border-b border-[#138ba0]/10 bg-[#f6fbfc]">
<div className="overflow-hidden rounded-3xl border border-brand/15 bg-surface shadow-sm">
<div className="grid grid-cols-7 border-b border-brand/10 bg-tint-soft">
{WEEKDAYS.map((day) => (
<div
key={day}
@ -516,7 +517,7 @@ function MonthGrid({ weeks, month, today, occurrences, selected, onSelect, accen
segments.filter((s) => s.col <= col && s.col + s.span > col).length
return (
<div key={week[0]} className="relative min-h-[8rem] border-b border-[#138ba0]/10 last:border-b-0">
<div key={week[0]} className="relative min-h-[8rem] border-b border-brand/10 last:border-b-0">
{/* Day cells: the click targets, and the numbers. */}
<div className="absolute inset-0 grid grid-cols-7">
{week.map((date, col) => {
@ -532,23 +533,23 @@ function MonthGrid({ weeks, month, today, occurrences, selected, onSelect, accen
onClick={() => onSelect(date)}
aria-pressed={isSelected}
aria-label={`${longDay(date)}${count ? `, ${count} event${count === 1 ? '' : 's'}` : ''}`}
className="relative flex flex-col items-start border-r border-[#138ba0]/10 p-2 text-left transition-colors last:border-r-0 hover:bg-[#f6fbfc]"
className="relative flex flex-col items-start border-r border-brand/10 p-2 text-left transition-colors last:border-r-0 hover:bg-tint-soft"
style={{
background: isSelected ? `${accent}14` : outside ? '#fbfdfd' : undefined,
background: isSelected ? `${withAlpha(accent, 8)}` : outside ? 'var(--color-tint-soft)' : undefined,
}}
>
<span
className="flex h-7 w-7 items-center justify-center rounded-full text-sm font-semibold"
style={
isToday
? { background: accent, color: '#ffffff' }
: { color: outside ? '#b8c6c9' : INK }
? { background: accent, color: readableOn(accent) }
: { color: outside ? withAlpha('var(--color-muted)', 60) : INK }
}
>
{Number(date.slice(8))}
</span>
{hidden > 0 && (
<span className="mt-auto text-xs font-semibold" style={{ color: accent }}>
<span className="mt-auto text-xs font-semibold" style={{ color: accentText(accent) }}>
+{hidden} more
</span>
)}
@ -620,14 +621,14 @@ function DayPanel({
onClose: () => void
}) {
return (
<div className="mt-4 rounded-3xl border bg-white p-6" style={{ borderColor: `${accent}40` }}>
<div className="mt-4 rounded-3xl border bg-surface p-6" style={{ borderColor: `${withAlpha(accent, 25)}` }}>
<div className="flex items-center gap-4">
<h4 className="font-display text-lg font-bold">{longDay(date)}</h4>
<button
type="button"
onClick={onClose}
className="ml-auto text-sm font-semibold hover:underline"
style={{ color: accent }}
style={{ color: accentText(accent) }}
>
Close
</button>
@ -664,7 +665,7 @@ function MonthList({
}) {
if (items.length === 0) {
return (
<p className="rounded-3xl bg-white p-10 text-center" style={{ color: BODY }}>
<p className="rounded-3xl bg-surface p-10 text-center" style={{ color: BODY }}>
Nothing on the calendar this month.
</p>
)
@ -683,9 +684,9 @@ function MonthList({
{[...byDay.entries()].map(([day, list]) => {
const d = parse(day)
return (
<li key={day} className="flex gap-5 rounded-3xl bg-white p-5 shadow-sm">
<li key={day} className="flex gap-5 rounded-3xl bg-surface p-5 shadow-sm">
<div className="w-14 shrink-0 text-center">
<p className="text-xs font-bold uppercase tracking-widest" style={{ color: accent }}>
<p className="text-xs font-bold uppercase tracking-widest" style={{ color: accentText(accent) }}>
{d.toLocaleDateString(undefined, { weekday: 'short' })}
</p>
<p className="font-display text-3xl font-extrabold leading-none">{d.getDate()}</p>
@ -715,13 +716,13 @@ function EventLine({ item, accent }: { item: Occurrence; accent: string }) {
return (
<Link
to={eventHref(event.id)}
className="group flex items-start gap-3 rounded-xl p-2 transition-colors hover:bg-[#f6fbfc]"
className="group flex items-start gap-3 rounded-xl p-2 transition-colors hover:bg-tint-soft"
>
<span className="mt-1.5 h-3 w-3 shrink-0 rounded-full" style={{ background: color }} aria-hidden="true" />
<span className="min-w-0">
<span className={`block font-semibold group-hover:underline ${cancelled ? 'line-through' : ''}`}>
{event.title}
{cancelled && <span className="ml-2 text-xs font-bold uppercase text-[#b3261e] no-underline">Cancelled</span>}
{cancelled && <span className="ml-2 text-xs font-bold uppercase text-danger no-underline">Cancelled</span>}
</span>
<span className="block text-sm" style={{ color: BODY }}>
{[
@ -755,8 +756,8 @@ function NavButton({
type="button"
onClick={onClick}
aria-label={label}
className="flex h-10 w-10 items-center justify-center rounded-full border text-xl transition-colors hover:bg-white"
style={{ borderColor: accent, color: accent }}
className="flex h-10 w-10 items-center justify-center rounded-full border text-xl transition-colors hover:bg-surface"
style={{ borderColor: accent, color: accentText(accent) }}
>
{children}
</button>
@ -781,7 +782,7 @@ function FilterSelect({
value={value}
onChange={(e) => onChange(e.target.value)}
aria-label={label}
className="rounded-full border border-[#138ba0]/25 bg-white px-4 py-2 text-sm outline-none focus:border-[#0f7183] focus:ring-2 focus:ring-[#0f7183]/40"
className="rounded-full border border-brand/25 bg-surface px-4 py-2 text-sm outline-none focus:border-link focus:ring-2 focus:ring-link/40"
>
<option value="">{all}</option>
{options.map(([id, name]) => (