feat: dark mode and a theme toggle in the generated viewer - #14
Open
DanielMontilla wants to merge 2 commits into
Open
feat: dark mode and a theme toggle in the generated viewer#14DanielMontilla wants to merge 2 commits into
DanielMontilla wants to merge 2 commits into
Conversation
added 2 commits
August 31, 2026 19:41
The Docsify viewer (leji view / leji viewer build) follows the OS scheme by default and offers a fixed pill that cycles system -> light -> dark and persists the choice in localStorage. - A new vendored theme-init.js runs in <head> before first paint, writing the effective theme to <html data-theme> so there is no wrong-theme flash; the dark palette lives in one :root[data-theme='dark'] block. - vue.css re-values the --leji-* tokens for dark and overrides the stock theme's Prism tokens, tables, tip box, search plugin borders and the zoom overlay; the layer's own accent is left as authored in both modes. - viewer-boot.js resolves system|light|dark (in-memory when localStorage is blocked), re-themes mermaid on toggle, and falls back to matchMedia.addListener for older engines. - viewer-contrast.test.ts gains an arithmetic guard for the dark palette. All three SDKs ship byte-identical copies (npm run assets) and the golden export manifests were regenerated. Signed-off-by: Daniel Montilla <daniel@montilla.dev>
Signed-off-by: Daniel Montilla <daniel@montilla.dev>
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.
Summary
Adds dark mode to the generated Docsify viewer (
leji view/leji viewer build), with a theme toggle that defaults to the OS scheme and persists the reader's choice.<html data-theme>before first paint by a new vendoredtheme-init.js(head script, CSP-safe), so there's no wrong-theme flash; the dark palette lives in a single:root[data-theme='dark']block.vue.cssre-values the--leji-*tokens for dark and overrides the stock theme's Prism tokens, tables, tip box, search-plugin borders, and the zoom overlay. The layer's own accent (viewer.theme.primary) is left as authored in both modes.viewer-boot.jsresolvessystem → light → dark(in-memory whenlocalStorageis blocked), re-themes mermaid on toggle, and falls back tomatchMedia.addListenerfor older engines.viewer-contrast.test.tsgains an arithmetic guard for the dark palette. All three SDKs ship byte-identical copies (npm run assets); golden export manifests regenerated.Screenshots
Light (system):
Dark (system):
Dark — code + blockquote:
Dark — table:
Manual toggle → dark (pill shows
🌙 Dark):Verification
preflight.test.ts, fails without these changes too)conformancetest+commands/export: passtest_units+test_export: 97 passviewer-tones/viewer-contrast(now incl. dark palette): passnpm run assets:check: in sync