Sha256: 378e53bd4aee20b92c06d00f0959be43049eba21e86743e34f6a2c58423067cf

Contents?: true

Size: 1.86 KB

Versions: 2

Compression:

Stored size: 1.86 KB

Contents

@function color($value)
  @if type-of($value) == color
    @return true
  @else
    @return null

@function luma($color)
  // Adapted from: https://gist.github.com/voxpelli/6304812
  $rgba: red($color), green($color), blue($color)
  $rgba2: ()
  @for $i from 1 through 3
    $rgb: nth($rgba, $i)
    $rgb: $rgb / 255
    $rgb: if($rgb < 0.03928, $rgb / 12.92, pow(($rgb + 0.055) / 1.055, 2.4))
    $rgba2: append($rgba2, $rgb)
  @return (0.2126 * nth($rgba2, 1) + 0.7152 * nth($rgba2, 2) + 0.0722 * nth($rgba2, 3)) * 100

$ruma-threshold: 100 / pi() !default

@function luma_contrast($color-1, $color-2: null)
  @if $color-2
    @if abs(luma($color-1) - luma($color-2)) > $ruma-threshold
      @return true
    @else
      @return null
  @else
    @return if(luma($color-1) < 51, dark, bright)

@function luma_value($color-1, $color-2: null)
  @if $color-2
    @return abs(luma($color-1) - luma($color-2))
  @else
    @return luma($color-1)

@function luma_which($color)
  @return if(luma($color-1) < 51, dark, bright)

@function luma_bright($color)
  @if luma($color) < 51
    @return null
  @else
    @return true

@function luma_dark($color)
  @if luma($color) < 51
    @return true
  @else
    @return null

@function luma_contrast_color($color)
  $luma-contrast-bright-color: #000000 !default
  $luma-contrast-dark-color: #ffffff !default
  @if luma_which($color) == bright
    @return $luma-contrast-bright-color
  @else
    @return $luma-contrast-dark-color

@function luma_add_contrast($background-color, $candidate-color)
  @if luma_contrast($background-color, $candidate-color)
    @return $candidate-color
  @else
    @if luma_dark($background-color)
      @return tint($candidate-color, reverse(percentage(luma_value($background-color, $candidate-color)*0.01))/1.618)
    @else
      @return shade($candidate-color, reverse(percentage(luma_value($background-color, $candidate-color)*0.01))/1.618)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
oulu-rails-0.5.9 vendor/assets/stylesheets/settings/functions/_color.css.sass
oulu-rails-0.5.8 vendor/assets/stylesheets/settings/functions/_color.css.sass