-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace yiq contrast by wcag official algorithm #22996
Conversation
…set font color to black or white
you should update our shrinkwrap because you added a new dependency with |
Yes I've seen it. I will update till 1hour |
scss/_functions.scss
Outdated
@@ -53,13 +56,28 @@ | |||
$r: red($color); | |||
$g: green($color); | |||
$b: blue($color); | |||
// get the relative lum for each color | |||
$luminositecouleur: relativelum($r / 255, $g / 255, $b / 255); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small request: as the official language for our files is english, could you update the variables to $luminositycolor
and $luminositywhite
? merci :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, to stay consistent with current WCAG wording (though from what I remember there's discussion about it being incorrect), this should be $luminancecolor
and $luminancewhite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, you were quicker than my brain which needed more coffee ;)
No problem I've many coffee :-) |
LGTM but I'm not a SASS expert. @mdo et al, feel free to merge if this looks kosher to you. |
Would be nice to have |
yes, that's my final idea, evolve that mixin to create a generic one that return a comparison between two colors. Or add in parameter output colors |
Not a fan of the dependency here. Is there another solution we could try? And if this changes what is output on our components, we'll need to revisit more things. |
I believe functionally the output is the same, just that it flips between light and dark text at a better calculated threshold which matches up with WCAG 2's requirements. |
Yeah, I mean visually as much as the compiled code :). |
Visually it'll be the same, except at the point just on the cusp between where light or dark would be better. There, it'll flip at a slightly earlier/later point, so yes for certain background colors it will be visually different. |
I understand and agree that adding a sass dependency is not fun. For @mdo the solution could be to Copy/paste source code directly in bootstrap utilities, because I don't think that pow expression will change in the time. for each $color in $chalenging-color-list -> check if ratio is valid, return the first valid color |
One alternative to the extra dependency would be to use the experimental const sass = require('sass')
const functions = {
pow(base, exponent) {
const result = Math.pow(base.getValue(), exponent.getValue())
return new sass.types.Number(result)
}
} Would need some additional documentation for ruby-sass and other variants. |
… functions feature in node-sass
build/sass-functions.js
Outdated
|
||
// Export math.pow function for node-sass | ||
|
||
var types = require('node-sass').types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should use const
instead of var
here because you don't change types
Hi, any news about this PR? I can update it if needed |
Hello, do you have news about this issue? We would like to use WCAG contrast for color-yiq function. We tried to play with the treshold, but as it ia not the same function we can't have something perfect. |
Hello, I use it in Boosted (that's why I create this PR) But wonder that one will go into the core soon. |
@Lausselloic: can you fetch upstream and rebase? |
I'm afraid we can't do this. This will make bootstrap not buildable with anything else than |
@MartijnCuppens Damn, if that's the case, feel free to close this out. Will wait for you to confirm though! |
Following @mdo PR for color update : #22836
Many thanks for the color contrast mixin which check the font color according to the background for badges only at time. But yiq is not the official wcag and doesn't give the same result on some colors (e.g with blue #527edb yiq set text color to white where official wcag lum set it to black.
I propose a SCSS adaptation of the HTMLCS JS solution. Need to add a dependency to sass-math-pow.
I hope this solution will be helpfull. Let me know