Skip to content

demo: theme customizer + distinct defaults for primary/action and error/danger - #17

Merged
jackgranatowski merged 1 commit into
mainfrom
kiro/theme-customizer-distinct-tokens
May 18, 2026
Merged

demo: theme customizer + distinct defaults for primary/action and error/danger#17
jackgranatowski merged 1 commit into
mainfrom
kiro/theme-customizer-distinct-tokens

Conversation

@kiro-agent

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

Copy link
Copy Markdown

This pull request was generated by @kiro-agent 👻

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


Summary

  • core/tokens.css — fix overlapping defaults so role names actually correspond to distinct colors:

    • --sf-color-action was identical to --sf-color-primary (both oklch(0.45 0.20 264)). Now oklch(0.60 0.16 210) — a cyan-teal that's clearly distinct from the indigo primary.
    • --sf-color-danger was identical to --sf-color-error (both oklch(0.55 0.22 25)). Now oklch(0.48 0.24 12) — a deeper crimson, clearly distinct from the orange-red error.
    • Bumped --sf-color-tertiary off the action hue (310 instead of 210) so all six brand colors stay separated.
    • Slightly retuned warning to keep separation from error.
    • Mirrored the same distinctness in every *-dark variant.
    • --sf-status-danger-{bg,text,border} now derive from --sf-color-danger instead of aliasing the error triplet.
  • core/base.css — in both dark-mode blocks (@media (prefers-color-scheme: dark) and [data-theme="dark"]), --sf-status-danger-text now derives from --sf-color-danger directly. Comment about keeping the two blocks in sync is honored.

  • docs/demo.html — Theme Customizer:

    • New section at the top of <main> (also added to the side nav as "Theme / Customizer").
    • Two columns: Light mode and Dark mode. Each has Brand (primary/secondary/tertiary/action/neutral/base) and Status (success/warning/error/info/danger) groups of native <input type="color"> pickers.
    • Light pickers write --sf-color-* on :root; dark pickers write --sf-color-*-dark. The framework's existing dark-mode swap takes care of the rest, so toggling dark mode previews the dark palette in context.
    • The dark column itself carries data-theme="dark", so its picker UI always renders against the dark palette — intuitive even while the rest of the page is in light mode.
    • "Reset all" clears the inline overrides and re-reads the registered @property defaults. "Randomize brand" picks a random hue per brand color and sets matching light/dark values.
    • oklch() → hex resolution for the native picker is done with a 1×1 canvas probe and a temporary data-theme-scoped probe element.
    • Stylesheets now load from jsDelivr (https://cdn.jsdelivr.net/gh/codeslash-dev/SLASHED@main/...) instead of relative paths, so the demo can be hosted/embedded standalone.
  • dist/slashed.essential.css — rebuilt with npm run build so the bundle reflects the token changes.

Testing

  • Verified bundle builds with the existing scripts/bundle.js.
  • Confirmed <section> and <script> tags balance in the demo HTML.
  • Spot-checked the bundled output for the new --sf-color-action, --sf-color-danger and --sf-status-danger-* values (all derive from the right base tokens, in both light and dark blocks).

Notes / limitations

  • Status colors typically don't get re-themed at runtime, but the customizer covers them anyway because the user asked for "Brand + status" coverage.
  • <input type="color"> is hex-only, so picking a color converts away from the OKLCH precision. The customizer is a preview tool — the canonical source of truth remains the @property defaults in core/tokens.css.

Summary by CodeRabbit

  • New Features

    • Added a theme customizer to the demo, allowing users to preview and adjust brand and status colors with live light/dark mode toggles, plus reset and randomize options.
  • Style

    • Updated danger status color styling for improved dark mode appearance and consistency with color system tokens.

Review Change Stack

…er defaults

- core/tokens.css: give --sf-color-action a cyan-teal hue (210) so it no
  longer duplicates --sf-color-primary; give --sf-color-danger a deeper
  crimson (12) so it no longer duplicates --sf-color-error; nudge tertiary
  off the new action hue and tweak warning. Status-danger triplets now
  derive from --sf-color-danger instead of aliasing -error.
- core/base.css: in both dark-mode blocks, --sf-status-danger-text now
  derives from --sf-color-danger.
- docs/demo.html: add a Theme Customizer section at the top with two
  columns (light + dark) of native color inputs covering all brand and
  status tokens, plus reset / randomize buttons. Stylesheets now load from
  jsDelivr (codeslash-dev/SLASHED@main) instead of relative paths.
- dist/slashed.essential.css rebuilt.

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

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR refactors CSS color token definitions so that danger status colors derive directly from --sf-color-danger instead of aliasing error tokens, updates dark-mode text styling to match, and adds an interactive theme customizer demo with CDN stylesheets, picker controls, and JavaScript color manipulation logic.

Changes

Color Token Updates & Theme Customizer

Layer / File(s) Summary
Color token definitions and danger status derivation
core/tokens.css
Brand and status color @property Oklch initial values are updated; danger status triplet tokens (--sf-status-danger-bg/text/border) now compute from --sf-color-danger instead of inheriting error token values.
Dark-mode danger text styling
core/base.css
--sf-status-danger-text in auto dark-mode and explicit dark-theme blocks is updated to derive from --sf-color-danger via Oklch clamp formula instead of reusing error text color.
Theme customizer demo and CDN integration
docs/demo.html
Stylesheet loading switches to jsDelivr CDN; customizer UI CSS (grid, pickers, buttons, labels) is added; navigation includes new Customizer link; HTML section provides light/dark color picker columns with Reset and Randomize controls; JavaScript resolves token hex values, syncs input state, applies CSS variable changes, and handles reset/randomize logic with Oklch generation.

Sequence Diagram

sequenceDiagram
  participant User
  participant ColorInput as Color Input
  participant Script as Customizer Script
  participant CSSVars as :root CSS Variables
  participant Display as Picker Display / Labels

  User->>ColorInput: Change color picker
  ColorInput->>Script: Input change event
  Script->>CSSVars: Set :root CSS property
  Script->>Script: Convert hex to oklch()
  Script->>Display: Update label text
  Script->>Display: Re-sync input with current value
  
  User->>ColorInput: Click "Reset all"
  ColorInput->>Script: Reset handler
  Script->>CSSVars: Clear :root overrides
  Script->>Script: Re-resolve token defaults
  Script->>Display: Update all inputs and labels
  
  User->>ColorInput: Click "Randomize brand"
  ColorInput->>Script: Randomize handler
  Script->>CSSVars: Generate and set new oklch() values for light brand tokens
  Script->>CSSVars: Generate and set dark variants
  Script->>Display: Re-sync all inputs and labels
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • codeslash-dev/SLASHED#7: Updates color token derivation for danger status tokens from error aliases to direct --sf-color-danger computation in core/tokens.css.
  • codeslash-dev/SLASHED#15: Modifies dark-mode derived status text colors including --sf-status-danger-text in core/base.css with updated derivation formulas.
  • codeslash-dev/SLASHED#55: Updates SLASHED color-token definitions for status colors with Oklch-based computations of danger tokens from the underlying danger hue.

Suggested reviewers

  • jackgranatowski
🚥 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 directly summarizes the two main changes: adding a theme customizer to the demo and establishing distinct default colors for primary/action and error/danger tokens.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kiro/theme-customizer-distinct-tokens

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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

🤖 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 `@docs/demo.html`:
- Around line 7-9: The demo HTML is loading CSS from jsDelivr using the mutable
`@main` ref which causes previews to pull the live main branch; update the two
<link> hrefs (the slashed.essential.css and optional/tokens.palette.css
references) to point to local built assets (relative paths like
dist/slashed.essential.css and optional/tokens.palette.css) or replace the `@main`
spec with an immutable tag/commit SHA so the demo uses the exact built files
under review.
🪄 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: d68515c5-ddc2-47ed-b812-3d1e6458a087

📥 Commits

Reviewing files that changed from the base of the PR and between 64c343d and c78a20f.

⛔ Files ignored due to path filters (1)
  • dist/slashed.essential.css is excluded by !**/dist/**
📒 Files selected for processing (3)
  • core/base.css
  • core/tokens.css
  • docs/demo.html

Comment thread docs/demo.html
Comment on lines +7 to +9
<!-- SLASHED via jsDelivr CDN -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/codeslash-dev/SLASHED@main/dist/slashed.essential.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/codeslash-dev/SLASHED@main/optional/tokens.palette.css">

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 | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

# First, confirm the content at lines 7-9 of docs/demo.html
head -20 docs/demo.html | cat -n

Repository: codeslash-dev/SLASHED

Length of output: 927


🏁 Script executed:

# Check if there are built assets in the repository
find . -type d -name "dist" -o -name "build" -o -name "assets" 2>/dev/null | head -20

Repository: codeslash-dev/SLASHED

Length of output: 72


🏁 Script executed:

# Search for any references to slashed.essential.css or tokens.palette.css in the repo
rg "slashed\." --type html -A 2 -B 2

Repository: codeslash-dev/SLASHED

Length of output: 449


🏁 Script executed:

# Check the overall structure of the repository
ls -la

Repository: codeslash-dev/SLASHED

Length of output: 1128


🏁 Script executed:

# Check contents of dist directory
ls -la dist/

Repository: codeslash-dev/SLASHED

Length of output: 251


🏁 Script executed:

# Check contents of optional directory
ls -la optional/

Repository: codeslash-dev/SLASHED

Length of output: 503


🏁 Script executed:

# Check if there's a build/versioning strategy in package.json or docs
cat package.json

Repository: codeslash-dev/SLASHED

Length of output: 367


Pin the demo stylesheets to this revision instead of @main.

The demo currently loads CSS from jsDelivr @main, causing local/branch previews to render the stylesheet from the main branch rather than the code under review. Built assets are available locally at dist/slashed.essential.css and optional/tokens.palette.css. Use relative paths to these local assets or pin CDN URLs to an immutable tag/commit to ensure the demo reflects the actual changes being reviewed.

🤖 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 `@docs/demo.html` around lines 7 - 9, The demo HTML is loading CSS from
jsDelivr using the mutable `@main` ref which causes previews to pull the live main
branch; update the two <link> hrefs (the slashed.essential.css and
optional/tokens.palette.css references) to point to local built assets (relative
paths like dist/slashed.essential.css and optional/tokens.palette.css) or
replace the `@main` spec with an immutable tag/commit SHA so the demo uses the
exact built files under review.

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