Skip to content

feat(cli): add dark/light theme toggle to local preview - #92

Merged
scott merged 2 commits into
mainfrom
feat/91-preview-theme-toggle
Sep 1, 2026
Merged

feat(cli): add dark/light theme toggle to local preview#92
scott merged 2 commits into
mainfrom
feat/91-preview-theme-toggle

Conversation

@scott

@scott scott commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add dark and light themes to the local markdown preview (file:// one-shot and --watch / runner on 127.0.0.1:7821) so it stays visually in lockstep with the hosted viewer.
  • Theme is applied by a blocking boot script in <head> (html[data-theme]) before first paint. Preference lives in localStorage['gander-theme'] ("light" | "dark"); absence follows the OS. try/catch around localStorage covers Safari file:// SecurityError.
  • Dark mode toggle uses a stable name + aria-pressed. Desktop-with-TOC: under the logo. No-TOC / mobile: left-aligned .gander-md-toolbar. Both sit outside #content-body so watch reloads do not eat them.
  • Mermaid @10 now initializes with dark / default, stashes source on data-gander-mermaid, and serializes overlapping run() on an in-flight Promise. Logo SVG uses fill="currentColor". Light palette is unchanged (body uses --gander-bg).

Related Issue

Closes #91

Paired with the hosted viewer (visual contract, not API): gandermd/gandermd#55.

Testing

  • go test ./...
  • go vet ./...
  • go build ./...
  • CGO_ENABLED=0 go build -o gander .
  • Inspected generated HTML for boot-before-style, TOC/toolbar toggle placement, and mermaid/toggle script order.

Notes

Token table, boot, and toggle scripts are a copy of gandermd internal/render/theme.go (no shared Go module). Persistence does not cross file://, 127.0.0.1:7821, and https://gander.md — acceptable per the design. A slipped CLI release does not block server deploy.

scott added 2 commits August 31, 2026 21:20
Match the hosted viewer: pill switch in a top-right chrome cluster instead of a labeled button under the TOC.
@scott
scott merged commit cc4c0f6 into main Sep 1, 2026
1 check passed
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.

feat: dark/light theme + toggle on local markdown preview

1 participant