feat(site-builder): token module, canvas token variables, palette swatch row

Make var(--wsb-*) a first-class style value in the editor:

- utils/tokens.ts: TokenKey, TOKEN_VARS (moved from html-export.ts, same
  order/content as the backend), COLOR_TOKENS palette order, tokenRef,
  isTokenRef, tokenKeyOf, resolveTokenValue and buildCanvasTokenCss, which
  defines the 16 vars + token base CSS scoped to .canvas-device-frame
  (never :root) with every value through cssValue().
- editor/CanvasTokenStyle.tsx: <style data-wsb-canvas-tokens> driven by
  useSiteDesign(), mounted in App inside SiteDesignProvider, so design
  edits recolour token-backed values on the canvas instantly.
- panels/right/styles/TokenSwatchRow.tsx: palette-first swatch row that
  emits token references; .token-swatch styles appended to editor.css.
- html-export.ts imports TOKEN_VARS; export output pinned byte-identical
  to the pre-move baseline by hash in html-export.test.ts.

Refs #44

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Opus 5.5 committed 2026-10-07 11:16:29 -07:00
1 parent 97ccbee461
commit f8ac1fbe42
10 files changed
+602 -22

No files matched your search

+46
View File
@@ -2054,3 +2054,49 @@ body {
padding: 4px 12px;
}
.conflict-modal-actions button:disabled { opacity: 0.5; cursor: default; }
/* W0-tokens: token swatches */
.token-swatch-row {
margin-bottom: 8px;
}
.token-swatch-label {
font-size: 10px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.04em;
color: var(--color-text-muted);
margin-bottom: 4px;
}
.token-swatches {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.token-swatch {
width: 22px;
height: 22px;
padding: 0;
border-radius: 50%;
border: 2px solid var(--color-border);
cursor: pointer;
transition: border-color var(--transition-fast), transform var(--transition-fast),
box-shadow var(--transition-fast);
}
.token-swatch:hover {
border-color: var(--color-text-muted);
transform: scale(1.1);
}
.token-swatch.active {
border-color: var(--color-accent);
box-shadow: 0 0 0 2px var(--color-accent-subtle);
}
.token-swatch:focus-visible {
outline: 2px solid var(--color-accent);
outline-offset: 2px;
}