Skip to content

Instantly share code, notes, and snippets.

@Chrissi2812
Created April 26, 2017 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chrissi2812/d5c7ac87fc08d02c9949312168346066 to your computer and use it in GitHub Desktop.
Save Chrissi2812/d5c7ac87fc08d02c9949312168346066 to your computer and use it in GitHub Desktop.
Sass Auto Text Color
//YIQ Implementation
@function yiq($color) {
$red : red($color);
$green: green($color);
$blue : blue($color);
@return (($red*.299)+($green*.587)+($blue*.114));
}
@function color-contrast($background, $dark:#000, $light:#fff) {
@if yiq($background) >= 128 {
@return $dark;
} @else {
@return $light;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment