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

@ -18,9 +18,10 @@ import { useCallback, useEffect, useRef, useState, type ReactNode } from "react"
import { Link } from "react-router-dom";
import { ApiError, del, get, post } from "../../lib/api.ts";
import { accentText } from '../../lib/color.ts'
const TEAL = "#0f7183";
const MUTED = "#4a6b72";
const MUTED = "var(--color-muted)";
const POLL_MS = 2000;
type Job = {
@ -81,29 +82,29 @@ function sizeOf(bytes: number | null): string {
}
const button =
"rounded-full border border-[#138ba0] px-4 py-2 text-sm font-semibold text-[#0f7183] transition-colors hover:bg-[#eef9fb] disabled:cursor-default disabled:opacity-50";
"rounded-full border border-brand px-4 py-2 text-sm font-semibold text-link transition-colors hover:bg-tint disabled:cursor-default disabled:opacity-50";
const primary =
"rounded-full bg-[#0f7183] px-5 py-2.5 font-semibold text-white transition-colors hover:bg-[#0b5c6a] disabled:bg-[#4a6b72]/25";
"rounded-full bg-action px-5 py-2.5 font-semibold text-white transition-colors hover:bg-action-hover disabled:bg-muted/25";
const input =
"rounded-lg border border-[#4a6b72]/25 bg-white px-3 py-2 text-sm text-[#26454c] outline-none focus:border-[#138ba0] focus:ring-2 focus:ring-[#138ba0]/25";
"rounded-lg border border-muted/25 bg-surface px-3 py-2 text-sm text-body outline-none focus:border-brand focus:ring-2 focus:ring-brand/25";
function Card({ title, children }: { title: string; children: ReactNode }) {
return (
<section className="mt-6 rounded-2xl border border-[#138ba0]/20 bg-white p-5">
<h2 className="text-lg font-semibold text-[#26454c]">{title}</h2>
<section className="mt-6 rounded-2xl border border-brand/20 bg-surface p-5">
<h2 className="text-lg font-semibold text-body">{title}</h2>
<div className="mt-4">{children}</div>
</section>
);
}
function Status({ job }: { job: Job }) {
if (job.status === "failed") return <p className="text-sm text-[#b3261e]">Failed: {job.error}</p>;
if (job.status === "failed") return <p className="text-sm text-danger">Failed: {job.error}</p>;
if (job.status === "done") return null;
const percent = Math.round(job.progress * 100);
return (
<div className="mt-2">
<div className="h-2 overflow-hidden rounded-full bg-[#eef9fb]">
<div className="h-full bg-[#0f7183] transition-all" style={{ width: `${job.status === "queued" ? 0 : percent}%` }} />
<div className="h-2 overflow-hidden rounded-full bg-tint">
<div className="h-full bg-action transition-all" style={{ width: `${job.status === "queued" ? 0 : percent}%` }} />
</div>
<p className="mt-1 text-xs" style={{ color: MUTED }}>
{job.status === "queued" ? "Waiting its turn…" : `${percent}%`}
@ -212,7 +213,7 @@ function Editor({ source, onMade }: { source: Job; onMade: () => void }) {
] as const
).map(([label, text, setText, setAt, value]) => (
<div key={label}>
<label className="block text-sm font-medium text-[#26454c]" htmlFor={`clip-${label}`}>
<label className="block text-sm font-medium text-body" htmlFor={`clip-${label}`}>
{label}
</label>
<input
@ -233,7 +234,7 @@ function Editor({ source, onMade }: { source: Job; onMade: () => void }) {
<button
type="button"
className="text-sm underline"
style={{ color: TEAL }}
style={{ color: accentText(TEAL) }}
onClick={() => {
if (videoRef.current) videoRef.current.currentTime = value;
}}
@ -249,7 +250,7 @@ function Editor({ source, onMade }: { source: Job; onMade: () => void }) {
</p>
<div>
<p className="text-sm font-medium text-[#26454c]">Make it</p>
<p className="text-sm font-medium text-body">Make it</p>
<div className="mt-2 flex gap-4 text-sm">
{[
["video", "Video (MP4)"],
@ -265,7 +266,7 @@ function Editor({ source, onMade }: { source: Job; onMade: () => void }) {
{format === "video" && (
<div>
<p className="text-sm font-medium text-[#26454c]">Shape</p>
<p className="text-sm font-medium text-body">Shape</p>
<div className="mt-2 grid gap-1.5 text-sm">
{SHAPES.map(([id, label]) => (
<label key={id} className="flex items-center gap-2">
@ -275,7 +276,7 @@ function Editor({ source, onMade }: { source: Job; onMade: () => void }) {
))}
</div>
{target && (
<label className="mt-3 block text-sm text-[#26454c]">
<label className="mt-3 block text-sm text-body">
Where to crop
<input
type="range"
@ -284,7 +285,7 @@ function Editor({ source, onMade }: { source: Job; onMade: () => void }) {
step={0.01}
value={focus}
onChange={(e) => setFocus(Number(e.target.value))}
className="mt-1 w-full accent-[#138ba0]"
className="mt-1 w-full accent-brand"
/>
<span className="text-xs" style={{ color: MUTED }}>
The white box on the video is what's kept.
@ -297,7 +298,7 @@ function Editor({ source, onMade }: { source: Job; onMade: () => void }) {
<button type="button" className={primary} disabled={busy || end <= start} onClick={make}>
{busy ? "Queuing…" : "Make clip"}
</button>
{error && <p className="text-sm text-[#b3261e]">{error}</p>}
{error && <p className="text-sm text-danger">{error}</p>}
</div>
</div>
);
@ -368,14 +369,14 @@ export default function AdminClips() {
return (
<div>
<div className="flex flex-wrap items-baseline gap-3">
<h1 className="text-2xl font-bold text-[#0f7183]">Video clips</h1>
<h1 className="text-2xl font-bold text-link">Video clips</h1>
<p className="text-sm" style={{ color: MUTED }}>
Cut clips from our YouTube and Facebook videos, for Reels, Shorts, the site or a podcast.
</p>
</div>
{missing.length > 0 && (
<p className="mt-4 rounded-xl bg-[#fdf3f2] px-4 py-3 text-sm text-[#b3261e]">
<p className="mt-4 rounded-xl bg-danger-tint px-4 py-3 text-sm text-danger">
{missing.join(" and ")} {missing.length > 1 ? "aren't" : "isn't"} installed on the server, so this
won't work until {missing.length > 1 ? "they are" : "it is"}. See docs/video-clips.md.
</p>
@ -397,15 +398,15 @@ export default function AdminClips() {
<p className="mt-2 text-xs" style={{ color: MUTED }}>
YouTube and Facebook links only, and only videos NGU owns or has permission to use. Up to 4 hours long.
</p>
{addError && <p className="mt-2 text-sm text-[#b3261e]">{addError}</p>}
{addError && <p className="mt-2 text-sm text-danger">{addError}</p>}
{data.sources.length > 0 && (
<ul className="mt-5 divide-y divide-[#138ba0]/10">
<ul className="mt-5 divide-y divide-brand/10">
{data.sources.map((s) => (
<li key={s.id} className="py-3">
<div className="flex flex-wrap items-center gap-3">
<div className="min-w-0 flex-1">
<p className="truncate font-medium text-[#26454c]">{s.title ?? s.source_url}</p>
<p className="truncate font-medium text-body">{s.title ?? s.source_url}</p>
<p className="text-xs" style={{ color: MUTED }}>
{[s.duration && clock(s.duration), sizeOf(s.bytes)].filter(Boolean).join(" · ")}
</p>
@ -418,7 +419,7 @@ export default function AdminClips() {
{s.status !== "running" && (
<button
type="button"
className="text-sm hover:text-[#b3261e]"
className="text-sm hover:text-danger"
style={{ color: MUTED }}
onClick={() =>
window.confirm("Delete this video and its clips from the server?") &&
@ -444,13 +445,13 @@ export default function AdminClips() {
{data.clips.length > 0 && (
<Card title="Clips">
{rowError && <p className="mb-3 text-sm text-[#b3261e]">{rowError}</p>}
<ul className="divide-y divide-[#138ba0]/10">
{rowError && <p className="mb-3 text-sm text-danger">{rowError}</p>}
<ul className="divide-y divide-brand/10">
{data.clips.map((clip) => (
<li key={clip.id} className="py-3">
<div className="flex flex-wrap items-center gap-3">
<div className="min-w-0 flex-1">
<p className="truncate font-medium text-[#26454c]">{sourceTitle(clip.source_id)}</p>
<p className="truncate font-medium text-body">{sourceTitle(clip.source_id)}</p>
<p className="text-xs" style={{ color: MUTED }}>
{clip.params &&
[
@ -480,7 +481,7 @@ export default function AdminClips() {
</>
)}
{clip.saved_url && (
<Link to="/admin/media" className="text-sm underline" style={{ color: TEAL }}>
<Link to="/admin/media" className="text-sm underline" style={{ color: accentText(TEAL) }}>
In the media library
</Link>
)}
@ -492,7 +493,7 @@ export default function AdminClips() {
{clip.status !== "running" && (
<button
type="button"
className="text-sm hover:text-[#b3261e]"
className="text-sm hover:text-danger"
style={{ color: MUTED }}
onClick={() => act(() => del(`/admin/clips/${clip.id}`))}
>