Skip to content

Use .blue() instead of .b() in textColorForBackgroundColor - #1031

Open
thomasjlee wants to merge 1 commit into
TryGhost:mainfrom
thomasjlee:always-blue
Open

Use .blue() instead of .b() in textColorForBackgroundColor#1031
thomasjlee wants to merge 1 commit into
TryGhost:mainfrom
thomasjlee:always-blue

Conversation

@thomasjlee

@thomasjlee thomasjlee commented Jul 30, 2026

Copy link
Copy Markdown

Supersedes #905 which has been inactive for a few months

Color.b() returns the b (blue-yellow) LAB color space value of the color instance. It should instead return the blue value in hexadecimal.

The only change was made in packages/color-utils/src/color-utils.ts. I then ran:

  • cd packages/color-utils && yarn build
  • yarn test (in the root)

The deleted test was incorrectly asserting the buggy behavior. The remaining tests seem to provide sufficient coverage.

  • There's a clear use-case for this code change
  • Commit message has a short title & references relevant issues
  • The build will pass (run yarn test and yarn lint)

I believe this will also fix TryGhost/Ghost#27797.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4b407af3-9aad-459e-89a4-e5d835e5f0eb

📥 Commits

Reviewing files that changed from the base of the PR and between f6085ce and bb1d2cf.

⛔ Files ignored due to path filters (3)
  • packages/color-utils/es/color-utils.js.map is excluded by !**/*.map
  • packages/color-utils/umd/color-utils.min.js is excluded by !**/*.min.js
  • packages/color-utils/umd/color-utils.min.js.map is excluded by !**/*.map, !**/*.min.js.map
📒 Files selected for processing (4)
  • packages/color-utils/cjs/color-utils.js
  • packages/color-utils/es/color-utils.js
  • packages/color-utils/src/color-utils.ts
  • packages/color-utils/test/color-utils.test.js
💤 Files with no reviewable changes (1)
  • packages/color-utils/test/color-utils.test.js

Walkthrough

Updated textColorForBackgroundColor to use backgroundColor.blue() for the blue channel in the YIQ contrast calculation across source and generated builds. Updated the test case from #cccccc to #333333, expecting white text.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary fix to use blue() instead of b() in textColorForBackgroundColor.
Description check ✅ Passed The description is directly related to the color utility bug fix, testing, and linked contrast-text-color issue.
Linked Issues check ✅ Passed The source and distributable implementations replace b() with blue(), addressing the linked issue's identified YIQ contrast bug.
Out of Scope Changes check ✅ Passed The implementation and test updates are focused on the linked contrast-color bug, with no unrelated code changes evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…call Color.blue()

refs Ghost (core) Issue #27797
- deleted test that was asserting the buggy behavior
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.

{{contrast_text_color}} helper returns incorrect text color

1 participant