Sha256: 0e9b366050c5fc877560abef03aa9f3f99ad0c0d4a2cb74d9ab367ffd32792fa

Contents?: true

Size: 1019 Bytes

Versions: 3

Compression:

Stored size: 1019 Bytes

Contents

$yiq-contrasted-dark-default: #000 !default;
$yiq-contrasted-light-default: #fff !default;
$yiq-contrasted-threshold: 128 !default;
$yiq-debug: false !default;

@function yiq-is-light(
  $color,
  $threshold: $yiq-contrasted-threshold
) {
  $red: red($color);
  $green: green($color);
  $blue: blue($color);

  $yiq: (($red*299)+($green*587)+($blue*114))/1000;

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

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

@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(
  $background-color,
  $dark: $yiq-contrasted-dark-default,
  $light: $yiq-contrasted-light-default,
  $threshold: $yiq-contrasted-threshold
) {
  background-color: $background-color;
  color: yiq-contrast-color($background-color, $dark, $light, $threshold);
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
compass-yiq-color-contrast-1.1.2 stylesheets/_yiq-color-contrast.scss
compass-yiq-color-contrast-1.1.1 stylesheets/_yiq-color-contrast.scss
compass-yiq-color-contrast-1.1.0 stylesheets/_yiq-color-contrast.scss