sass-site/source/_includes/code_snippets/example-if-parent-selector.liquid

27 lines
546 B
Plaintext
Raw Normal View History

2023-05-25 17:55:08 +02:00
{% codeExample 'if-parent-selector' %}
2023-05-30 23:23:34 +02:00
@mixin app-background($color) {
#{if(&, '&.app-background', '.app-background')} {
background-color: $color;
color: rgba(#fff, 0.75);
}
2023-05-16 13:26:56 +02:00
}
2023-05-30 23:23:34 +02:00
@include app-background(#036);
2023-05-16 13:26:56 +02:00
2023-05-30 23:23:34 +02:00
.sidebar {
@include app-background(#c6538c);
}
===
@mixin app-background($color)
#{if(&, '&.app-background', '.app-background')}
background-color: $color
color: rgba(#fff, 0.75)
2023-05-16 13:26:56 +02:00
2023-05-30 23:23:34 +02:00
@include app-background(#036)
2023-05-16 13:26:56 +02:00
2023-05-30 23:23:34 +02:00
.sidebar
@include app-background(#c6538c)
2023-05-16 13:26:56 +02:00
{% endcodeExample %}