Increase color saturation with sassimin

I am trying to write a looped mixin that iteratively increases the saturation of a background color. Here is the final mixin code:

@mixin generateBackgroundSteps($cell-count, $color) {
    @for $i from 0 through $cell-count - 1 {
        $percent: (5 * $i) + "%";
        $new-color: saturate($color, $percent);

        &[setting-id="#{$i}"] {
            background-color: $new-color;                
        }
    }
}

      

Regardless of how I changed it, the generated css just looks like this:

.rubric-design .rubric .create-new-criteria .create-criteria-initial-
settings .create-criteria-setting[setting-id="2"] {
      background-color: saturate(#90afc8);
}

      

Perhaps this is how I generate $ interest. It must be something obvious!

+3


source to share


1 answer


Try using the function percentage

.

percentage function in SCSS



$percent: percentage((5 * $i) / (5 * $cell-count));

@mixin generateBackgroundSteps($cell-count, $color) {
@for $i from 0 through $cell-count - 1 {
    $percent: percentage((5 * $i) / (5 *$cell-count));
    $new-color: saturate($color, $percent);

    &[setting-id="#{$i}"] {
        background-color: $new-color;                
    }
 }
}

      

+3


source







All Articles