Skip to content

Sync viewport previews, revamp live preview, icon-trigger class hints - #229

Merged
jackgranatowski merged 2 commits into
mainfrom
claude/blissful-brahmagupta-UaAVU
Jun 5, 2026
Merged

Sync viewport previews, revamp live preview, icon-trigger class hints#229
jackgranatowski merged 2 commits into
mainfrom
claude/blissful-brahmagupta-UaAVU

Conversation

@jackgranatowski

@jackgranatowski jackgranatowski commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Svelte admin panel:

  • Live Scale Preview sliders in the Spacing and Typography tabs now scrub
    the actual Fluid Scale Viewport Range (viewport_min/viewport_max from
    the Spacing tab) instead of hardcoded bounds. The range is exposed via
    a shared viewportRangePx() helper so both previews — and the generated
    clamp() — share one source of truth; the Typography tab references the
    Spacing tab as that source.
  • Rewrote the bottom Live Preview into a token-driven design-set showcase:
    computes auto-contrasting on-color text, surfaces, text hierarchy,
    borders, links and status tints mirroring core/tokens.css. Fixes the
    unreadable white-on-light-status text and adds surfaces, typography,
    feedback alerts, buttons, a card and a form field.
  • Header height / sticky offset inputs now show the framework default
    values (3.5rem / 5rem) as placeholders.

Bricks editor:

  • Class hints no longer trigger on hovering the whole class row (which
    obscured controls and was buggy). Instead a small "?" info icon is
    injected beside each SLASHED class row's action icons, and the tooltip
    is bound to that icon only. Reconcile-based, idempotent, fail-silent.

Summary by CodeRabbit

  • New Features

    • Added info icon buttons with tooltips for class documentation in the Bricks class manager.
  • Improvements

    • Enhanced live preview with improved design system visualization, including typography, color swatches, and form field rendering.
    • Unified viewport range handling across spacing and typography previews.
    • Updated default header height and sticky offset values for better framework alignment.
  • Documentation

    • Clarified font size scale viewport interpolation range documentation.

Svelte admin panel:
- Live Scale Preview sliders in the Spacing and Typography tabs now scrub
  the actual Fluid Scale Viewport Range (viewport_min/viewport_max from
  the Spacing tab) instead of hardcoded bounds. The range is exposed via
  a shared viewportRangePx() helper so both previews — and the generated
  clamp() — share one source of truth; the Typography tab references the
  Spacing tab as that source.
- Rewrote the bottom Live Preview into a token-driven design-set showcase:
  computes auto-contrasting on-color text, surfaces, text hierarchy,
  borders, links and status tints mirroring core/tokens.css. Fixes the
  unreadable white-on-light-status text and adds surfaces, typography,
  feedback alerts, buttons, a card and a form field.
- Header height / sticky offset inputs now show the framework default
  values (3.5rem / 5rem) as placeholders.

Bricks editor:
- Class hints no longer trigger on hovering the whole class row (which
  obscured controls and was buggy). Instead a small "?" info icon is
  injected beside each SLASHED class row's action icons, and the tooltip
  is bound to that icon only. Reconcile-based, idempotent, fail-silent.
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jackgranatowski, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 39 minutes and 37 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f406a9f3-b147-4698-84c3-fbcf2ee2870d

📥 Commits

Reviewing files that changed from the base of the PR and between a398f60 and bb188c6.

📒 Files selected for processing (2)
  • plugins/SLASHED-for-WP/integrations/bricks/assets/editor-app/app.js
  • plugins/SLASHED-for-WP/integrations/bricks/editor-app/src/lib/class-hints.js
📝 Walkthrough

Walkthrough

This PR refactors the Bricks admin UI and editor interactions: a new viewport range helper consolidates hardcoded viewport constants used by preview components; the LivePreview component is completely redesigned to render token-driven design-system components; class hints transition from hover-based tooltips to injected icon buttons with focused event handling; and layout/typography hint text and default values are clarified and aligned.

Changes

Admin UI and Editor Enhancements

