Skip to content

feat(configurator): inline live preview for every token domain - #371

Merged
jackgranatowski merged 2 commits into
mainfrom
claude/configurator-v2-redesign-yk7qno
Jun 22, 2026
Merged

feat(configurator): inline live preview for every token domain#371
jackgranatowski merged 2 commits into
mainfrom
claude/configurator-v2-redesign-yk7qno

Conversation

@jackgranatowski

@jackgranatowski jackgranatowski commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Extends the Colors panel redesign to every other token domain. The Colors panel's headline new feature was the inline "Semantic roles" card — a live preview of your tokens right where you edit. This generalises that to all token domains so each panel shows focused, live feedback without leaving the editing surface.

Domain Inline preview
Typography Type-scale specimen + font-stack samples
Spacing Fluid spacing bars
Layout Container max-widths, drawn to relative scale
Gradients Brand/surface/fade gradient tiles
Borders Radius corners + stroke widths
Shadows Elevation cards (incl. glow)
Motion Animated duration + easing bars
Effects Blur + opacity samples

Each renders inside a scoped stage carrying the full framework cascade plus the user's overrides (buildPreviewDeclarations), so every var(--sf-*) resolves live and updates the instant a token changes. The stage honours the preview theme and the reduced-motion toggle.

Architecture (mirrors existing patterns)

  • lib/domainPreviews.js — curated per-domain preview specs; single source of truth, pinned to the baked catalogue by a tripwire test (same philosophy as colorRoles.js / basics.js).
  • components/DomainPreview.svelte — one component; layout switches on the spec kind (radius corners, elevation cards, gradient tiles, motion bars, type specimen, spacing/container bars, blur/opacity).
  • DomainPanel.svelte — collapsed "Preview" accordion for any domain with a spec. Colors keeps its bespoke ColorAssignments card (it is not in DOMAIN_PREVIEWS, so no generic Preview is added there).

Test plan

  • Unit suite green — new tests/domainPreviews.test.js tripwire pins every preview token to the catalogue (518 tests pass)
  • Component tests green — tests-components/domain-preview.test.js: every domain mounts and renders a sample per spec item; an override flows into the scoped stage
  • npm run build clean (0 errors), svelte-check 0 errors, check:curation + root check:version green
  • e2e spec added (tests-e2e/domain-preview.spec.js): accordion opens, stays collapsed by default, Colors keeps Semantic roles — validated in CI (local browsers are network-restricted here)

🤖 Generated with Claude Code

https://claude.ai/code/session_01Fg7U9rTiqBgbsPuz9kdWea


Generated by Claude Code


Summary by cubic

Adds inline live previews to every token domain (Typography, Spacing, Layout, Gradients, Borders, Shadows, Motion, Effects). Fixes motion easing bars to honor reduced-motion by scaling animation duration with --sf-motion-scale.

  • New Features

    • New DomainPreview.svelte renders curated per-domain previews from domainPreviews.js inside a scoped stage using buildPreviewDeclarations; honors theme and reduced-motion.
    • DomainPanel.svelte displays the Preview accordion when a spec exists; Colors keeps its bespoke ColorAssignments.
  • Tests

    • Tripwire unit tests pin all preview tokens to the baked catalogue; component test verifies rendering and live override flow.
    • E2E tests cover accordion behavior, confirm Colors does not show the generic Preview, and assert a --sf-radius-scale override flows into the stage’s inline styles.

Written for commit c1bdd5c. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Added inline "Preview" accordion cards to domain panels, displaying live visual previews of design tokens with type-specific layouts (typography, spacing, borders, gradients, motion, effects, and more).
  • Tests

    • Added comprehensive test coverage for preview functionality including unit, component, and end-to-end tests.

Generalises the Colors panel's "Semantic roles" card to every other token
domain. Each of Typography, Spacing, Layout, Gradients, Borders, Shadows,
Motion and Effects now carries a collapsed "Preview" accordion that renders a
compact, domain-shaped live preview of its tokens — type specimen, spacing
bars, container widths, gradient tiles, radius corners, elevation cards, motion
bars and blur/opacity samples — resolved against the user's current overrides.

- lib/domainPreviews.js: curated per-domain preview specs (single source of
  truth, pinned to the catalogue by a tripwire test like colorRoles.js).
- components/DomainPreview.svelte: renders the spec inside a scoped stage
  carrying the full framework cascade (buildPreviewDeclarations), switching
  layout on the spec kind. Honours the preview theme + reduced-motion toggle.
- DomainPanel.svelte: shows the Preview accordion for any domain with a spec
  (Colors keeps its bespoke ColorAssignments card).

