Skip to content
SprecherEast
Issue 791

documentation: Knowledge note for the theme (src/platform/theme and src/themes)

Back to our plan
Done
documentationstylingtoolingpriority: medium

Type

documentation

Summary

Write the short note on how the site's look is themed: where each color and size token is named, where its value is set for light and dark, how a visitor's choice of light or dark is applied before the page paints, and how a theme adds decorations.

Problem

A token is named in one file, valued in another and mapped to Tailwind classes in a third, and tests tie them together. The design guideline's token table may no longer match the values (#279).

What the generated reference already shows, so the note doesn't repeat it: Nothing in the generated reference covers the theme: no content type, route or kit component. docs/guidelines/nextjs-tailwind.md states the rules; decisions 0006 and 0012 the reasons.

Proposed fix

Write src/platform/theme/README.md from the template. Owner's direction for every note (2026-11-06, Claude session, recorded on #712 and #719): a note explains the behavior and logic of its content types and code (what shows, where, when, who publishes or changes it, and the special rules), never a list of fields; and every link between fields is stated near the top, so no agent has to work it out from the code.

Links between fields the note states up front (each one checked in the code first):

  • Token names live in tokens.ts; their light and dark values in src/themes/<name>/theme.css; tailwind.css maps each to classes (--color-primary: var(--primary) gives bg-primary). themes.test.ts checks every theme sets every token, using themeFile.ts.
  • Each name in registry.ts has a folder in src/themes/; registry.test.ts checks the two lists match.
  • Theme options (what tokens can't express) have defaults in options.ts, so a theme that only changes colors needs nothing else (decision 0012).
  • Chart color pairs and their contrast are checked in themes.test.ts (CHART_PAIRS, #659).

Behaviors and rules the note must cover (each with the file or test named):

  • InitTheme sets data-theme on the page before first paint from the stored choice, or the system's preference (InitTheme.tsx, theme.ts).
  • ThemeProvider reads and stores the visitor's choice and sets it again where the script didn't run, such as a 404 (ThemeProvider.client.tsx).
  • The theme selector works but is not rendered anywhere yet (ThemeSelector.client.tsx, docs/ui/evidence.md).
  • Decorations: a theme's faint CSS-only layer; any movement stops within 5 seconds and doesn't start with reduced motion (ThemeDecoration.tsx, decorations.css, #409).
  • Chart reveal and print styles (chartReveal, chartPrint tests), and prose styles (prose.test.ts).

Tests to name under "Rules and the tests that protect them": themes.test.ts, registry.test.ts, options.test.ts, ThemeProvider.client.test.tsx, ThemeDecoration.test.tsx, chartReveal.test.ts, chartPrint.test.ts, prose.test.ts, and the theme lint (eslint.theme.config.mjs).

Map entry: { "note": "src/platform/theme/README.md", "paths": ["src/platform/theme/**", "src/themes/**"] }

Acceptance criteria

  • Not done: src/platform/theme/README.md follows docs/knowledge/note-template.md and is at most 80 lines.
  • Not done: It explains behavior and logic, not fields: no field lists, props tables or route lists. It links the generated pages named above for those.
  • Not done: Right after its opening sentences, a short list states every link between fields named above (relationships, values copied or derived, mapper inputs and the props they become, hooks that copy a value), each with its file.
  • Not done: Every behavior listed above is covered or, if the code turns out different, the note says what the code does and this issue gets a comment saying what changed.
  • Not done: Every statement names the file or test it comes from, checked against the code at the branch's base.
  • Not done: docs/knowledge/index.md gets one short line for the note (a few words after the link). It stays within the budget check.
  • Not done: docs/knowledge/map.json gets the entry above.
  • Not done: npm run agent-context -- --write has been run and its generated rule committed, and npm run agent-context passes. If the budget check fails, this issue is not done; trimming other always-loaded files is not part of this issue.
  • Not done: Known contradictions: #279 applies: check the "Design Tokens" table in docs/guidelines/nextjs-tailwind.md against src/themes/default/theme.css. Prefer replacing the copied values with a link to tokens.ts and theme.css (one definition, guard rail 1); if that would change a rule, fix the values instead and ask on #279. Regenerate the guideline's copy with npm run agent-context -- --write, and comment on #279 which item this closes. For #158, check docs/roles/ui-designer.md and fix only statements of fact the code contradicts. #366 and #531 don't apply; leave the lines #531 names in the same guideline untouched.
  • Not done: No code changes. A bug or gap found in the code goes under the note's "Known gaps" and is filed as its own issue (labeled scope-creep, linked here).
  • Not done: Prettier, Knowledge sync, PR Policy and Agent context pass.

Files likely touched

  • src/platform/theme/README.md
  • docs/knowledge/index.md (one line)
  • docs/knowledge/map.json (one entry)
  • .claude/rules/generated/src--platform--theme--README.md
  • docs/guidelines/nextjs-tailwind.md (the Design Tokens table only)
  • .claude/rules/generated/docs--guidelines--nextjs-tailwind.md (regenerated)
  • docs/roles/ui-designer.md (only if a fact is wrong)

Must not touch

  • Code under src/ (the note itself excepted): this issue documents behavior and changes none.
  • Other notes, their generated rules, and the files the other note issues under #712 list.
  • docs/knowledge/note-template.md and the session-start set (CLAUDE.md, AGENTS.md, docs/guidelines/guard-rails.md).
  • docs/architecture/data-model.md, docs/ui/data-types.md, docs/ui/component-set-modules.md: read them and fold this area's facts into the note (decision 0019, section 7); report any drift in them in a comment on #712 instead of editing them, since every note issue reads them.
  • src/modules/README.md, src/platform/README.md, docs/project.md (#725 owns them).

Open questions

  • Session-start room. The index line needs room at session start, which #799 makes. This issue is blocked by #799 and is not Ready until it lands; the line then stays within the budget check.
  • Dead code first. #728 (the audit, waiting for the owner's keep-or-drop marks) removes unused or unwanted code before a note describes it. This issue is marked blocked by #728; it can start once #728 has settled this area, even if other areas are still open there.
  • Size: not set; a cloud session can't read the board. Suggested: M.

Area

tooling, styling

Priority

medium


Generated by Claude Code, opens in a new tab

See it on GitHub, opens in a new tab