Skip to content

Commit

Permalink
Merge pull request #1 from Snugug/master
Browse files Browse the repository at this point in the history
Added yiq-is-light function, refactored yiq-contrast-color to take advantage
  • Loading branch information
timhettler committed Oct 31, 2013
2 parents aad51aa + 8ebd1d9 commit b3f96fc
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 b3f96fc

Please sign in to comment.