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:
parent
a225e84408
commit
f1edaaf92a
9 changed files with 258 additions and 4 deletions
28
server/src/migrations/041_site_colors.sql
Normal file
28
server/src/migrations/041_site_colors.sql
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 041 SITE COLOURS
|
||||
--
|
||||
-- The admin's palette (Panel → Site settings → Colours): one row per
|
||||
-- colour token that differs from the site's own (src/index.css), with
|
||||
-- a light and a dark value. Blank keeps that mode's default. The
|
||||
-- server writes them into every page (server/src/theme.js) and
|
||||
-- refuses a save that would make text hard to read.
|
||||
--
|
||||
-- token one of the tokens in THEME_DEFAULTS (theme.js), which
|
||||
-- the admin's dropdown offers
|
||||
-- light '#rrggbb', or null for the default
|
||||
-- dark '#rrggbb', or null for the default
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
CREATE TABLE site_setting_colors (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
settings_id TEXT NOT NULL REFERENCES site_settings (id) ON DELETE CASCADE,
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
token TEXT NOT NULL CHECK (token IN (
|
||||
'ink', 'body', 'muted', 'link', 'brand', 'action', 'action-hover',
|
||||
'surface', 'tint', 'tint-soft', 'danger', 'danger-tint')),
|
||||
light TEXT CONSTRAINT "A colour must be written #rrggbb, eg. #0f7183."
|
||||
CHECK (light IS NULL OR (length(light) = 7 AND light GLOB '#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]')),
|
||||
dark TEXT CONSTRAINT "A dark colour must be written #rrggbb, eg. #5ccbdc."
|
||||
CHECK (dark IS NULL OR (length(dark) = 7 AND dark GLOB '#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]')),
|
||||
UNIQUE (settings_id, token)
|
||||
) STRICT;
|
||||
Loading…
Add table
Add a link
Reference in a new issue