Tests: tests/domainPreviews.test.js (curation tripwire), component test
(every domain mounts + override flows into the stage), e2e spec (accordion
opens, stays collapsed by default, Colors keeps Semantic roles).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fg7U9rTiqBgbsPuz9kdWea
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds inline domain preview cards to the configurator. A new domainPreviews.js catalog maps each token domain to a preview spec (kind, blurb, grouped --sf-* token items). A new DomainPreview.svelte component renders live token visualizations for each spec kind. DomainPanel.svelte conditionally shows a "Preview" accordion card using this component. Unit, component, and e2e tests cover data integrity, rendering, and live override reflection.

Changes

Inline Domain Preview

Layer / File(s) Summary
Preview data catalog
configurator/src/lib/domainPreviews.js
Defines DOMAIN_PREVIEWS as a domain-keyed catalog with kind, blurb, and groups of labeled --sf-* token items. Exports allPreviewTokens() to flatten all referenced token strings.
DomainPreview component and DomainPanel wiring
configurator/src/components/DomainPreview.svelte, configurator/src/components/DomainPanel.svelte
DomainPreview.svelte derives spec from DOMAIN_PREVIEWS, computes a scoped stageStyle cascade from overrides and preview theme, and renders per-kind token visualizations (type, spacing, layout, gradients, radius, elevation, motion, effects) with reduced-motion support. DomainPanel.svelte adds showPreview state, a derived previewSpec lookup, and a conditional "Preview" <details> accordion card in the SETTINGS section.
Unit, component, and e2e tests
configurator/tests/domainPreviews.test.js, configurator/tests-components/domain-preview.test.js, configurator/tests-e2e/domain-preview.spec.js
Node unit tests assert catalog structural integrity (domain keys, token format, no duplicates, all tokens present in api-index.generated.json). Component tests verify mount, label rendering, missing-spec guard, and override store propagation into inline styles. E2e tests check accordion expand/collapse, live --sf-radius-m override reflection in stage styles, and that the Colors panel omits the generic "Preview" card.

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant DomainPanel
  participant DomainPreview
  participant DOMAIN_PREVIEWS
  participant overrideStore

  User->>DomainPanel: select domain (e.g. Borders)
  DomainPanel->>DOMAIN_PREVIEWS: lookup previewSpec by domain.id
  DOMAIN_PREVIEWS-->>DomainPanel: spec { kind, blurb, groups }
  DomainPanel->>DomainPanel: set showPreview, render Preview <details>
  User->>DomainPanel: expand Preview accordion
  DomainPanel->>DomainPreview: render domain prop
  DomainPreview->>DOMAIN_PREVIEWS: derive spec from domain
  DomainPreview->>overrideStore: read current overrides + ui.previewTheme
  overrideStore-->>DomainPreview: CSS variable overrides
  DomainPreview->>DomainPreview: buildPreviewDeclarations() → stageStyle string
  DomainPreview-->>User: .dp__stage with live token-driven visuals
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • codeslash-dev/SLASHED#367: Refactors DomainPanel.svelte into the SETTINGS + disclosure layout that determines where the new "Preview" accordion card is inserted in this PR.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly summarizes the main change: introducing inline live preview functionality for all token domains in the configurator.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/configurator-v2-redesign-yk7qno

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@configurator/tests-e2e/domain-preview.spec.js`:
- Around line 35-46: The test `the preview reflects a live override` only
verifies that the baseline stage style contains `--sf-radius-m`, but does not
actually test that live overrides work by mutating a token and observing the
change. After capturing the `before` style attribute of the `stage` locator, add
steps to mutate a radius token (such as radius-m) through the UI in the
catalogue, then retrieve the updated style attribute and assert that it has
changed to reflect the new token value, proving that the override propagation is
working correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 27eaff14-4545-454c-9c0b-d01ce2f87661

📥 Commits

Reviewing files that changed from the base of the PR and between 7036cd0 and 676c100.

📒 Files selected for processing (6)
  • configurator/src/components/DomainPanel.svelte
  • configurator/src/components/DomainPreview.svelte
  • configurator/src/lib/domainPreviews.js
  • configurator/tests-components/domain-preview.test.js
  • configurator/tests-e2e/domain-preview.spec.js
  • configurator/tests/domainPreviews.test.js

Comment thread configurator/tests-e2e/domain-preview.spec.js

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 6 files

You’re at about 91% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread configurator/tests-e2e/domain-preview.spec.js Outdated
Comment thread configurator/src/components/DomainPreview.svelte Outdated
…e override in e2e

Two review findings on the inline domain previews:

- DomainPreview easing bars hardcoded animation-duration: 1.1s, bypassing the
  reduced-motion toggle (which sets --sf-motion-scale: 0 on the stage). Scale
  the easing duration by --sf-motion-scale so those bars freeze too, matching
  the duration bars (whose tokens are calc(... * --sf-motion-scale)).

- The "preview reflects a live override" e2e only asserted the baseline cascade
  contained a radius token (always true). radius-m is a read-only consumption
  token, so drive its upstream knob --sf-radius-scale via the Scaling panel and
  assert the new value flows live into the stage's inline custom properties.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fg7U9rTiqBgbsPuz9kdWea
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.

2 participants