Skip to content

fix: three bugs in configurator colors panel - #390

Merged
jackgranatowski merged 4 commits into
mainfrom
claude/configurator-colors-panel-bugs-o9tq3k
Jun 24, 2026
Merged

fix: three bugs in configurator colors panel#390
jackgranatowski merged 4 commits into
mainfrom
claude/configurator-colors-panel-bugs-o9tq3k

Conversation

@jackgranatowski

@jackgranatowski jackgranatowski commented Jun 24, 2026

Copy link
Copy Markdown
Contributor
  • OklchPicker: switchMode now converts OKLCH↔OKLab channel state before
    changing mode, so sliders stay consistent and the emitted color doesn't
    jump to a stale/wrong value when the user switches color spaces.

  • OklchPicker: onHexChange no longer fires on 3-char hex; only 6- and
    8-digit hex are accepted. The old 3-char match was causing the $effect
    to overwrite hexInput mid-typing, making it impossible to finish a full
    6-char hex without the field being interrupted.

  • BrandColorRow: pickerValue is now kept in sync via $effect, so typing
    in the text input while the OklchPicker is open updates the picker's
    sliders rather than leaving it showing the stale opening value.

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_013M6i4qstSh8vRPchkfm6Fy

Summary by CodeRabbit

  • New Features

    • Updated the preview experience to better reflect real design-system styling across layout and macro examples.
    • Improved color picker behavior so switching modes keeps the selected color in sync with the active view.
  • Bug Fixes

    • Contrast and gradient previews now refresh more reliably when settings change.
    • Color input handling was tightened for more consistent hex entry and mode switching.
    • Minor visual token updates improve readability in preview chips and swatches.

claude added 4 commits June 24, 2026 05:32
- OklchPicker: switchMode now converts OKLCH↔OKLab channel state before
  changing mode, so sliders stay consistent and the emitted color doesn't
  jump to a stale/wrong value when the user switches color spaces.

- OklchPicker: onHexChange no longer fires on 3-char hex; only 6- and
  8-digit hex are accepted. The old 3-char match was causing the $effect
  to overwrite hexInput mid-typing, making it impossible to finish a full
  6-char hex without the field being interrupted.

- BrandColorRow: pickerValue is now kept in sync via $effect, so typing
  in the text input while the OklchPicker is open updates the picker's
  sliders rather than leaving it showing the stale opening value.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013M6i4qstSh8vRPchkfm6Fy
- ContrastBadge: track per-property override changes with full loop
  (void overrides alone misses value mutations on existing keys)