Layer / File(s) Summary
Viewport Range Helper
plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/lib/stores.svelte.js
Introduces viewportRangePx() to derive viewport clamp bounds from reactive tokens.spacing with fallbacks to defaults, replacing hardcoded VW_MIN/VW_MAX constants across preview components.
Preview Components Viewport Integration
plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/components/SpacingPreview.svelte, TypographyPreview.svelte
SpacingPreview and TypographyPreview now derive viewport slider bounds and interpolation from the reactive viewportRangePx() helper, with reactive clamping when bounds change and updated slider UI labels.
LivePreview Canvas Redesign
plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/components/LivePreview.svelte, assets/admin-app/app.css
Replaces legacy DOM-querying preview with token-driven canvas: expanded inline CSS-variable generation computes light/dark active-mode colors (--c-*), auto-contrasting text (--on-*), surface/hierarchy variables, status tints, and layout params. Template rewritten with semantic sf-canvas/sf-* classes rendering typography, surfaces grid, swatches, buttons, status feedback, card, and form field. Component and admin app stylesheets completely rewritten for the new canvas layout.
Class Hints Icon Button Redesign
plugins/SLASHED-for-WP/integrations/bricks/editor-app/src/lib/class-hints.js, src/styles/panel.css, assets/editor-app/app.css, docs/roadmap.md
Refactors from body-delegated hover tooltip to injected ? icon button: module now uses MutationObserver to detect Bricks container changes, idempotently injects buttons beside row actions, and shows tooltips via button-specific event handlers (mouseenter/leave, focus/blur, click, Escape). Tooltip repositions to center over button and clamp to viewport. Button stores class name in dataset for hint re-resolution on reuse. New .rebemer-class-hint-btn CSS styling and editor app stylesheet regeneration support the icon visual and interaction states. Roadmap documentation updated to reflect the icon-based behavior.
Layout & Typography Defaults and Documentation
plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/components/LayoutsTab.svelte, TypographyTab.svelte
LayoutsTab hint text now documents framework default header heights (3.5rem mobile, 5rem desktop) and all mobile/desktop height and offset NumberField defaults now fall back to non-empty values instead of empty strings. TypographyTab hint clarifies that fluid type scaling uses the Fluid Scale Viewport Range set in the Spacing tab.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • codeslash-dev/SLASHED#180: Implements the earlier "class documentation tooltips" feature that this PR refactors from hover-only to icon-based interaction, modifying the same class-hints.js editor-side logic and UI styling.
  • codeslash-dev/SLASHED#151: Refactors LivePreview.svelte to switch from legacy DOM-based rendering to a token-driven canvas, directly overlapping with the preview redesign in this PR.
  • codeslash-dev/SLASHED#157: Adds the underlying show_class_hints setting generation and data/classes-hints.json fixture that feeds the class hints icon button implementation in this PR.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the three main changes: syncing viewport previews (Spacing/Typography sliders now use shared viewportRangePx), revamping the live preview (token-driven design showcase), and implementing icon-triggered class hints.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/blissful-brahmagupta-UaAVU

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: 2

🧹 Nitpick comments (2)
plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/components/LivePreview.svelte (2)

186-186: 💤 Low value

Minor: inconsistent variable name in sample text.

The preview text references --sf-color-text--secondary (double hyphen) but the actual CSS variable used throughout is --c-text-secondary. Consider updating to match the preview's actual token name for clarity.

🤖 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
`@plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/components/LivePreview.svelte`
at line 186, The sample preview text in LivePreview.svelte uses the wrong CSS
variable name `--sf-color-text--secondary`; replace that string with the actual
token name `--c-text-secondary` so the preview matches the CSS variables used in
the app (update the text/rendered sample that currently references
`--sf-color-text--secondary` to `--c-text-secondary`).

94-99: Update CSS sign() browser support in onColor() compatibility note.

LivePreview.svelte (lines 94-99) uses CSS sign() in onColor(). sign() is supported in Chrome/Edge 138+, Firefox 118+, and Safari 15.4+ (Baseline Newly Available: 2025-06-26). If the WordPress admin audience includes browsers older than these, add a fallback or document a supported-browser minimum.

