-
-
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
Reuse of the color-yiq function #23114
Comments
envolute
pushed a commit
to envolute/bootstrap
that referenced
this issue
Aug 1, 2017
This change refers to the issue twbs#23114
This was referenced Aug 1, 2017
It would be much better to change it to a function, so we can use it for whatever we like. Then the colors Function // Color contrast
@function color-yiq($color) {
$r: red($color);
$g: green($color);
$b: blue($color);
$yiq: (($r * 299) + ($g * 587) + ($b * 114)) / 1000;
@if ($yiq >= 150) {
@return $text-black;
} @else {
@return $text-white;
}
} Mixins @mixin text-color($color: $body-bg) {
color: color-yiq($color);
} or @mixin color-yiq($color: $body-bg, $prop: 'color') {
#{$prop}: color-yiq($color);
} |
A PR is welcome. |
Mixin was renamed to be a function in #24426. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With a simple change it is possible to use the color-yiq function with other properties, not just "color"
Just add the parameter "$prop: 'color'" that we can use other properties
This can be interesting when you want to assign a background that contrasts with a color.
The text was updated successfully, but these errors were encountered: