themes-v1: 18 preset palettes + Settings picker
Adds 18 preset themes (16 dual-mode + 2 light-only) selectable from
a new /settings route. Persists per-user via the existing key-value
settings table — no schema refactor. Default on first load is
obsidian dark.
Storage: two new seeded keys (theme_id, theme_mode) inserted
idempotently from schema.sql. PATCH /api/settings tightens validation
with a discriminated branch — theme_id must be one of the 18
whitelisted ids, theme_mode ∈ {dark,light,system}, anything else
rejects 400. Other keys pass through the loose record schema.
CSS layer: 18 files in apps/web/src/styles/themes/, each declaring
.theme-<id> (light) and .theme-<id>.dark (dark) — except ivory and
chalk which are light-only. Anchor-to-token mapping per spec §3.
--destructive stays red across all themes. --radius unchanged at
0.625rem (spec parenthetical was about "not per-theme", not a
specific value swap).
Frontend: lib/theme.ts owns THEMES, applyTheme(), setTheme(), and
useTheme() — module-singleton with optimistic PATCH + revert on
failure (mirrors useChatStatus / useSidebar pattern). Settings.tsx
renders a 3-col (md) / 2-col (mobile) grid of shadcn Card swatches
with a Dark/Light/System radio group on top. App.tsx mounts
useTheme() at AppShell top and wires the /settings route.
index.html ships a pre-React FOUC script that reads localStorage
'boocode.theme' and stamps the className on <html> before any
paint. Stripped two pre-existing dark-mode lock-ins (AppShell's
hardcoded 'dark' className and body's neutral-950/100 tailwind
utilities) that would have fought theme tokens.
Light-only + dark request → falls back to obsidian dark in three
places: lib/theme.ts effectiveThemeId(), the FOUC script, and the
picker's "Light only" badge. No inline message; matches spec §8
decision 1.
shadcn primitives card and radio-group installed via shadcn CLI
(no hand-rolling). card.tsx and radio-group.tsx are the only ui/
additions.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
60
apps/web/src/styles/themes/gunmetal.css
Normal file
60
apps/web/src/styles/themes/gunmetal.css
Normal file
@@ -0,0 +1,60 @@
|
||||
/* themes-v1: Gunmetal (family: charcoal/black).
|
||||
Dark anchors: #0d1117 #161b22 #21262d #7d8590 #388bfd. */
|
||||
.theme-gunmetal {
|
||||
--background: #fafafa;
|
||||
--foreground: #14181f;
|
||||
--card: #f1f3f6;
|
||||
--card-foreground: #14181f;
|
||||
--popover: #f1f3f6;
|
||||
--popover-foreground: #14181f;
|
||||
--primary: #0c6dd0;
|
||||
--primary-foreground: #ffffff;
|
||||
--secondary: #dde1e8;
|
||||
--secondary-foreground: #14181f;
|
||||
--muted: #dde1e8;
|
||||
--muted-foreground: #5a6470;
|
||||
--accent: #0c6dd0;
|
||||
--accent-foreground: #ffffff;
|
||||
--destructive: #b91c1c;
|
||||
--destructive-foreground: #ffffff;
|
||||
--border: #dde1e8;
|
||||
--input: #dde1e8;
|
||||
--ring: #0c6dd0;
|
||||
--sidebar: #f1f3f6;
|
||||
--sidebar-foreground: #14181f;
|
||||
--sidebar-primary: #0c6dd0;
|
||||
--sidebar-primary-foreground: #ffffff;
|
||||
--sidebar-accent: #dde1e8;
|
||||
--sidebar-accent-foreground: #14181f;
|
||||
--sidebar-border: #dde1e8;
|
||||
--sidebar-ring: #0c6dd0;
|
||||
}
|
||||
.theme-gunmetal.dark {
|
||||
--background: #0d1117;
|
||||
--foreground: #e6ecf0;
|
||||
--card: #161b22;
|
||||
--card-foreground: #e6ecf0;
|
||||
--popover: #161b22;
|
||||
--popover-foreground: #e6ecf0;
|
||||
--primary: #388bfd;
|
||||
--primary-foreground: #0d1117;
|
||||
--secondary: #21262d;
|
||||
--secondary-foreground: #e6ecf0;
|
||||
--muted: #21262d;
|
||||
--muted-foreground: #7d8590;
|
||||
--accent: #388bfd;
|
||||
--accent-foreground: #0d1117;
|
||||
--destructive: #dc2626;
|
||||
--destructive-foreground: #ffffff;
|
||||
--border: #21262d;
|
||||
--input: #21262d;
|
||||
--ring: #388bfd;
|
||||
--sidebar: #161b22;
|
||||
--sidebar-foreground: #e6ecf0;
|
||||
--sidebar-primary: #388bfd;
|
||||
--sidebar-primary-foreground: #0d1117;
|
||||
--sidebar-accent: #388bfd;
|
||||
--sidebar-accent-foreground: #0d1117;
|
||||
--sidebar-border: #21262d;
|
||||
--sidebar-ring: #388bfd;
|
||||
}
|
||||
Reference in New Issue
Block a user