Skip to content

feat(canvas): independent background selection + custom color#17

Merged
dani-polani merged 1 commit into
mainfrom
feat/independent-background-selection
Jul 11, 2026
Merged

feat(canvas): independent background selection + custom color#17
dani-polani merged 1 commit into
mainfrom
feat/independent-background-selection

Conversation

@dani-polani

Copy link
Copy Markdown
Member

What

Decouple the canvas from the visual style so any style can render on any background. Answers the user request to use a style's word treatment (e.g. Bauhaus blocks) on a different canvas.

  • The Style panel's Canvas section is now a background grid available for every style (light, dark + the 12 style canvases), not only Classic.
  • New Custom tile paints the diagram on a solid user-chosen color via the native color picker; text color and light/dark chrome are derived from the color's luminance (no separate text control needed).
  • The main Style picker still selects the whole style; picking a style resets the background override to that style's default — the same pattern palette already uses.

How

  • styles.ts: BackgroundId axis + BACKGROUNDS catalog derived from the style canvases; resolveCanvas() (shared by all render/export sites), computeSolidCanvas() for custom, backgroundExport(id,…) (style wrapper kept for callers/tests).
  • schema.ts + compact-v4.ts: additive backgroundId / backgroundCustomColor, carried in the share link (bi, bc) only when set/active.
  • AlignmentPreview / TokenView / ExportMenu / svg.ts: render + export the resolved canvas; plain light/dark keep the preview-frame CSS path, custom is a caller-filled solid.
  • StylePanel.svelte: background grid + custom color-input tile (native swatch styled to match the sibling tiles).

Compatibility

Additive fields only — an old share link with no backgroundId renders exactly as before. Note: Classic dark chosen via the grid is now an override, so it resets on a style switch (consistent with the "don't pin tweaks" rule).

Verification

  • 163 unit tests pass (13 added: catalog/resolver, export override incl. Bauhaus-on-Aurora and custom solid fill, serialization round-trips). Typecheck / lint / build clean.
  • Driven live with Playwright: Bauhaus chips on the Aurora gradient; custom solid blue with auto-white text; a light-yellow custom flips auto-text to near-black; switching style resets the canvas.

🤖 Generated with Claude Code

Decouple the canvas from the visual style so any style can render on any
background. The Style panel's Canvas section is now a background grid for
every style (light, dark + the 12 style canvases), not just Classic, plus a
Custom tile painting a solid user-chosen color.

- Extract canvases into a background axis (BackgroundId, resolveCanvas); the
  style still sets a default and picking a style clears the override, the
  same way palette already works.
- custom canvas: native color picker, text color + light/dark chrome derived
  from luminance; the color is remembered and travels in the share link only
  while custom is active.
- Additive backgroundId / backgroundCustomColor settings — old share links
  render exactly as before.
- Export (PNG/SVG/PDF/HTML) mirrors the chosen background.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dani-polani dani-polani merged commit debb05c into main Jul 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant