SASS Color Weight Mixin - Stack Overflow

PHOTO EMBED

Sat Jan 08 2022 01:31:26 GMT+0000 (UTC)

Saved by @wnakswl #color #scss #mixin

@mixin color-weight ($class, $base-color, $weight: 4) {
  $bg-color: null;

  @for $i from 1 through 8 {
    @if $i < 4 {
      $weight: $weight - 1;
      $bg-color: lighten($base-color, $weight * 10%);
    } @else if $i == 4 {
      $weight: 0;
      $bg-color: $base-color;
    } @else {
      $weight: $weight + 1;
      $bg-color: darken($base-color, $weight * 10%);
    }

    .#{$class}-#{$i} { background-color: $bg-color; }
  }
}

@include color-weight(bg-blue, #1483ff);
@include color-weight(mad, red);
content_copyCOPY

https://stackoverflow.com/questions/43806105/sass-color-weight-mixin?rq