name: theme-compliance
description: Audit and fix theme compliance issues in HTML and JS files — raw Tailwind color utilities, hardcoded hex/RGB values, inline styles, and incorrect getCssVar usage. Use this when asked to "audit colors", "check theme compliance", "fix raw Tailwind", "fix hardcoded colors", or when lint:js-colors reports violations.
Theme Compliance Audit & Fix
Goal
Ensure all papers, questions, and site-wide HTML/JS files use the semantic design system tokens (CSS custom properties, panel/chip/toggle classes) instead of raw Tailwind color utilities or hardcoded hex/RGB/HSL values. This enables consistent dark-mode support and theme switching.
When to use
- After creating or editing a paper/question with colored UI (bars, charts, badges, conditional styling)
- When
npm run lint:js-colors reports violations
- When performing a bulk housekeeping pass
- When a visual regression appears in dark mode
Quick check
# Run the JS color linter to find violations
npm run lint:js-colors
# Run full lint (includes HTML, CSS, JS colors, and repo validation)
npm run lint
The two violation categories
1. HTML: Raw Tailwind color utilities and hardcoded colors
Problem: Classes like bg-indigo-50, border-blue-200, text-red-600 or inline style="color: #ef4444" break theme switching.
Solution: Replace with semantic theme classes:
| Instead of |
Use |
bg-indigo-50, bg-blue-50 |
panel panel-info or bg-surface-* tokens |
bg-green-50, bg-emerald-50 |
panel panel-success or bg-success-* tokens |
bg-yellow-50, bg-amber-50 |
panel panel-warning or bg-warning-* tokens |
bg-red-50, bg-rose-50 |
panel panel-danger or use --tone-rose-* |
border-blue-200 |
border-info or border-accent |
text-indigo-700 |
text-accent-strong |
text-emerald-600 |
text-success |
Inline style="color: #xxx" |
Semantic class or JS getCssVar() |
Audit command:
# The HTML linter catches <style> blocks and inline styles in fragments
npm run lint:html
2. JS: Hardcoded hex colors in interactive scripts
Problem: Lines like element.style.backgroundColor = '#10b981' or fill: '#6366f1' ignore the active theme.
Solution: Use the getCssVar helper with a hardcoded fallback:
const getCssVar = (name, fallback) => {
const v = getComputedStyle(document.documentElement).getPropertyValue(name).trim();
return v || fallback;
};
// Usage
element.style.backgroundColor = getCssVar('--tone-emerald-strong', '#10b981');
Audit command:
npm run lint:js-colors
Auto-fix command (use with care):
node scripts/fix-js-colors.js # Apply fixes
node scripts/fix-js-colors.js --dry-run # Preview only
Common token mappings
| Hex value |
CSS token |
Semantic meaning |
#10b981, #22c55e, #059669 |
--tone-emerald-strong |
Success/positive |
#34d399 |
--tone-emerald-border |
Success border |
#ecfdf5, #d1fae5 |
--tone-emerald-bg |
Success background |
#6366f1, #4f46e5 |
--color-accent-strong |
Primary accent |
#eef2ff, #e0e7ff |
--color-accent-bg |
Accent background |
#ef4444, #dc2626 |
--tone-rose-strong |
Danger/negative |
#fef2f2, #fee2e2 |
--tone-rose-bg |
Danger background |
#f59e0b, #d97706 |
--tone-amber-strong |
Warning |
#fffbeb, #fef3c7 |
--tone-amber-bg |
Warning background |
#e5e7eb, #d1d5db |
--color-border |
Neutral border |
#f3f4f6, #f9fafb |
--color-surface-alt |
Neutral surface |
#1f2937, #111827 |
--color-text-primary |
Primary text |
#6b7280, #9ca3af |
--color-text-secondary |
Secondary text |
To discover more tokens, inspect css/theme.css for --tone-*, --color-* custom property definitions.
getCssVar critical rules
Define at IIFE top scope, after 'use strict', never inside init(). Sibling functions like updateUI(), renderChart() need access. Defining inside init() causes ReferenceError.
Always provide a fallback — the second argument is a literal color value that works if the CSS variable is missing:
getCssVar('--tone-emerald-strong', '#10b981') // ✅
getCssVar('--tone-emerald-strong') // ❌ no fallback
SVG template literals — wrap in ${} interpolation AND quote the attribute:
// ✅ Correct
`stroke="${getCssVar('--color-border', '#e5e7eb')}"`
// ❌ Wrong — raw function call, no interpolation
`stroke=getCssVar('--color-border', '#e5e7eb')`
Never use raw var() in JS-generated inline styles:
// ❌ Unreliable cross-browser
element.style.color = 'var(--tone-emerald-strong)';
// ✅ Resolves the value first
element.style.color = getCssVar('--tone-emerald-strong', '#10b981');
Full audit workflow
Run linters:
npm run lint:js-colors # JS violations
npm run lint:html # HTML violations
Review violations — the JS linter outputs file paths and line numbers.
Apply fixes:
- For JS: use
node scripts/fix-js-colors.js for bulk fixes, or manual edits for complex cases.
- For HTML: manually replace Tailwind classes with semantic tokens (no auto-fixer).
Verify:
npm test # Full lint + E2E
Visual smoke test — check both light and dark mode in the browser, especially charts, bars, and conditional coloring.
Checklist items (from PAPER_CHECKLIST.md / QUESTION_CHECKLIST.md)
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: pondevelopment-llm-training-theme-compliance3description: ---4---5---6name: theme-compliance7description: Audit and fix theme compliance issues in HTML and JS files — raw Tailwind color utilities, hardcoded hex/RGB values, inline styles, and incorrect getCssVar usage. Use this when asked to "audit colors", "check theme compliance", "fix raw Tailwind", "fix hardcoded colors", or when lint:js-colors reports violations.8---910# Theme Compliance Audit & Fix1112## Goal1314Ensure all papers, questions, and site-wide HTML/JS files use the semantic design system tokens (CSS custom properties, panel/chip/toggle classes) instead of raw Tailwind color utilities or hardcoded hex/RGB/HSL values. This enables consistent dark-mode support and theme switching.1516## When to use1718- After creating or editing a paper/question with colored UI (bars, charts, badges, conditional styling)19- When `npm run lint:js-colors` reports violations20- When performing a bulk housekeeping pass21- When a visual regression appears in dark mode2223## Quick check2425```bash26# Run the JS color linter to find violations27npm run lint:js-colors2829# Run full lint (includes HTML, CSS, JS colors, and repo validation)30npm run lint31```3233## The two violation categories3435### 1. HTML: Raw Tailwind color utilities and hardcoded colors3637**Problem:** Classes like `bg-indigo-50`, `border-blue-200`, `text-red-600` or inline `style="color: #ef4444"` break theme switching.3839**Solution:** Replace with semantic theme classes:4041| Instead of | Use |42|-----------|-----|43| `bg-indigo-50`, `bg-blue-50` | `panel panel-info` or `bg-surface-*` tokens |44| `bg-green-50`, `bg-emerald-50` | `panel panel-success` or `bg-success-*` tokens |45| `bg-yellow-50`, `bg-amber-50` | `panel panel-warning` or `bg-warning-*` tokens |46| `bg-red-50`, `bg-rose-50` | `panel panel-danger` or use `--tone-rose-*` |47| `border-blue-200` | `border-info` or `border-accent` |48| `text-indigo-700` | `text-accent-strong` |49| `text-emerald-600` | `text-success` |50| Inline `style="color: #xxx"` | Semantic class or JS `getCssVar()` |5152**Audit command:**53```bash54# The HTML linter catches <style> blocks and inline styles in fragments55npm run lint:html56```5758### 2. JS: Hardcoded hex colors in interactive scripts5960**Problem:** Lines like `element.style.backgroundColor = '#10b981'` or `fill: '#6366f1'` ignore the active theme.6162**Solution:** Use the `getCssVar` helper with a hardcoded fallback:6364```javascript65const getCssVar = (name, fallback) => {66 const v = getComputedStyle(document.documentElement).getPropertyValue(name).trim();67 return v || fallback;68};6970// Usage71element.style.backgroundColor = getCssVar('--tone-emerald-strong', '#10b981');72```7374**Audit command:**75```bash76npm run lint:js-colors77```7879**Auto-fix command (use with care):**80```bash81node scripts/fix-js-colors.js # Apply fixes82node scripts/fix-js-colors.js --dry-run # Preview only83```8485## Common token mappings8687| Hex value | CSS token | Semantic meaning |88|-----------|-----------|-----------------|89| `#10b981`, `#22c55e`, `#059669` | `--tone-emerald-strong` | Success/positive |90| `#34d399` | `--tone-emerald-border` | Success border |91| `#ecfdf5`, `#d1fae5` | `--tone-emerald-bg` | Success background |92| `#6366f1`, `#4f46e5` | `--color-accent-strong` | Primary accent |93| `#eef2ff`, `#e0e7ff` | `--color-accent-bg` | Accent background |94| `#ef4444`, `#dc2626` | `--tone-rose-strong` | Danger/negative |95| `#fef2f2`, `#fee2e2` | `--tone-rose-bg` | Danger background |96| `#f59e0b`, `#d97706` | `--tone-amber-strong` | Warning |97| `#fffbeb`, `#fef3c7` | `--tone-amber-bg` | Warning background |98| `#e5e7eb`, `#d1d5db` | `--color-border` | Neutral border |99| `#f3f4f6`, `#f9fafb` | `--color-surface-alt` | Neutral surface |100| `#1f2937`, `#111827` | `--color-text-primary` | Primary text |101| `#6b7280`, `#9ca3af` | `--color-text-secondary` | Secondary text |102103To discover more tokens, inspect `css/theme.css` for `--tone-*`, `--color-*` custom property definitions.104105## getCssVar critical rules1061071. **Define at IIFE top scope**, after `'use strict'`, never inside `init()`. Sibling functions like `updateUI()`, `renderChart()` need access. Defining inside `init()` causes `ReferenceError`.1081092. **Always provide a fallback** — the second argument is a literal color value that works if the CSS variable is missing:110 ```javascript111 getCssVar('--tone-emerald-strong', '#10b981') // ✅112 getCssVar('--tone-emerald-strong') // ❌ no fallback113 ```1141153. **SVG template literals** — wrap in `${}` interpolation AND quote the attribute:116 ```javascript117 // ✅ Correct118 `stroke="${getCssVar('--color-border', '#e5e7eb')}"`119120 // ❌ Wrong — raw function call, no interpolation121 `stroke=getCssVar('--color-border', '#e5e7eb')`122 ```1231244. **Never use raw `var()` in JS-generated inline styles:**125 ```javascript126 // ❌ Unreliable cross-browser127 element.style.color = 'var(--tone-emerald-strong)';128129 // ✅ Resolves the value first130 element.style.color = getCssVar('--tone-emerald-strong', '#10b981');131 ```132133## Full audit workflow1341351. **Run linters:**136 ```bash137 npm run lint:js-colors # JS violations138 npm run lint:html # HTML violations139 ```1401412. **Review violations** — the JS linter outputs file paths and line numbers.1421433. **Apply fixes:**144 - For JS: use `node scripts/fix-js-colors.js` for bulk fixes, or manual edits for complex cases.145 - For HTML: manually replace Tailwind classes with semantic tokens (no auto-fixer).1461474. **Verify:**148 ```bash149 npm test # Full lint + E2E150 ```1511525. **Visual smoke test** — check both light and dark mode in the browser, especially charts, bars, and conditional coloring.153154## Checklist items (from PAPER_CHECKLIST.md / QUESTION_CHECKLIST.md)155156- [ ] `getCssVar` helper (if used) defined at **IIFE top scope**, not inside `init()`157- [ ] No raw Tailwind color utilities in HTML — use semantic theme classes158- [ ] No hardcoded colors in JS — use `getCssVar('--token', '#fallback')`159- [ ] No `<style>` blocks or inline `style=""` in HTML fragments160- [ ] Dark mode renders correctly (no invisible text, no clashing backgrounds)161162---163> Converted and distributed by [TomeVault](https://tomevault.io/claim/pondevelopment) — claim your Tome and manage your conversions.164<!-- tomevault:4.0:skill_md:2026-04-16 -->