voxpelli / sass-color-helpers

A collection of Sass color helpers that enables easier, more fool-proof design implementations (+ some math helpers)
92 stars 9 forks source link

Look into adding some kind of simple warning funcitonality #6

Open voxpelli opened 7 years ago

voxpelli commented 7 years ago

Perhaps omething like:

@include ch-color-contrast-warn($baseColor, $topColor);

With maybe an implementation like:

@mixin ch-color-contrast-warn($color1, $color2, $target: 3) {
  $contrast: ch-color-contrast($color1, $color2);

  @if ($contrast < $target) {
    @warn "Contrast ratio of #{$color2} on #{$color1} is pretty bad, wanted a contrast of at least #{$target} but got just #{$contrast}";
  }
}

Would have preferred to have it as a function, but functions in Sass needs to return a value and when called, needs to assign that value somewhere.

A mixin on the other hand doesn't need to have any side effects whatsoever.