Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix bulma color brightness #3837

Merged
merged 2 commits into from
Jul 1, 2024
Merged

Conversation

bagedevimo
Copy link
Contributor

@bagedevimo bagedevimo commented Jun 11, 2024

This is a bugfix.

Proposed solution

Previously, the bulmaColorBrightness function was understating the value of the blue channel when estimating brightness for a specific colour, due to a missing set of brackets. This just corrects the brackets so that all channels of the colour are weighted, instead of just red and green.

Additionally, I've switched from the slash division operation which is deprecated in Sass, to the math.div operator.

Tradeoffs

Some folks may be relying on the slightly odd behaviour, though with blue being the least significant channel for brightness this will be an edge case and will likely be a producing confusing rules with the current implementation.

Testing Done

Ran the docs site and visually compared a variety of buttons, panels, box, and theme pages to ensure no difference. Using the default theming values, validated that there are no differences before and after this change in the output css.

Changelog updated?

No, but happy too if that's a good idea.

Instead of using all channels of the colour to approximate brightness,
this function was sublty ignoring the blue channel and over-stating
other channels.
@jgthms
Copy link
Owner

jgthms commented Jun 12, 2024

Oh wow, good catch! That was definitely an error, since the W3 recommendation I was refering to does have the extra set of brackets: https://www.w3.org/TR/AERT/#color-contrast

The formula should be:

((Red value X 299) + (Green value X 587) + (Blue value X 114)) / 1000

This correction will definitely change things. And I wonder if my error did alter my judgment when developing v1.

I'm gonna check out your branch and see how this looks. Many thanks in any case.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants