_is-light.scss (568B)
1 @charset "UTF-8"; 2 3 /// Programatically determines whether a color is light or dark. 4 /// 5 /// @link http://robots.thoughtbot.com/closer-look-color-lightness 6 /// 7 /// @param {Color (Hex)} $color 8 /// 9 /// @example scss - Usage 10 /// is-light($color) 11 /// 12 /// @return {Bool} 13 14 @function is-light($hex-color) { 15 $-local-red: red(rgba($hex-color, 1)); 16 $-local-green: green(rgba($hex-color, 1)); 17 $-local-blue: blue(rgba($hex-color, 1)); 18 $-local-lightness: ($-local-red * 0.2126 + $-local-green * 0.7152 + $-local-blue * 0.0722) / 255; 19 20 @return $-local-lightness > 0.6; 21 }