Replace inline styles with token-driven CSS classes in preview templates - #458
Conversation
…rop inline styles The preview templates hand-faked their styling with inline style="…" attributes — hardcoded literals (line-height:1.1, font-weight:800, color:#fff) and the wrong tokens (--sf-text-display-l instead of the semantic --sf-h1-*). Because inline styles outrank @layer rules, those attributes shadowed the framework's own element/token styling, so adjusting many panel knobs (h1 size, heading weights, line-heights, etc.) had no visible effect in the preview. Rebuild all five template bodies (marketing, docs, dashboard, components, stylescape) as semantic HTML driven entirely by SLASHED: - Real core primitives that ship live in the bundle: .sf-container, .sf-section, .sf-stack, .sf-cluster, .sf-grid/.sf-grid-cols-*, .sf-sidebar, .sf-divider, .sf-icon, .sf-surface, .sf-text-gradient, .sf-prose, plus classless form and heading styling. - Custom BEM components (.pv-btn/.pv-card/.pv-tag/.pv-field) for the pieces the framework stages off until v0.8 (.sf-btn/.sf-card/.sf-tag/.sf-field are commented out in every bundle), mirroring their reserved definitions. - A token-driven preview skin (previewSkinCSS) for the bits that have no framework class — colour ramps, type-scale ramp, radius/shadow/spacing demos, demo chrome. Every declaration references a live --sf-* token. Net result: zero inline styles in the templates, and every panel control that maps to a token now actually moves the preview. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Dr6QRJAoEupbzM4XM1KFB
|
Warning Review limit reached
Next review available in: 20 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
PR Summary by QodoReplace inline styles with token-driven CSS classes in preview templates
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
6 rules 1.
|
…w skin SPACES includes "3xs" but core/tokens.css defines spacing only from --sf-space-2xs up, so .pv-space--3xs referenced an undefined token with no fallback and the 3xs spacing bar collapsed to its min size instead of showing the real step. Special-case 3xs with var(--sf-space-3xs, 0.125rem), matching the fallback the framework already uses for this token elsewhere. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Dr6QRJAoEupbzM4XM1KFB
Summary
Refactored all preview template markup in
PreviewPanel.svelteto eliminate inline styles and replace them with a comprehensive set of token-driven CSS utility classes. This aligns the preview demos with the framework's design-token philosophy and ensures the configurator UI itself demonstrates best practices.Key Changes
Added
previewSkinCSS()function: Generates ~150 lines of minified CSS that provides:.pv-eyebrow,.pv-lead,.pv-muted,.pv-secondary, etc.).pv-btn,.pv-card,.pv-tag,.pv-field) that mirror framework reserved definitions.pv-header,.pv-panel,.pv-cta,.pv-code-block)Refactored all template bodies:
MARKETING_BODY: Replaced ~40 inline styles with semantic classes (.pv-header,.pv-brand,.pv-tag,.pv-type--*,.pv-btn--*,.pv-cta)DOCS_BODY: Replaced sidebar/main layout inline styles with.pv-panel,.pv-nav,.pv-eyebrow,.pv-code-blockDASHBOARD_BODY: Replaced stat card styles with.pv-card,.pv-stat,.pv-stat-label,.pv-delta--*classesCOMPONENTS_BODY: Replaced component showcase styles with.pv-btn--*,.pv-field,.pv-type--*classesSTYLESCAPE_BODY: Replaced entire stylescape demo with generated swatch rows and grid layouts using.pv-ramp,.pv-chip--*,.pv-grad--*,.pv-radius--*,.pv-shadow--*classesLeveraged framework layout primitives: Templates now use
.sf-container,.sf-cluster,.sf-stack,.sf-grid,.sf-sidebar,.sf-section,.sf-proseand other framework classes alongside the new preview skinImplementation Details
previewSkinCSS()references live--sf-*tokens (no hardcoded colors or values)ramp(),swatchRow()) to generate repetitive class definitions from token step arraysTesting
The refactored templates should render identically to the original versions, but now:
https://claude.ai/code/session_015Dr6QRJAoEupbzM4XM1KFB