Skip to content

fix(bricks): resolve REST 404 and add dark mode colors - #116

Merged
jackgranatowski merged 2 commits into
mainfrom
fix/svelte-admin-rest-and-dark-mode
May 27, 2026
Merged

fix(bricks): resolve REST 404 and add dark mode colors#116
jackgranatowski merged 2 commits into
mainfrom
fix/svelte-admin-rest-and-dark-mode

Conversation

@kiro-agent

@kiro-agent kiro-agent Bot commented May 27, 2026

Copy link
Copy Markdown

This pull request was created by @kiro-agent on behalf of @jackgranatowski 👻

Comment with /kiro fix to address specific feedback or /kiro all to address everything.
Learn about Kiro autonomous agent


Summary

Fixes three issues in the Svelte admin app:

1. REST rest_no_route 404 error on save

The REST controller (Slashed_Bricks_REST_Controller) was only instantiated inside the is_admin() block. However, WordPress REST API requests do NOT satisfy is_admin(), so when the Svelte app posted to /wp-json/slashed-bricks/v1/tokens, the routes were never registered and WordPress returned rest_no_route.

Fix: Added a parallel slashed_bricks_rest_init() function that loads the REST controller (and its dependencies: Token Defaults, Token Sanitizer, Tab Registry) on non-admin requests via plugins_loaded.

2. No dark mode color options

The ColorTab only exposed light-mode brand/status colors. The CSS framework supports optional --sf-color-X-dark overrides for full per-mode control, but the admin UI had no way to set them.

Fix:

  • Added "Brand Colors — Dark Mode" and "Status Colors — Dark Mode" sections to ColorTab
  • Updated Token Defaults with brand_dark / status_dark arrays and corresponding hex hints
  • Updated CSS Generator to emit --sf-color-X-dark declarations
  • Updated LivePreview to reflect dark overrides in its generated CSS preview
  • Added --sf-color-{brand}-dark to cheatsheet data

3. Settings verified against library tokens

Cross-referenced all Svelte tab components against core/tokens.css:

  • Colors: brand (6) + status (5) + dark variants ✅
  • Contrast: bias, threshold, opacity_disabled, focus ring ✅
  • Typography: 7 font families, 12 fluid sizes, 2 scale multipliers ✅
  • Spacing: space_scale + 5 aliases ✅
  • Radius: radius_scale ✅
  • Shadows: shadow_strength ✅
  • Motion: motion_scale + 5 durations ✅
  • Z-Index: 8 levels ✅

All settings in the admin app correctly map to the library's CSS custom properties.

- Fix rest_no_route error: REST controller was only loaded inside
  is_admin() block, but REST API requests are not admin requests.
  Added slashed_bricks_rest_init() to register routes on non-admin
  (API) requests.

- Add dark mode color UI: ColorTab now shows separate sections for
  light and dark mode brand/status colors. Dark mode fields are
  optional — the framework auto-derives from light when empty.

- Update CSS generator to emit --sf-color-X-dark declarations when
  dark overrides are set by the user.

- Update Token Defaults with dark mode placeholders and hex hints.

- Update LivePreview to include dark color overrides in generated CSS.

- Add --sf-color-{brand}-dark to cheatsheet data.

Co-authored-by: Jack Granatowski <contact@codeslash.net>
@jackgranatowski

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown

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 57 minutes and 25 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: eea9d9be-748e-4ac3-a092-d8552c8a7f09

📥 Commits

Reviewing files that changed from the base of the PR and between 0891a4f and 16ac2f6.

📒 Files selected for processing (8)
  • integrations/bricks/admin-app/src/components/ColorTab.svelte
  • integrations/bricks/admin-app/src/components/LivePreview.svelte
  • integrations/bricks/admin-app/src/lib/cheatsheet-data.js
  • integrations/bricks/assets/admin-app/app.css
  • integrations/bricks/assets/admin-app/app.js
  • integrations/bricks/includes/class-css-generator.php
  • integrations/bricks/includes/class-token-defaults.php
  • integrations/bricks/slashed-bricks.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/svelte-admin-rest-and-dark-mode

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.

Replace the duplicated slashed_bricks_rest_init() (gated by !is_admin)
with a single rest_api_init hook. WordPress only fires rest_api_init
during REST dispatch, so this is both simpler and eliminates the risk
of dependency drift between admin and REST init paths.

Also removes the redundant REST controller instantiation from the
admin init — routes are now registered exclusively via rest_api_init.
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