🤖 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
`@plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/components/LivePreview.svelte`
around lines 94 - 99, The CSS sign() call in onColor() can be unsupported in
some browsers; change onColor to use a CSS custom property fallback (e.g.
replace sign(${TH} - l) with var(--sign-${name}, 1)) and in the same code where
pairs are built set a per-color CSS var (--sign-<name>) via JS when rendering
LivePreview.svelte: compute the sign from (TH - l) in JS and push a fallback
declaration like `--sign-${name}: ${signValue}` into pairs (or set it on the
preview element style) so older browsers use the JS-provided sign while modern
browsers still resolve the real sign() expression.
🤖 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
`@plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/components/LayoutsTab.svelte`:
- Line 88: Replace logical-OR fallbacks with nullish coalescing for the default
bindings so only null/undefined trigger the hardcoded fallback: change
expressions like defaults.header_height_mobile || '3.5' to use ??, and do the
same for the other affected bindings (the occurrences referencing
defaults.header_height_mobile, defaults.header_height_desktop and the other
header height/default fields at the other noted locations). Ensure each Svelte
input/default uses the ?? operator so legitimate falsy values (0 or empty
string) from defaults are preserved.

In
`@plugins/SLASHED-for-WP/integrations/bricks/editor-app/src/lib/class-hints.js`:
- Around line 316-333: The observer filter (touchesContainers) currently ignores
removed nodes so a detached anchored row can leave _activeBtn set while the
tooltip stays visible; update touchesContainers to also iterate m.removedNodes
and return true if any removed node contains or is the current _activeBtn (or
matches BRICKS_CONTAINERS/BUTTON selector) so reconcile() runs and clears
_activeBtn; reference the function touchesContainers, the variable _activeBtn,
the reconcile() caller, and BTN_CLASS/BRICKS_CONTAINERS selectors, and apply the
same removed-nodes check to the other similar observer/filter block (the one
around the 364–366 area).

---

Nitpick comments:
In
`@plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/components/LivePreview.svelte`:
- Line 186: The sample preview text in LivePreview.svelte uses the wrong CSS
variable name `--sf-color-text--secondary`; replace that string with the actual
token name `--c-text-secondary` so the preview matches the CSS variables used in
the app (update the text/rendered sample that currently references
`--sf-color-text--secondary` to `--c-text-secondary`).
- Around line 94-99: The CSS sign() call in onColor() can be unsupported in some
browsers; change onColor to use a CSS custom property fallback (e.g. replace
sign(${TH} - l) with var(--sign-${name}, 1)) and in the same code where pairs
are built set a per-color CSS var (--sign-<name>) via JS when rendering
LivePreview.svelte: compute the sign from (TH - l) in JS and push a fallback
declaration like `--sign-${name}: ${signValue}` into pairs (or set it on the
preview element style) so older browsers use the JS-provided sign while modern
browsers still resolve the real sign() expression.
🪄 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: 521ccd06-7d41-4de5-8292-1f8dd82fa082

📥 Commits

Reviewing files that changed from the base of the PR and between e5a7b96 and a398f60.

📒 Files selected for processing (13)
  • docs/roadmap.md
  • plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/components/LayoutsTab.svelte
  • plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/components/LivePreview.svelte
  • plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/components/SpacingPreview.svelte
  • plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/components/TypographyPreview.svelte
  • plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/components/TypographyTab.svelte
  • plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/lib/stores.svelte.js
  • plugins/SLASHED-for-WP/integrations/bricks/assets/admin-app/app.css
  • plugins/SLASHED-for-WP/integrations/bricks/assets/admin-app/app.js
  • plugins/SLASHED-for-WP/integrations/bricks/assets/editor-app/app.css
  • plugins/SLASHED-for-WP/integrations/bricks/assets/editor-app/app.js
  • plugins/SLASHED-for-WP/integrations/bricks/editor-app/src/lib/class-hints.js
  • plugins/SLASHED-for-WP/integrations/bricks/editor-app/src/styles/panel.css

min={0}
step={0.25}
default={defaults.header_height_mobile ?? ''}
default={defaults.header_height_mobile || '3.5'}

@coderabbitai coderabbitai Bot Jun 5, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use nullish coalescing (??) instead of logical OR (||) for fallback defaults.

