Sha256: e942ea3ca42834bfb54b02b2f5a6c1ccbb6967893ee566c8130012854dff4a4e

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

$contrasted-dark-default:   #000 !default;
$contrasted-light-default:  #fff !default;
$contrasted-lightness-threshold: 30% !default;

// Returns the `$light` color when the `$color` is dark
// and the `$dark` color when the `$color` is light.
// The `$threshold` is a percent between `0%` and `100%` and it determines
// when the lightness of `$color` changes from "dark" to "light".
@function contrast-color(
  $color,
  $dark: $contrasted-dark-default,
  $light: $contrasted-light-default,
  $threshold: $contrasted-lightness-threshold
) {
  @return if(lightness($color) < $threshold, $light, $dark)
}

// Sets the specified background color and calculates a dark or light contrasted text color.
// The arguments are passed through to the [contrast-color function](#function-contrast-color).
@mixin contrasted(
  $background-color,
  $dark: $contrasted-dark-default,
  $light: $contrasted-light-default,
  $threshold: $contrasted-lightness-threshold
) {
  background-color: $background-color;
  color: contrast-color($background-color, $dark, $light, $threshold);
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
compass-sourcemaps-0.12.3.sourcemaps.a4836f1 frameworks/compass/stylesheets/compass/utilities/color/_contrast.scss
compass-sourcemaps-0.12.2.sourcemaps.57a186c frameworks/compass/stylesheets/compass/utilities/color/_contrast.scss