Refactor palette color-mix percentages into reusable tokens - #301
Conversation
…leak fix - optional/tokens.palette.css: add --sf-palette-mix-50..950 configurable knobs; all 5 brand and base palette families now use var(--sf-palette-mix-*) instead of hardcoded percentages; add V-shaped ramp docs for base family - core/macros.css: fix alpha leak in --sf-surface-contrast (add / 1); add --sf-focus-ring-color and --sf-caret-color to all 12 surface variants - core/themes.css: add :where([data-theme]:not(:root,html)) bg/color rule so section-level data-theme attributes receive background and text colors - core/tokens.css: expand --sf-contrast-threshold comment with actionable per-surface override examples and escape-hatch instructions - core/layout.css: annotate @container thresholds (30em/48em) explaining CSS spec limitation on var() inside container queries - bundle.config.json: remove core/tokens.color-fallbacks.css from all optimal* and full bundles; file remains available as standalone opt-in - docs/theming.md: add Per-surface color control and Contrast guarantee sections - tests/token-api.snapshot.json: add 10 new --sf-palette-mix-* tokens https://claude.ai/code/session_01SykDjAVz3XdqzcrL1MzZoc
|
Warning Review limit reached
More reviews will be available in 44 minutes and 33 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 (12)
📝 WalkthroughWalkthroughThis pull request introduces a palette ramp customization system via new ChangesPalette Mix and Surface Enhancement
Bundle Configuration and Fallback Cleanup
Theming and Layout Documentation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
The sRGB fallbacks were removed from all default bundles (opt-in only). P3 and P7 previously asserted the fallbacks were embedded in dist/slashed.full.css; they now simulate the documented opt-in load order (core/tokens.color-fallbacks.css linked before the bundle). P3 additionally asserts the fallbacks are NOT embedded in the default bundle, locking in the new contract. https://claude.ai/code/session_01SykDjAVz3XdqzcrL1MzZoc
There was a problem hiding this comment.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
docs/api-index.json (1)
18348-18447:⚠️ Potential issue | 🟠 MajorFix incorrect token descriptions for safe-area inset tokens in
docs/api-index.json.
--sf-safe-bottom,--sf-safe-left,--sf-safe-right, and--sf-safe-top(values areenv(safe-area-inset-*, 0px)) have thedescriptioncopied from--sf-contrast-threshold(“Lightness crossover for text-on-color auto-contrast…”), which is unrelated to safe-area insets.🤖 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/api-index.json` around lines 18348 - 18447, The four token entries --sf-safe-bottom, --sf-safe-left, --sf-safe-right, and --sf-safe-top in docs/api-index.json currently have an incorrect description copied from --sf-contrast-threshold; locate those token objects and replace the description text with an accurate one describing safe-area insets (e.g., "Safe area inset for bottom/left/right/top to account for device notches and UI safe areas; defaults to env(safe-area-inset-*, 0px)"). Ensure each token's description matches its name (bottom/left/right/top) and reflects that the value defaults to env(safe-area-inset-*, 0px).docs/token-index.json (1)
2024-2032:⚠️ Potential issue | 🟠 Major | ⚡ Quick winPrimary ramp still hardcodes mix percentages at Line 2031 and Line 2058.
--sf-color-primary-400and--sf-color-primary-600still use65%/82%literals while the rest of the palette ladder uses--sf-palette-mix-*. This leaves primary partially non-overridable and defeats the new global mix-knob behavior.Suggested fix
- "value": "color-mix(in oklab, var(--sf-color-primary) 65%, var(--sf-color-surface))" + "value": "color-mix(in oklab, var(--sf-color-primary) var(--sf-palette-mix-400), var(--sf-color-surface))" - "value": "color-mix(in oklab, var(--sf-color-primary) 82%, var(--sf-color-text))" + "value": "color-mix(in oklab, var(--sf-color-primary) var(--sf-palette-mix-600), var(--sf-color-text))"Also applies to: 2051-2059
🤖 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/token-index.json` around lines 2024 - 2032, The primary ramp entries --sf-color-primary-400 and --sf-color-primary-600 currently hardcode mix percentages (65% and 82%); replace those literal percentages in their "value" expressions with the corresponding palette mix variables (e.g. use var(--sf-palette-mix-400) for --sf-color-primary-400 and var(--sf-palette-mix-600) for --sf-color-primary-600) so they follow the same overridable mix-knob pattern used by the rest of the palette; update both occurrences mentioned (the 400 and 600 entries) to use the var(...) references instead of numeric literals.
🤖 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/api-index.md`:
- Around line 707-710: Replace the hardcoded mix percentages in the primary ramp
so the ramp is fully configurable: in the table entries for
`--sf-color-primary-400` and `--sf-color-primary-600` (currently using `65%` and
`82%`), swap those literal percentages for the corresponding knob variables
`var(--sf-palette-mix-400)` and `var(--sf-palette-mix-600)` so the
`color-mix(...)` expressions use the palette mix variables instead of fixed
values.
- Around line 440-443: The descriptions for the tokens `--sf-safe-bottom`,
`--sf-safe-left`, `--sf-safe-right`, and `--sf-safe-top` are incorrect (they
currently describe contrast thresholds); replace each description with a concise
safe-area inset description (e.g., "Device safe-area inset for
bottom/left/right/top; value uses env(safe-area-inset-*, 0px) and defaults to
0px") and ensure the example value remains `env(safe-area-inset-*, 0px)`; also
fix the docs generator mapping that assigns descriptions so tokens whose names
start with `--sf-safe-` map to a safe-area inset description rather than the
contrast-threshold template.
- Around line 770-779: The table rows for the palette-mix tokens (e.g.,
`--sf-palette-mix-50`, `--sf-palette-mix-100`, `--sf-palette-mix-200`, ...,
`--sf-palette-mix-950`) have mismatched tier data: the Tier column shows
`PUBLIC` but the description begins with `PUBLIC-ADVANCED`; update either the
Tier column to `PUBLIC-ADVANCED` or change the description prefix to `PUBLIC` so
both metadata and description match for each `--sf-palette-mix-*` entry, keeping
the descriptive text otherwise unchanged.
In `@docs/theming.md`:
- Around line 229-233: The example exposes an internal token
(--sf-surface-contrast) that core/macros.css marks as internal; remove or
replace the .my-card.sf-surface snippet so docs do not instruct consumers to
override --sf-surface-contrast. Instead, demonstrate using a supported public
token or macro (for example show overriding --sf-surface-color or using the
public theming API/macro for surface color) and update the example to reference
.sf-surface and the public token (--sf-surface-color) rather than the internal
--sf-surface-contrast.
In `@docs/token-index.md`:
- Around line 389-392: Update the two primary ramp tokens so they consume the
palette mix knob variables instead of hardcoded percentages: replace the
hardcoded `65%` in `--sf-color-primary-400` with `var(--sf-palette-mix-400)` and
replace the hardcoded `82%` in `--sf-color-primary-600` with
`var(--sf-palette-mix-600)` (ensure you update both locations where
`--sf-color-primary-400` and `--sf-color-primary-600` are defined so they match
how other families use `var(--sf-palette-mix-XXX)`).
In `@optional/tokens.palette.css`:
- Around line 72-74: The primary palette entries --sf-color-primary-400 and
--sf-color-primary-600 were left with literal mix percentages (65% and 82%);
change their color-mix calls to use the shared ramp variables
--sf-palette-mix-400 and --sf-palette-mix-600 respectively (keeping the same
color operands var(--sf-color-primary) with var(--sf-color-surface) for 400 and
var(--sf-color-primary) with var(--sf-color-text) for 600) so they follow the
same global ramp-shape override behavior as the other families.
---
Outside diff comments:
In `@docs/api-index.json`:
- Around line 18348-18447: The four token entries --sf-safe-bottom,
--sf-safe-left, --sf-safe-right, and --sf-safe-top in docs/api-index.json
currently have an incorrect description copied from --sf-contrast-threshold;
locate those token objects and replace the description text with an accurate one
describing safe-area insets (e.g., "Safe area inset for bottom/left/right/top to
account for device notches and UI safe areas; defaults to env(safe-area-inset-*,
0px)"). Ensure each token's description matches its name (bottom/left/right/top)
and reflects that the value defaults to env(safe-area-inset-*, 0px).
In `@docs/token-index.json`:
- Around line 2024-2032: The primary ramp entries --sf-color-primary-400 and
--sf-color-primary-600 currently hardcode mix percentages (65% and 82%); replace
those literal percentages in their "value" expressions with the corresponding
palette mix variables (e.g. use var(--sf-palette-mix-400) for
--sf-color-primary-400 and var(--sf-palette-mix-600) for --sf-color-primary-600)
so they follow the same overridable mix-knob pattern used by the rest of the
palette; update both occurrences mentioned (the 400 and 600 entries) to use the
var(...) references instead of numeric literals.
🪄 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: 359ce941-f472-488d-854e-eab2c15f8282
⛔ Files ignored due to path filters (1)
dist/badge-essential.jsonis excluded by!**/dist/**
📒 Files selected for processing (15)
bundle.config.jsonconfigurator/src/data/api-index.generated.jsoncore/layout.csscore/macros.csscore/themes.csscore/tokens.cssdocs/api-index.jsondocs/api-index.mddocs/registry.jsondocs/theming.mddocs/token-index.jsondocs/token-index.mddocs/tokens.mdoptional/tokens.palette.csstests/token-api.snapshot.json
💤 Files with no reviewable changes (1)
- bundle.config.json
- optional/tokens.palette.css: primary-400/600 now use the --sf-palette-mix-400/600 knobs like every other family (the two steps were missed in the initial migration) - docs/theming.md: stop documenting the internal --sf-surface-contrast helper as an override target; the generic .sf-surface example now pins the public surface-facing tokens instead - scripts/token-tiers.js: classify --sf-palette-mix-* as PUBLIC-ADVANCED (matches the palette file header), fixing the tier/description mismatch in generated docs - core/tokens.css: give the safe-area inset tokens their own comment so generated docs stop inheriting the contrast-threshold description - regenerate docs and bundles https://claude.ai/code/session_01SykDjAVz3XdqzcrL1MzZoc
Summary
Extracted hardcoded color-mix percentages from palette token definitions into a new set of reusable
--sf-palette-mix-*tokens. This enables global ramp shape adjustments without editing individual palette tokens.Key Changes
New palette mix tokens (
optional/tokens.palette.css):--sf-palette-mix-50,--sf-palette-mix-100,--sf-palette-mix-200,--sf-palette-mix-300,--sf-palette-mix-400,--sf-palette-mix-600,--sf-palette-mix-700,--sf-palette-mix-800,--sf-palette-mix-900,--sf-palette-mix-950Refactored palette definitions:
var(--sf-palette-mix-*)instead of hardcoded percentages incolor-mix()expressionsRemoved color-fallback bundles:
core/tokens.color-fallbacks.cssfromoptimalbundle configuration inbundle.config.jsonDocumentation updates:
Implementation Details
The new tokens enable users to reshape the entire color ramp globally by overriding a single set of percentages:
This change propagates across all 6 brand families simultaneously, providing a powerful customization point without requiring per-token overrides. The tokens are marked PUBLIC-ADVANCED to indicate they're powerful but niche.
Token counts increased by 10 (new mix tokens) and palette token category increased from 132 to 142.
https://claude.ai/code/session_01SykDjAVz3XdqzcrL1MzZoc
Summary by CodeRabbit
New Features
--sf-palette-mix-*) enabling customization of color ramp intensities.Improvements
Documentation