Skip to content

feat(theming): themes you can choose, edit, and take with you (#350) - #638

Merged
EVWorth merged 1 commit into
mainfrom
feat/theming-custom-themes
Sep 11, 2026
Merged

EVWorth merged 1 commit into
mainfrom
feat/theming-custom-themes

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Follows #636.

NFR-5.2 asks for a CSS-based theme system, an editor with live preview, and import/export. What existed was dark and light written into globals.css and a system mode resolving to one of them — nothing a user could add, edit or keep.

A theme is now data: sixteen colour tokens, a name, and which way round it reads. Applying one writes those tokens onto the document element, which is where the whole stylesheet already reads from.

Three themes beyond the originals, chosen for what they do rather than for count: two long-standing palettes people already have opinions about (Nord, Solarized Light), and High Contrast. That last is an accessibility need rather than a taste — the default dark theme's border sits at about 1.3:1 against its background, which is not a line anyone can rely on seeing.

The preview is the app

A swatch pane would show colours without showing what they do to a dense grid or a code editor, which is the only question worth asking of a theme. So selecting one applies it, an edit applies as it is typed, and abandoning an edit puts back what was showing. Nothing is written down until Save.

Editing a built-in opens a copy, so the original stays reachable. The editor warns when text on the background falls below WCAG AA and says what the ratio is — without blocking, because a theme mid-edit is allowed to be unreadable and being told so is the point.

Import and export are files, which is what makes a theme shareable without the app knowing anything about where it came from.

Monaco follows

The editor now takes its colours from the same palette. With two themes that difference didn't show; with five it does, and a Nord window with a generic dark editor in the middle of it reads as a bug. Monaco's own syntax colours are kept — an eleven-colour app palette has nothing to say about how a SQL keyword should differ from a string literal.

Trust boundary

Imported themes are validated field by field, not cast. This is the one place a stranger's data reaches the stylesheet, and --color-bg-primary: url(https://…) is a request the app would then make on their behalf. Stored custom themes are re-validated on read for the same reason — the file is editable. Tests cover CSS functions, named colours, and a value carrying a semicolon.

globals.css keeps its two blocks as the floor: what the app looks like between the stylesheet loading and the first script running, and the fallback for a theme that omits a token. A test compares them against themes.ts, because drift there shows up as a flash of the wrong colour. (Mutation-checked.)

On the community theme repository

NFR-5.2's fourth clause asks for one. I've left it out deliberately: a community repository is a hosted service with moderation, review and abuse handling attached — not a feature of a desktop client. Import/export covers sharing; a registry is a separate decision with running costs. Happy to file it as its own issue if you want it tracked.

Found on the way

themeStore.test.ts cleared mocks rather than restoring them, so the test that makes localStorage.getItem throw was still throwing in every test that followed it.

2535 unit + 340 browser tests. 36 on the theme model (including WCAG contrast floors for every built-in), 18 new on the store, 19 on the dialog, 11 on the Monaco bridge.

Closes #350

🤖 Generated with Claude Code

NFR-5.2 asks for a CSS-based theme system, an editor with live preview, and
import/export. What existed was `dark` and `light` written into globals.css
and a `system` mode resolving to one of them — nothing a user could add, edit
or keep (#350).

A theme is now data: sixteen colour tokens, a name, and which way round it
reads. Applying one writes those tokens onto the document element, which is
where the whole stylesheet already reads from.

Three themes beyond the originals, chosen for what they do rather than for
count: two long-standing palettes people already have opinions about, and a
high-contrast one. That last is an accessibility need rather than a taste —
the default dark theme's border sits at about 1.3:1 against its background,
which is not a line anyone can rely on seeing.

The preview is the app. A swatch pane would show colours without showing what
they do to a dense grid or a code editor, which is the only question worth
asking of a theme — so selecting one applies it, an edit applies as it is
typed, and abandoning an edit puts back what was showing. Nothing is written
down until Save.

Editing a built-in opens a copy, so the original stays reachable. The editor
warns when text on the background falls below WCAG AA and says what the ratio
is, without blocking: a theme mid-edit is allowed to be unreadable, and being
told so is the point.

Import and export are files, which is the part that makes a theme something
you can share without the app knowing anything about where it came from.

The Monaco editor now takes its colours from the same palette. With two themes
that difference did not show; with five it does, and a Nord window with a
generic dark editor in the middle of it reads as a bug. Monaco's own syntax
colours are kept — an eleven-colour app palette has nothing to say about how a
SQL keyword should differ from a string literal.

Imported themes are validated field by field rather than cast. This is the one
place a stranger's data reaches the stylesheet, and `--color-bg-primary:
url(https://…)` is a request the app would then make on their behalf. Stored
custom themes are re-validated on read for the same reason — the file is
editable.

globals.css keeps its two blocks as the floor: what the app looks like between
the stylesheet loading and the first script running, and the fallback for a
theme that omits a token. A test compares the two against themes.ts, because
drift there shows up as a flash of the wrong colour.

Found on the way: `themeStore.test.ts` cleared mocks rather than restoring
them, so the test that makes `localStorage.getItem` throw was still throwing
in every test that followed it.

Co-Authored-By: Claude Opus 5 <[email protected]>
@EVWorth
EVWorth merged commit 875662a into main Sep 11, 2026
12 checks passed
@EVWorth
EVWorth deleted the feat/theming-custom-themes branch September 11, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1/doc-drift] NFR-5.2 custom themes — no theme editor, no import/export, no community repo

1 participant