Cleaned up color_to_rgba template helper#28392
Conversation
|
Too much diff to scan? Review this PR in Change Stack to start with the highest-impact changes. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe JavaScript helper for color_to_rgba was removed and replaced by a new TypeScript implementation that parses and sanitizes raw color and alpha inputs, clamps alpha to [0,1], applies the alpha using 🚥 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 docstrings
🧪 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 |
no ref This makes several fixes to our `color_to_rgba` template helper: - Handles more invalid `alpha` values: non-numbers, non-strings, and `NaN`. - Converts everything to TypeScript. - Uses "color" in all variable names, instead of both "color" and "background color". - Uses "alpha" in all variable names, instead of both "alpha" and "opacity". - Adds additional tests. This shouldn't change anything for folks using the helper correctly. If they were using it *incorrectly* (e.g., passing an invalid `alpha` value), we now normalize it a little better. I followed [the docs][0] when deciding how things should work. [0]: https://docs.ghost.org/themes/helpers/utility/color_to_rgba
5d8ad04 to
e987c3d
Compare
no ref
This makes several fixes to our
color_to_rgbatemplate helper:Handles more invalid
alphavalues: non-numbers, non-strings, andNaN.Converts everything to TypeScript.
Uses "color" in all variable names, instead of both "color" and "background color".
Uses "alpha" in all variable names, instead of both "alpha" and "opacity".
Adds additional tests.
This shouldn't change anything for folks using the helper correctly. If they were using it incorrectly (e.g., passing an invalid
alphavalue), we now normalize it a little better. I followed the docs when deciding how things should work.