From: Andy Cochran Date: Wed, 2 Nov 2016 23:54:19 +0000 (-0400) Subject: pick-best-color() to color-pick-contrast(), update its comment X-Git-Tag: v6.3-rc1~6^2~4^2~2^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44f4a2bcee4dc28891aff2ec910a70419634aa05;p=thirdparty%2Ffoundation%2Ffoundation-sites.git pick-best-color() to color-pick-contrast(), update its comment --- diff --git a/scss/components/_badge.scss b/scss/components/_badge.scss index 0d139c029..768f649f2 100644 --- a/scss/components/_badge.scss +++ b/scss/components/_badge.scss @@ -53,7 +53,7 @@ $badge-font-size: 0.6rem !default; @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)); } } } diff --git a/scss/components/_button.scss b/scss/components/_button.scss index 4e222cf19..01686a6ef 100644 --- a/scss/components/_button.scss +++ b/scss/components/_button.scss @@ -114,7 +114,7 @@ $button-transition: background-color 0.25s ease-out, color 0.25s ease-out !defau $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 { diff --git a/scss/components/_label.scss b/scss/components/_label.scss index b849d962d..5f26e91f4 100644 --- a/scss/components/_label.scss +++ b/scss/components/_label.scss @@ -54,7 +54,7 @@ $label-radius: $global-radius !default; @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)); } } } diff --git a/scss/components/_tabs.scss b/scss/components/_tabs.scss index 37a03a252..f2b61d07c 100644 --- a/scss/components/_tabs.scss +++ b/scss/components/_tabs.scss @@ -169,7 +169,7 @@ $tab-content-padding: 1rem !default; background: $primary-color; > li > a { - color: pick-best-color($primary-color); + color: color-pick-contrast($primary-color); &:hover, &:focus { diff --git a/scss/util/_color.scss b/scss/util/_color.scss index 07a4cff96..06018d267 100644 --- a/scss/util/_color.scss +++ b/scss/util/_color.scss @@ -51,13 +51,13 @@ @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); diff --git a/test/sass/_color.scss b/test/sass/_color.scss index b069ec150..854ca54b1 100755 --- a/test/sass/_color.scss +++ b/test/sass/_color.scss @@ -6,7 +6,7 @@ @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, @@ -14,7 +14,7 @@ } @include test('Foreground (White) [function]') { - $test: pick-best-color($black); + $test: color-pick-contrast($black); $expect: $white; @include assert-equal($test, $expect,