3

With this HTML code:

<div class="pie-wrapper pie-wrapper--solid progress" style="--percent: 50; --color: red;"></div>

I wan't to use var(--percent) value as @mixin @include call in a scss file:

@mixin draw-progress--solid($progress, $color) {
    background: linear-gradient(to right, $bg-color 50%, $color 50%);

    &:before {
        @if $progress <= 50 {
            background: $bg-color;
            transform: rotate((100 - (50 - $progress)) / 100 * 360deg * -1);
        } @else {
            background: $color;
            transform: rotate((100 - $progress) / 100 * 360deg);
        }
    }
}

.progress {
    @include draw-progress--solid(#{var(--percent)}, #8e44ad);
}

Tested and not working:

@include draw-progress--solid(#{var(--percent)}, #8e44ad);
@include draw-progress--solid(var(--percent), #8e44ad);

Thanks :)

Lito
  • 1,262
  • 2
  • 17
  • 25

0 Answers0