@if $name != primary {
&.#{$name} {
background: $color;
- color: pick-best-color($color, ($badge-color, $badge-color-alt));
+ color: color-pick-contrast($color, ($badge-color, $badge-color-alt));
}
}
}
$background-hover-lightness: $button-background-hover-lightness
) {
@if $color == auto {
- $color: pick-best-color($background, ($button-color, $button-color-alt));
+ $color: color-pick-contrast($background, ($button-color, $button-color-alt));
}
@if $background-hover == auto {
@if $name != primary {
&.#{$name} {
background: $color;
- color: pick-best-color($color, ($label-color, $label-color-alt));
+ color: color-pick-contrast($color, ($label-color, $label-color-alt));
}
}
}
background: $primary-color;
> li > a {
- color: pick-best-color($primary-color);
+ color: color-pick-contrast($primary-color);
&:hover,
&:focus {
@return $ratio;
}
-/// Checks the luminance of `$base`, and if it passes the `$threshold` of lightness, it returns the `$yes` color. Otherwise, it returns the `$no` color. Use this function to dynamically output a foreground color based on a given background color.
+/// Checks the luminance of `$base`, and returns the color from `$colors` (list of colors) that has the most contrast.
///
/// @param {Color} $color1 - First color to compare.
/// @param {Color} $color2 - Second color to compare.
///
/// @returns {Number} The contrast ratio of the compared colors.
-@function pick-best-color($base, $colors: ($white, $black), $tolerance: 0) {
+@function color-pick-contrast($base, $colors: ($white, $black), $tolerance: 0) {
$contrast: color-contrast($base, nth($colors, 1));
$best: nth($colors, 1);
@include test-module('Color') {
@include test('Foreground (Black) [function]') {
- $test: pick-best-color($white);
+ $test: color-pick-contrast($white);
$expect: $black;
@include assert-equal($test, $expect,
}
@include test('Foreground (White) [function]') {
- $test: pick-best-color($black);
+ $test: color-pick-contrast($black);
$expect: $white;
@include assert-equal($test, $expect,