fix(skills): lint catches hardcoded SVG fill/stroke and inline colors

- New lint rules: svg-hardcoded-fill and svg-hardcoded-stroke catch
  fill="#hex" and stroke="#hex" in inline SVGs
- Updated hard-gate to explicitly cover SVG attributes
- Lint must run on both design.html AND summary.html
- SVG color tokenization guide in figma-to-design-html.md

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vance Ingalls
2026-05-18 17:56:15 -07:00
co-authored by Claude Opus 4.6
parent 5650d47a8a
commit d922d53f72
3 changed files with 51 additions and 4 deletions
@@ -278,7 +278,9 @@ These slides are VIDEO FRAMES, not website components. Each renders at 1920×108
The picker sidebar has 6 config controls: palette, typography, corners, density, depth, and shader background. ALL of them must visually affect BOTH the design.html page AND the slide thumbnails. This only works if every CSS value that should respond to config uses `var()` refs instead of hardcoded values.
**The rule:** NEVER write a hardcoded `border-radius`, `padding`, `gap`, `box-shadow`, or color hex in any design template CSS. Use the token vars.
**The rule:** NEVER write a hardcoded `border-radius`, `padding`, `gap`, `box-shadow`, or color hex in any design template CSS, inline styles, OR SVG attributes. Use the token vars.
**This includes inline SVGs.** SVG `fill` and `stroke` attributes with hardcoded hex break palette switching. Use `currentColor` on SVG elements and set `color` via CSS vars on the parent, or use `fill="var(--tp-accent)"` directly (works in inline SVGs, not in `<img>` src).
**Files this applies to:**
@@ -361,13 +363,14 @@ In **template.html** CSS (generated by build script):
- `summary.html` slides inside design.html: scoped under `.ds-slide-frame` with `--cr`/`--pad`/`--gap`/`--shadow` set on the scope. CSS vars cascade into the slides.
- `template.html` slides (Phase 1 cards + Phase 2 specimen): `updateSlideIframes()` rewrites the `:root` block inside the iframe's `<style>` tag via `contentDocument`.
**After generating or editing any design template file, run the lint:**
**After generating or editing any design template file, run the lint on ALL template files:**
```bash
python3 skills/hyperframes/scripts/lint-design-html.py presentations/<slug>/design.html
python3 skills/hyperframes/scripts/lint-design-html.py presentations/<slug>/summary.html
```
This catches: hardcoded `border-radius` (use `var(--cr)`), hardcoded colors in CSS (use `var()`), missing `var(--shadow)` on containers, missing `var(--gap)` on grids, missing token sentinels. Fix every warning before serving.
This catches: hardcoded `border-radius` (use `var(--cr)`), hardcoded colors in CSS (use `var()`), hardcoded SVG `fill`/`stroke` attributes (use `currentColor` or `var()`), missing `var(--shadow)` on containers, missing `var(--gap)` on grids, missing token sentinels. Fix every warning before serving.
</HARD-GATE>
@@ -150,6 +150,38 @@ Returns `{ "images": { "node:id": "https://...s3.amazonaws.com/..." } }`. Downlo
- Color-modified via CSS (fill, stroke attributes)
- Animated via GSAP (path morphing, drawing, transforms)
**SVG color tokenization:** Figma exports SVGs with hardcoded hex fills (`fill="#88E655"`). For the picker's palette controls to affect SVGs in slides, replace hardcoded colors with `currentColor` and set the color via CSS vars on the parent container:
```html
<!-- WRONG — picker can't change this -->
<svg>
<rect fill="#88E655" />
<text fill="#0A0A0A">Label</text>
</svg>
<!-- RIGHT — responds to palette changes -->
<div style="color:var(--tp-accent)">
<svg>
<rect fill="currentColor" />
<text fill="var(--tp-primary)">Label</text>
</svg>
</div>
```
For multi-color SVGs, use CSS class selectors on SVG elements:
```css
.brand-fill {
fill: var(--tp-accent);
}
.ink-fill {
fill: var(--tp-primary);
}
.ink-stroke {
stroke: var(--tp-primary);
}
```
For raster-only assets (photographs, complex textures), export as PNG at 2x and note in the DESIGN.html that the asset requires a file reference rather than inline SVG.
### Step 7: Build slides as component references
+13 -1
View File
@@ -55,9 +55,21 @@ RULES = [
{
'name': 'inline-hardcoded-hex',
'pattern': r'style="[^"]*(?:background|color|border):[^"]*#[0-9a-fA-F]{3,8}',
'message': 'Inline style with hardcoded hex color — use var(--bg/--fg/--ac/--mt) instead',
'message': 'Inline style with hardcoded hex color — use var(--tp-primary/--tp-secondary/--tp-accent/--tp-tertiary)',
'exclude': r'var\(--|color-mix\(',
},
{
'name': 'svg-hardcoded-fill',
'pattern': r'\bfill="(#[0-9a-fA-F]{3,8})"',
'message': 'SVG fill="{match}" hardcoded — use fill="currentColor" or fill="var(--tp-accent)" so palette switching works',
'exclude': r'fill="none"|fill="currentColor"|fill="var\(',
},
{
'name': 'svg-hardcoded-stroke',
'pattern': r'\bstroke="(#[0-9a-fA-F]{3,8})"',
'message': 'SVG stroke="{match}" hardcoded — use stroke="currentColor" or stroke="var(--tp-primary)"',
'exclude': r'stroke="none"|stroke="currentColor"|stroke="var\(',
},
{
'name': 'missing-token-sentinels',
'check_sentinels': ['__PRIMARY__', '__SECONDARY__', '__TERTIARY__', '__ACCENT__',