Sha256: a4c0c9f1cd5b2d5344c006214400cdd7acb6f7a48fef0db8d28a67347ffff8a5

Contents?: true

Size: 1.47 KB

Versions: 16

Compression:

Stored size: 1.47 KB

Contents

// Foundation for Sites by ZURB
// foundation.zurb.com
// Licensed under MIT Open Source

////
/// @group functions
////

/// Checks the lightness of `$color`, and if it passes the `$threshold` of lightness, it returns the `$yes` color. Otherwise, it returns the `$no` color. Use this function to dynamically output a foreground color based on a given background color.
///
/// @param {Color} $color - Color to check the lightness of.
/// @param {Color} $yes [$black] - Color to return if `$color` is light.
/// @param {Color} $no [$white] - Color to return if `$color` is dark.
/// @param {Percentage} $threshold [60%] - Threshold of lightness to check against.
///
/// @returns {Color} The $yes color or $no color.
@function foreground($color, $yes: $black, $no: $white, $threshold: 60%) {
  @if $color == transparent {
    $color: $body-background;
  }
  @if (lightness($color) > $threshold) {
    @return $yes;
  }
  @else {
    @return $no;
  }
}

/// Scales a color to be lighter if it's light, or darker if it's dark. Use this function to tint a color appropriate to its lightness.
///
/// @param {Color} $color - Color to scale.
/// @param {Percentage} $scale [5%] - Amount to scale up or down.
/// @param {Percentage} $threshold [40%] - Threshold of lightness to check against.
///
/// @returns {Color} A scaled color.
@function smart-scale($color, $scale: 5%, $threshold: 40%) {
  @if lightness($color) > $threshold {
    $scale: -$scale;
  }
  @return scale-color($color, $lightness: $scale);
}

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
pusher-chameleon-1.4.6 stylesheets/util/_color.scss
pusher-chameleon-1.4.5 stylesheets/util/_color.scss
pusher-chameleon-1.4.4 stylesheets/util/_color.scss
pusher-chameleon-1.4.3 stylesheets/util/_color.scss
pusher-chameleon-1.4.2 stylesheets/util/_color.scss
pusher-chameleon-1.4.1 stylesheets/util/_color.scss
pusher-chameleon-1.4.0 stylesheets/util/_color.scss
pusher-chameleon-1.3.0 stylesheets/util/_color.scss
pusher-chameleon-1.2.1 stylesheets/util/_color.scss
pusher-chameleon-1.2.0 stylesheets/util/_color.scss
pusher-chameleon-1.1.0 stylesheets/util/_color.scss
pusher-chameleon-1.0.4 stylesheets/util/_color.scss
pusher-chameleon-1.0.3 stylesheets/util/_color.scss
pusher_chameleon-1.0.3 stylesheets/util/_color.scss
pusher_chameleon-1.0.2 stylesheets/util/_color.scss
pusher_chameleon-1.0.0 stylesheets/util/_color.scss