fix(bricks): resolve REST 404 and add dark mode colors - #116
Conversation
- 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>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Warning Review limit reached
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 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
✨ 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 |
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.
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_route404 error on saveThe REST controller (
Slashed_Bricks_REST_Controller) was only instantiated inside theis_admin()block. However, WordPress REST API requests do NOT satisfyis_admin(), so when the Svelte app posted to/wp-json/slashed-bricks/v1/tokens, the routes were never registered and WordPress returnedrest_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 viaplugins_loaded.2. No dark mode color options
The ColorTab only exposed light-mode brand/status colors. The CSS framework supports optional
--sf-color-X-darkoverrides for full per-mode control, but the admin UI had no way to set them.Fix:
brand_dark/status_darkarrays and corresponding hex hints--sf-color-X-darkdeclarations--sf-color-{brand}-darkto cheatsheet data3. Settings verified against library tokens
Cross-referenced all Svelte tab components against
core/tokens.css:All settings in the admin app correctly map to the library's CSS custom properties.