feat(core): refine CSS functions for perceptual uniformity#48
Merged
Conversation
📝 WalkthroughWalkthroughMakes gamut-aware adjustments to color and shadow utilities, clamps saturate/desaturate, rebuilds glow and text-shadow layers, updates contrast/readability logic (including Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/core/src/utils/functions.css`:
- Around line 121-137: The fallback function --s-contrast-text-fallback uses a
0.6 OKLCH lightness threshold which is inconsistent with the [s-dark-aware]
component's 0.55 threshold; update the fallback to use 0.55 instead of 0.6 by
changing the clamp/threshold expression inside --s-contrast-text-fallback so
both --s-contrast-text-fallback and [s-dark-aware] use the same 0.55 lightness
threshold for consistent visual results across fallbacks and native
color-contrast().
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/core/src/utils/functions.css`:
- Around line 121-137: The current `@function` --s-contrast-text relies on
color-contrast(), which has no stable browser support and cannot be
feature-detected inside CSS functions (if() is Chromium-only and CSS `@supports`
works only at rule level), so change the implementation to make the fallback
reachable: either make --s-contrast-text use the logic from
--s-contrast-text-fallback as the default implementation and keep
--s-contrast-text-fallback for clarity, or keep the simple fallback in
--s-contrast-text and move any color-contrast()/contrast-color() usage into the
consumer rules using `@supports` (matching the pattern in
surface.css/button.css/badge.css) so you detect support at rule level before
applying the newer API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Aligned all OKLCH-based CSS functions with perceptual uniformity philosophy. Functions now use modern 2026 CSS features (
color-contrast(),round()) for accurate color math and rhythm-aligned spacing.Changes
--s-saturatemin(0.4)clamp to prevent overflow--s-desaturatemax(0)prevents negative chroma values--s-glow--s-text-shadow-glow--s-contrast-textcolor-contrast()for true WCAG 2.2 compliance--s-readable-on--s-space-scaleround()quantizes output to base unit for Bento rhythmPhilosophy Alignment
color-contrast()delegates luminance calculation to browser engineRelated Issues
N/A
Checklist
bun run lintpassesbun run buildsucceedsType of Change
Additional Notes
Added
--s-contrast-text-fallbackfunction for browsers withoutcolor-contrast()support. The fallback uses the 0.6 OKLCH lightness threshold approximation.