feat(docs): slate dark theme and contrast fixes #328

Merged
abiwab merged 2 commits from feat/docs-slate-dark-theme into dev/1.6 2026-11-30 15:23:37 +01:00
Owner

Reworks the docs site's dark theme and fixes the contrast issues found along the way.

Dark theme: bistro slate

  • Replaces the saturated brown with a near-neutral charcoal (#1c1c1b), chalk-colored text and the Gram orange kept for accents.
  • Headings use #f2efe8 instead of pure white: 14.9:1 instead of 17.3:1, no more halation on the dark ground.
  • Code blocks sit one step below the page (--gram-code-bg), their title bars and tabs one step above (--gram-code-chrome).
  • The footer and the generated OG images follow the same palette (OG titles no longer pure white).

Theme logic in one place

  • New src/lib/theme.ts: storage key, parsing, resolution and the inline anti-flash script, shared by Layout.astro and ThemeSelect.astro instead of three copies. Default stays auto; Starlight's storage contract is unchanged, so existing choices carry over.

Contrast fixes

  • Inline code (dark): the chip went from a bright #3a3836 patch (8.2:1, 68% of the body text contrast) to an outlined #2a2927 chip (10.2:1).
  • Orange buttons (docs home, 404): dark text via a new --gram-on-accent token, 8.1:1 instead of light text at 2.1:1.
  • Light theme: orange text and the current sidebar entry use #ad5600 (5.1:1 on white, was 2.3:1); link hover follows.
  • Comments in Markdown code blocks (dark): the playground's readable-comment patch is now shared (src/lib/shiki-themes.ts) and applied through astro.config.mjs (~10:1, was ~3.8:1). The playground still loads its theme lazily.

Tests

  • src/styles/contrast.test.ts reads global.css and checks every text pair a reader meets, in both themes: WCAG AA (4.5:1) everywhere, dark text under 15:1, inline code keeping at least 80% of the body text contrast, primary button text at rest and on hover.
  • src/lib/theme.test.ts checks the inline script and the theme helpers agree across 12 stored/OS combinations.

Checks

  • bun test in packages/docs: 155 pass. bun run typecheck: 0 errors.
  • Full astro build checked: comment color and inline code token present in the output.
  • Not visually checked in a browser yet.
Reworks the docs site's dark theme and fixes the contrast issues found along the way. ## Dark theme: bistro slate - Replaces the saturated brown with a near-neutral charcoal (`#1c1c1b`), chalk-colored text and the Gram orange kept for accents. - Headings use `#f2efe8` instead of pure white: 14.9:1 instead of 17.3:1, no more halation on the dark ground. - Code blocks sit one step below the page (`--gram-code-bg`), their title bars and tabs one step above (`--gram-code-chrome`). - The footer and the generated OG images follow the same palette (OG titles no longer pure white). ## Theme logic in one place - New `src/lib/theme.ts`: storage key, parsing, resolution and the inline anti-flash script, shared by `Layout.astro` and `ThemeSelect.astro` instead of three copies. Default stays `auto`; Starlight's storage contract is unchanged, so existing choices carry over. ## Contrast fixes - Inline code (dark): the chip went from a bright `#3a3836` patch (8.2:1, 68% of the body text contrast) to an outlined `#2a2927` chip (10.2:1). - Orange buttons (docs home, 404): dark text via a new `--gram-on-accent` token, 8.1:1 instead of light text at 2.1:1. - Light theme: orange text and the current sidebar entry use `#ad5600` (5.1:1 on white, was 2.3:1); link hover follows. - Comments in Markdown code blocks (dark): the playground's readable-comment patch is now shared (`src/lib/shiki-themes.ts`) and applied through `astro.config.mjs` (~10:1, was ~3.8:1). The playground still loads its theme lazily. ## Tests - `src/styles/contrast.test.ts` reads `global.css` and checks every text pair a reader meets, in both themes: WCAG AA (4.5:1) everywhere, dark text under 15:1, inline code keeping at least 80% of the body text contrast, primary button text at rest and on hover. - `src/lib/theme.test.ts` checks the inline script and the theme helpers agree across 12 stored/OS combinations. ## Checks - `bun test` in `packages/docs`: 155 pass. `bun run typecheck`: 0 errors. - Full `astro build` checked: comment color and inline code token present in the output. - Not visually checked in a browser yet.
abiwab merged commit 5123a58543 into dev/1.6 2026-11-30 15:23:37 +01:00
abiwab deleted branch feat/docs-slate-dark-theme 2026-11-30 15:23:38 +01:00
Sign in to join this conversation.
No description provided.