- DomainPreview: use correct token --sf-color-text--on-primary instead
  of the non-existent --sf-color-on-primary (always fell through to #fff)
- SmartSettings: apply full override cascade to gradient card swatches so
  var(--sf-color-*) refs in gradient values resolve from overrides rather
  than the global :root (which never receives user overrides)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013M6i4qstSh8vRPchkfm6Fy
…t tab

Load core/layout.css in the configurator (safe — all rules are .sf-*
prefixed opt-in classes, no element or reset selectors, no conflict with
chrome styles). This lets the Layout preview tab demonstrate actual
framework primitives instead of custom inline-style simulations.

Every layout section now uses real classes:
- sf-stack / sf-stack--{size} / sf-stack--center/end/stretch
- sf-cluster / sf-cluster--{size} / --center / --between
- sf-grid / sf-grid--{tier} (uses real --sf-grid-min-* tokens)
- sf-grid-cols-{2,3,4} / sf-grid-cols-1-2 / sf-grid-cols-1-3
  (wrapped in sf-cq to provide the required container context)
- sf-equal / sf-equal--{2,3,4,6}
- sf-sidebar / sf-sidebar--right / sf-sidebar--narrow
- sf-switcher, sf-cover + sf-cover__center, sf-frame--video
- sf-bento--3 + sf-bento-featured / sf-bento-wide span modifiers
- sf-divider / sf-divider--{soft,strong,dashed,dotted,gradient}

Remove dead pv__lp-stack and pv__lp-cluster simulation classes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013M6i4qstSh8vRPchkfm6Fy
… framework classes

The Macros tab was demonstrating sf-prose, sf-truncate, sf-line-clamp-*,
sf-surface--*, sf-scroll-shadow, sf-overflow-fade, sf-link--*, sf-tabular-nums,
sf-text-gradient, sf-text-protect, and sf-flow using custom pv__* CSS rules
that manually recreated the framework's visual behavior — meaning user overrides
to color tokens had no effect on the demo output.

Replace every simulation with the real framework class:
- pv__surface-{c}  → sf-surface--{c} (full-color contextual surface macro)
- pv__text-grad    → sf-text-gradient (background-clip: text via --sf-gradient-primary)
- pv__text-protect → sf-text-protect (text-shadow halo from --sf-scrim-text-shadow)
- pv__truncate     → sf-truncate
- pv__clamp2/3/n   → sf-line-clamp-2/3/N with --sf-line-clamp for the N variant
- pv__prose-demo + pv__prose-*/pv__not-prose → sf-prose / sf-not-prose on real HTML
- pv__flow-demo    → sf-flow (lobotomized owl via --sf-flow-space)
- pv__scroll-shadow → sf-scroll-shadow (mask-image fade)
- pv__overflow-fade → sf-overflow-fade (end-edge horizontal mask)
- pv__link-*/pv__link-ext → sf-link--subtle / sf-link--reverse / sf-link-external
- pv__tbl (font-variant-numeric) → sf-tabular-nums class alongside pv__tbl layout

Import core/macros.css in main.js (safe: all .sf-* selectors in @layer
slashed.macros, no global effects) so the real macro classes are available
in the preview stage. Remove all replaced pv__* CSS simulation rules.

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

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR refactors the configurator's Layout and Macros preview tabs to use sf-* utility classes instead of inline styles and pv__* demo classes, importing core/layout.css and core/macros.css to support them. OklchPicker gains proper OKLCH↔OKLab channel conversion on mode switch and restricts HEX input to 6/8-digit forms. BrandColorRow and ContrastBadge receive reactivity fixes.

Changes

Configurator Preview and Color Picker Updates

Layer / File(s) Summary
OklchPicker: HEX validation and OKLCH↔OKLab channel conversion
configurator/src/components/OklchPicker.svelte
HEX input restricted to 6- and 8-digit forms. switchMode rewritten to convert channel values between OKLCH and OKLab via trigonometry (chroma/hue↔a/b), with an early-return guard for same-mode switches and emit() call after conversion.
BrandColorRow picker sync and ContrastBadge override tracking
configurator/src/components/BrandColorRow.svelte, configurator/src/components/ContrastBadge.svelte
BrandColorRow moves pickerValue initialization out of openPicker into a reactive $effect that continuously syncs from the active light/dark values. ContrastBadge iterates overrides keys to track per-property changes instead of touching the whole object.
CSS imports for sf- layout and macro classes*
configurator/src/main.js
Imports core/layout.css and core/macros.css with comments scoping them to sf-* selectors and @layer slashed.macros for the live-preview tabs.
Preview.svelte: Layout tab refactored to sf- classes*
configurator/src/components/Preview.svelte
Demo markup for sf-stack, sf-cluster, sf-grid, sf-grid-cols, sf-equal, sf-sidebar, sf-switcher, sf-cover, sf-frame, sf-bento, sf-container, and sf-divider replaced with modifier-class-driven examples removing inline styles and pv__lp-* patterns.
Preview.svelte: Macros tab + CSS updates
configurator/src/components/Preview.svelte
Surface cells use sf-surface--{token}, text/typography demos use sf-text-gradient/sf-truncate/sf-prose/sf-flow, overflow demos use sf-scroll-shadow/sf-overflow-fade, link demos use pv__a sf-link--*. Component CSS updates .pv__tag, .pv__tbl, .pv__lp-wrap, and .pv__lp-label.
SmartSettings gradient swatch style and DomainPreview token fix
configurator/src/components/SmartSettings.svelte, configurator/src/components/DomainPreview.svelte
SmartSettings derives stageStyle from buildPreviewDeclarations and applies it to gradient swatches. DomainPreview corrects the opacity chip text token from --sf-color-on-primary to --sf-color-text--on-primary.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • codeslash-dev/SLASHED#328: Both PRs make substantial overlapping changes to Preview.svelte, refactoring the live preview markup and layout/macro rendering toward sf-* class-based demos.
  • codeslash-dev/SLASHED#374: Directly connected—both modify the same opacity chip area in DomainPreview.svelte, with this PR correcting the text token introduced by that rework.
  • codeslash-dev/SLASHED#371: Overlaps on DomainPreview.svelte and the buildPreviewDeclarations-driven preview styling used in SmartSettings.svelte.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main user-facing change: fixing three bugs in the configurator colors panel.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ 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-colors-panel-bugs-o9tq3k

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.

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
configurator/src/components/OklchPicker.svelte (1)

134-141: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Don't accept 8-digit HEX until alpha can round-trip.

Line 136 now accepts #RRGGBBAA, but hexToLinearRgb() only consumes the first 6 digits and emit() persists an opaque oklch()/oklab() string. Typing an 8-digit HEX therefore drops transparency before TokenEditor stores the override, which changes the color semantics.

✂️ Safer stopgap
-    if (/^#?[0-9a-fA-F]{6}$/.test(v) || /^#?[0-9a-fA-F]{8}$/.test(v)) {
+    if (/^#?[0-9a-fA-F]{6}$/.test(v)) {
🤖 Prompt for 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.

In `@configurator/src/components/OklchPicker.svelte` around lines 134 - 141, The
onHexChange handler in OklchPicker.svelte is incorrectly accepting 8-digit HEX
input even though the alpha channel is not preserved through hexToLinearRgb,
applyOklch, and emit. Restrict the validation in onHexChange to 6-digit HEX
only, or otherwise reject 8-digit values until alpha can be round-tripped end to
end, so TokenEditor does not store a color override with lost transparency.
🤖 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.

Outside diff comments:
In `@configurator/src/components/OklchPicker.svelte`:
- Around line 134-141: The onHexChange handler in OklchPicker.svelte is
incorrectly accepting 8-digit HEX input even though the alpha channel is not
preserved through hexToLinearRgb, applyOklch, and emit. Restrict the validation
in onHexChange to 6-digit HEX only, or otherwise reject 8-digit values until
alpha can be round-tripped end to end, so TokenEditor does not store a color
override with lost transparency.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6d076273-0b88-4640-b66f-c8803d4d8ee2

📥 Commits

Reviewing files that changed from the base of the PR and between d723bff and 6e56365.

📒 Files selected for processing (7)
  • configurator/src/components/BrandColorRow.svelte
  • configurator/src/components/ContrastBadge.svelte
  • configurator/src/components/DomainPreview.svelte
  • configurator/src/components/OklchPicker.svelte
  • configurator/src/components/Preview.svelte
  • configurator/src/components/SmartSettings.svelte
  • configurator/src/main.js

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e56365406

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +873 to +875
<p style="margin:0">First (no top margin)</p>
<p style="margin:0">Second (gets --sf-flow-space top margin via * + *)</p>
<p style="margin:0">Third (same)</p>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Let sf-flow control the paragraph spacing

In the Macros tab, these inline margin:0 styles prevent the newly imported .sf-flow class from demonstrating its behavior: the framework rule in core/macros.css only adds margin-block-start to > * + *, but the inline margin on each paragraph wins in the cascade, so the second and third lines render with no flow gap despite the label saying they get --sf-flow-space. Removing the child inline margins (or only resetting the first child without overriding block-start on siblings) lets the live preview reflect the real macro.

Useful? React with 👍 / 👎.

@jackgranatowski
jackgranatowski merged commit 2c69ebc into main Jun 24, 2026
13 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.

2 participants