feat(playground): soften dark views and set the editor on the code background #330

Merged
abiwab merged 2 commits from feat/playground-dark-polish into dev/1.6 2026-11-30 18:35:35 +01:00
Owner

Follow-up to #328: the playground still showed glaring pure white in the dark recipe and run sheet views, and its editor sat on the page background.

Renderer: an opt-in hook, no default change

  • --color-text-strong (headings, quantities) in dark mode now reads var(--vp-c-text-1, oklch(100% 0 0)), the same pattern as the existing --vp-c-bg background hook.
  • Hosts that set neither variable keep their exact look: gram view --serve stays pure white, and the VS Code preview already overrides --color-text-strong in its own view.css.
  • tests/dark-host-hooks.test.ts locks both fallbacks (#1a1a1a, pure white) so a change to the default rendering cannot slip in.

Docs / playground

  • global.css feeds --vp-c-text-1: var(--sl-color-white) next to --vp-c-bg: the views take the site's chalk white (#f2efe8, 14.9:1 instead of ~17:1) wherever the docs show them.
  • The CodeMirror editor uses --gram-code-bg (the darker ground of the docs' code blocks) and its gutter --gram-code-chrome. No change in the light theme, where --gram-code-bg is the page background.
  • contrast.test.ts now covers the renderer's strong text (AA, under 15:1) and the editor's line numbers on the gutter.

Checks

  • bun test: renderer 730 pass, docs 160 pass. Renderer rebuilt, dist/gram.css carries the hook.
  • Not visually checked in a browser yet.
Follow-up to #328: the playground still showed glaring pure white in the dark recipe and run sheet views, and its editor sat on the page background. ## Renderer: an opt-in hook, no default change - `--color-text-strong` (headings, quantities) in dark mode now reads `var(--vp-c-text-1, oklch(100% 0 0))`, the same pattern as the existing `--vp-c-bg` background hook. - Hosts that set neither variable keep their exact look: `gram view --serve` stays pure white, and the VS Code preview already overrides `--color-text-strong` in its own `view.css`. - `tests/dark-host-hooks.test.ts` locks both fallbacks (`#1a1a1a`, pure white) so a change to the default rendering cannot slip in. ## Docs / playground - `global.css` feeds `--vp-c-text-1: var(--sl-color-white)` next to `--vp-c-bg`: the views take the site's chalk white (#f2efe8, 14.9:1 instead of ~17:1) wherever the docs show them. - The CodeMirror editor uses `--gram-code-bg` (the darker ground of the docs' code blocks) and its gutter `--gram-code-chrome`. No change in the light theme, where `--gram-code-bg` is the page background. - `contrast.test.ts` now covers the renderer's strong text (AA, under 15:1) and the editor's line numbers on the gutter. ## Checks - `bun test`: renderer 730 pass, docs 160 pass. Renderer rebuilt, `dist/gram.css` carries the hook. - Not visually checked in a browser yet.
abiwab merged commit 0f7d4e0901 into dev/1.6 2026-11-30 18:35:35 +01:00
abiwab deleted branch feat/playground-dark-polish 2026-11-30 18:35:36 +01:00
Sign in to join this conversation.
No description provided.