]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
pick-best-color() to color-pick-contrast(), update its comment
authorAndy Cochran <acochran@council.nyc.gov>
Wed, 2 Nov 2016 23:54:19 +0000 (19:54 -0400)
committerAndy Cochran <acochran@council.nyc.gov>
Thu, 17 Nov 2016 18:29:01 +0000 (13:29 -0500)
scss/components/_badge.scss
scss/components/_button.scss
scss/components/_label.scss
scss/components/_tabs.scss
scss/util/_color.scss
test/sass/_color.scss

index 0d139c029b652df1c19bd97b453a3a830b7056f4..768f649f242ada60e9a6630dd453474cd533e728 100644 (file)
@@ -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));
         }
       }
     }
index 4e222cf199f79510cefd3e5531571b1dde5e3405..01686a6efbf83ad6f2ac09e5c1f27ab08819825b 100644 (file)
@@ -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 {
index b849d962dfe1307328441394205bdbf150be4f9b..5f26e91f471d1d9b9d4956dc15468293d72646b1 100644 (file)
@@ -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));
         }
       }
     }
index 37a03a2522a5f307bb45cdc0cc64b20da721403e..f2b61d07cdb5216b5dc00722324e0248590e0c4c 100644 (file)
@@ -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 {
index 07a4cff96e1aa56f9a58f50ad7638d79995e58e6..06018d26786ec274bee95285de126583585308cb 100644 (file)
   @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);
 
index b069ec1505c3c6cafd41911abae963a54e4e94b5..854ca54b1296326d48db1208946f54a491c39261 100755 (executable)
@@ -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,