Use .blue() instead of .b() in textColorForBackgroundColor#905
Conversation
.b() returns the HSB brightness component, not the blue RGB channel. This caused incorrect YIQ calculation for most colors.
WalkthroughThis PR adjusts formatting and line breaks in the Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit eca1791. Configure here.
There was a problem hiding this comment.
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 `@packages/color-utils/cjs/color-utils.js`:
- Around line 38-41: The YIQ luminance calculation uses the Lab b-channel method
call `.b()` in the TypeScript source (packages/color-utils/src/color-utils.ts)
causing wrong RGB values; update the calculation where `yiq` is computed (the
expression that multiplies backgroundColor channels) to call
`backgroundColor.blue()` instead of `backgroundColor.b()`, ensure the code still
references `backgroundColor.red()` and `backgroundColor.green()` as before, then
rebuild the package so CJS/ES/UMD outputs are regenerated with the corrected
YIQ/contrast logic.
🪄 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
Run ID: ed186db0-2471-4a27-877f-6dd9ab54ba21
📒 Files selected for processing (1)
packages/color-utils/cjs/color-utils.js

.b() returns the HSB brightness component, not the blue RGB channel. This caused incorrect YIQ calculation for most colors.
Note
Low Risk
Small, localized bugfix in
textColorForBackgroundColorthat changes text color selection results for some backgrounds; low risk but may affect UI contrast outcomes.Overview
Fixes
textColorForBackgroundColor’s YIQ computation to use the RGB blue channel viablue()instead ofb()(which refers to a different color component), correcting text color selection for many backgrounds.Rebuilds the generated
cjs/esoutputs to reflect this change.Reviewed by Cursor Bugbot for commit 301ad96. Bugbot is set up for automated code reviews on this repo. Configure here.