openfoodfoundation/openfoodnetwork

View on GitHub
app/webpacker/css/admin/globals/functions.scss

Summary

Maintainability
Test Coverage
// Make color very close to white
@function very-light($color, $adjust: 3) {
  @if type-of($adjust) == "number" and $adjust > 0 {
    @for $i from 0 through 100 {
      @if lighten($color, $i) == white and ($i - $adjust) > $adjust {
        @return lighten($color, $i - $adjust);
      }
    }
  } @else {
    @debug "Please correct $adjust value. It should be number and larger then 0. Currently it is '#{type-of($adjust)}' with value '#{$adjust}'";
  }
}

// Quick fix for dynamic variables missing in SASS
@function get-value($prop, $val, $search) {
  $n1: index($prop, $search);
  $n2: index($val, $search);

  @if ($n1) {
    @return nth($val, $n1);
  } @else {
    @return nth($prop, $n2);
  }
}