Skip to content

Commit

Permalink
Added yiq-is-light function, refactored yiq-contrast-color to take ad…
Browse files Browse the repository at this point in the history
…vantage
  • Loading branch information
Snugug committed Oct 30, 2013
1 parent aad51aa commit 8ebd1d9
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ $yiq-contrasted-light-default: #fff !default;
$yiq-contrasted-threshold: 128 !default;
$yiq-debug: false !default;

@function yiq-contrast-color(
@function yiq-is-light(
$color,
$dark: $yiq-contrasted-dark-default,
$light: $yiq-contrasted-light-default,
$threshold: $yiq-contrasted-threshold
) {
$red: red($color);
Expand All @@ -16,8 +14,17 @@ $yiq-debug: false !default;
$yiq: (($red*299)+($green*587)+($blue*114))/1000;

@if $yiq-debug { @debug $yiq, $threshold; }

@return if($yiq >= $threshold, true, false);
}

@return if($yiq >= $threshold, $yiq-contrasted-dark-default, $yiq-contrasted-light-default);
@function yiq-contrast-color(
$color,
$dark: $yiq-contrasted-dark-default,
$light: $yiq-contrasted-light-default,
$threshold: $yiq-contrasted-threshold
) {
@return if(yiq-is-light($color, $threshold), $yiq-contrasted-dark-default, $yiq-contrasted-light-default);
}

@mixin yiq-contrasted(
Expand All @@ -28,4 +35,4 @@ $yiq-debug: false !default;
) {
background-color: $background-color;
color: yiq-contrast-color($background-color, $dark, $light, $threshold);
}
}

0 comments on commit 8ebd1d9

Please sign in to comment.