Let superadmins change the whole colour palette

Panel -> Site settings -> Colours: any colour token, with a light and a
dark value (migration 041). The server writes the overrides into each
page's head in the same cascade layers as index.css, so a light-only
change leaves dark mode alone. Values must be #rrggbb (a table CHECK),
and saving refuses a palette that puts any text under 4.5:1 in either
mode, through a new descriptor hook, check(db, id), run inside the
save's transaction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-28 23:26:35 -05:00
parent a225e84408
commit f1edaaf92a
9 changed files with 258 additions and 4 deletions

View file

@ -125,6 +125,14 @@ const inputLocked =
/* ── Dotted paths ────────────────────────────────────────────── */
/* What an empty colour field shows in its swatch and placeholder:
the field's own default (a value, or one worked out from the row),
else the brand teal. */
function colorPlaceholder(field, row): string {
const own = typeof field.placeholder === "function" ? field.placeholder(row) : field.placeholder;
return own || "#138ba0";
}
export function getPath(object, path) {
// An entity with no slug has no heading path either, and a missing
// path should read as "no value" rather than throwing on .split.
@ -274,7 +282,7 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
<div className="flex gap-2">
<input
type="color"
value={/^#[0-9a-f]{6}$/i.test(value ?? "") ? value : "#138ba0"}
value={/^#[0-9a-f]{6}$/i.test(value ?? "") ? value : colorPlaceholder(field, row)}
disabled={locked}
onChange={(e) => onChange(e.target.value)}
className="h-9 w-12 shrink-0 rounded border border-muted/25 bg-surface disabled:opacity-50"
@ -282,7 +290,7 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
<input
{...common}
readOnly={locked}
placeholder="#138ba0"
placeholder={colorPlaceholder(field, row)}
className={locked ? inputLocked : common.className}
/>
</div>