Repository navigation
feat(theming): themes you can choose, edit, and take with you (#350) - #638
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows #636.
NFR-5.2 asks for a CSS-based theme system, an editor with live preview, and import/export. What existed was
darkandlightwritten intoglobals.cssand asystemmode 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.csskeeps 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 againstthemes.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.tscleared mocks rather than restoring them, so the test that makeslocalStorage.getItemthrow 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