From fc028fa8f032a0a182bd8a6012c6ea85e134e135 Mon Sep 17 00:00:00 2001 From: Till JS Date: Thu, 16 Apr 2026 00:58:13 +0200 Subject: [PATCH] chore(lint): audit:theme-tokens guard against bare --muted / --theme-* drift Three naming conventions had drifted through the monorepo (--muted, --theme-*, --color-*). Only the last is defined in the Mana theme; the others silently fell back to nothing and stopped tracking theme variants. Today's cleanup migrated ~100 files, but nothing stopped the drift from creeping back. - scripts/audit-theme-tokens.mjs scans ~3k source files and fails if any references a bare shadcn token or a --theme-* prefix, with an allowlist for known-literal module brand colors (news-research, agent templates) - wire into pnpm script and lint-staged (runs once per commit touching *.{svelte,css}, ignores per-file args) - design-ux.md guideline: fix stale --color-destructive entry (Mana uses --color-error), add explicit "never bare tokens" warning with examples Co-Authored-By: Claude Opus 4.6 (1M context) --- .claude/guidelines/design-ux.md | 26 +++- lint-staged.config.js | 5 + package.json | 1 + scripts/audit-theme-tokens.mjs | 216 ++++++++++++++++++++++++++++++++ 4 files changed, 246 insertions(+), 2 deletions(-) create mode 100644 scripts/audit-theme-tokens.mjs diff --git a/.claude/guidelines/design-ux.md b/.claude/guidelines/design-ux.md index 6aba53434..2e1af8377 100644 --- a/.claude/guidelines/design-ux.md +++ b/.claude/guidelines/design-ux.md @@ -114,10 +114,32 @@ background: white; | `--color-muted-foreground` | Sekundärtext, Platzhalter | | `--color-surface` | Hintergründe | | `--color-border` | Rahmen, Trennlinien | -| `--color-destructive` | Lösch-Aktionen, Fehler | +| `--color-error` | Lösch-Aktionen, Fehler | | `--color-success` | Erfolgsmeldungen | | `--color-warning` | Warnungen | +### ⚠️ Nie bare shadcn-Tokens + +Manche Komponenten aus shadcn- oder theme-Vorlagen sprechen bare Token-Namen +an (`--muted`, `--primary`, `--theme-muted`). **Diese existieren im Mana-Theme +nicht** und fallen stumm aus — das Theme-Wechseln wird nicht mehr mitgezogen. +Immer den `--color-*`-Präfix nutzen: + +```css +/* Falsch */ +background: hsl(var(--muted)); +color: var(--foreground, #111); +border: 1px solid var(--theme-border); + +/* Richtig */ +background: hsl(var(--color-muted)); +color: hsl(var(--color-foreground)); +border: 1px solid hsl(var(--color-border)); +``` + +Der Audit `pnpm audit:theme-tokens` (läuft auch in `lint-staged`) schlägt +jeden Drift an. + ### Dark Mode Immer beide Modi berücksichtigen: @@ -434,7 +456,7 @@ function handleKeydown(e: KeyboardEvent) { | Aspekt | Input-Toggle | contenteditable | | -------------------- | ------------------------------ | ---------------------------- | | Klicks zum Editieren | 2 (aktivieren + positionieren) | 1 (Cursor an Klick-Position) | -| DOM-Wechsel | `` ↔ `` | Keiner | +| DOM-Wechsel | `` ↔ `` | Keiner | | Mehrzeilig | Braucht `