The || operator treats all falsy values (0, '', false, null, undefined) as triggers for the fallback, which could mask legitimate PHP defaults. If defaults.header_height_mobile or similar fields are explicitly set to 0 or an empty string in PHP, the operator will incorrectly fall back to the hardcoded '3.5' or '5' instead of using the actual PHP default.

Use the nullish coalescing operator (??) to only fall back when the value is strictly null or undefined.

🔧 Proposed fix
-          default={defaults.header_height_mobile || '3.5'}
+          default={defaults.header_height_mobile ?? '3.5'}

-          default={defaults.header_height_desktop || '5'}
+          default={defaults.header_height_desktop ?? '5'}

-          default={defaults.sticky_offset_mobile || '3.5'}
+          default={defaults.sticky_offset_mobile ?? '3.5'}

-          default={defaults.sticky_offset_desktop || '5'}
+          default={defaults.sticky_offset_desktop ?? '5'}

Also applies to: 98-98, 113-113, 123-123

🤖 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
`@plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/components/LayoutsTab.svelte`
at line 88, Replace logical-OR fallbacks with nullish coalescing for the default
bindings so only null/undefined trigger the hardcoded fallback: change
expressions like defaults.header_height_mobile || '3.5' to use ??, and do the
same for the other affected bindings (the occurrences referencing
defaults.header_height_mobile, defaults.header_height_desktop and the other
header height/default fields at the other noted locations). Ensure each Svelte
input/default uses the ?? operator so legitimate falsy values (0 or empty
string) from defaults are preserved.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Keeping || here intentionally. The default prop is used only as the input placeholder, and the PHP defaults for these four fields are empty strings ('header_height_mobile' => '', etc. in class-token-defaults.php) — that empty value means "no override, fall back to the framework value". Switching to ?? would yield '' ?? '3.5''', which re-introduces the very missing-placeholder bug this change fixes. With ||, an empty PHP default correctly surfaces the framework value (3.5rem / 5rem) as the placeholder. meta.defaults is the read-only framework default map, so a legitimate 0 is never expected for these height fields.


Generated by Claude Code

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@jackgranatowski, thanks for the clear explanation — that makes complete sense. Since class-token-defaults.php uses '' as the "no override" sentinel for these height fields, || is exactly right: it correctly promotes an empty-string PHP default to the visible framework placeholder (3.5 / 5), whereas ?? would pass the empty string through and silently swallow the placeholder. I'll withdraw the suggestion.


✏️ Learnings added
Learnt from: jackgranatowski
Repo: codeslash-dev/SLASHED PR: 229
File: plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/components/LayoutsTab.svelte:88-88
Timestamp: 2026-06-05T00:31:10.366Z
Learning: In `plugins/SLASHED-for-WP/integrations/bricks/admin-app/src/components/LayoutsTab.svelte`, the `default` prop on `NumberField` for `header_height_mobile`, `header_height_desktop`, `sticky_offset_mobile`, and `sticky_offset_desktop` intentionally uses logical-OR (`||`) rather than nullish coalescing (`??`). The PHP defaults in `class-token-defaults.php` for these four fields are empty strings (`''`), which means "no override — show framework default as placeholder". `||` correctly promotes `''` to the hardcoded framework placeholder (`'3.5'` / `'5'`), whereas `??` would pass the empty string through unchanged. A legitimate value of `0` is never expected for these rem-based height fields.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: CR
Repo: codeslash-dev/SLASHED PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-05-12T22:15:57.949Z
Learning: Applies to **/*.css : Reach for fluid tokens (space, text, leading with `clamp()`) first for responsive design, then container-aware primitives (`.grid`, `.stack`, `.cluster`), then breakpoint utilities as a last resort.

If a class row holding the active "?" icon is deleted while its tooltip
is open, _activeBtn detaches but the fixed-position tooltip would stay
visible pointing at nothing. The body observer now drops it as soon as
the anchor leaves the DOM.

Addresses CodeRabbit review on PR #229.
@jackgranatowski
jackgranatowski merged commit dc3bc47 into main Jun 5, 2026
9 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