Answer the question
In order to leave comments, you need to log in
How to use reference to parent selector in mixin without compiling to cascade?
There is a mixin:
=notification-color($elem-class
@each $color-postfix in green, yellow, red
.#{$elem-class}_#{$color-postfix}
color: $color-postfix
.widget-content__icon
font-size: 3em
+notification-color(".widget-content__icon")
.widget-content__icon {
font-size: 3em; }
.widget-content__icon_green {
color: green; }
.widget-content__icon_yellow {
color: yellow; }
.widget-content__icon_red {
color: red; }
.widget-content__icon {
font-size: 3em; }
.widget-content__icon .widget-content__icon_green {
color: green; }
.widget-content__icon .widget-content__icon_yellow {
color: yellow; }
.widget-content__icon .widget-content__icon_red {
color: red; }
Answer the question
In order to leave comments, you need to log in
Use the @at-root directive in your mixin:
@mixin notification-color($elem-class) {
@each $color-postfix in green, yellow, red {
@at-root #{$elem-class}_#{$color-postfix} {
color: $color-postfix;
}
}
}
.widget-content__icon {
font-size: 3em;
@include notification-color(&);
}
.widget-content__icon {
font-size: 3em;
}
.widget-content__icon_green {
color: green;
}
.widget-content__icon_yellow {
color: yellow;
}
.widget-content__icon_red {
color: red;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question