Last active
June 10, 2021 19:43
-
-
Save napotopia/c66dd0d30f6ba740c14e52470b33bcc4 to your computer and use it in GitHub Desktop.
Add a wrapping class with the desired level of specificity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin class-wrapper($wrapper, $specificity: 10) { | |
@if ($wrapper == null) { | |
@warn "$wrapper value is required."; | |
} | |
$iterator: $specificity / 10; | |
$selector: null; | |
@for $i from 0 to $iterator { | |
$selector: $selector + $wrapper; | |
} | |
#{$selector} { | |
@content; | |
} | |
} | |
@mixin prism-sandbox-wrapper() { | |
@include class-wrapper('.prism-sandbox', 20) { | |
@content; | |
}; | |
} | |
// Example | |
@include prism-sandbox-wrapper { | |
.btn { | |
background-color: gold; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.prism-sandbox.prism-sandbox .btn { | |
background-color: gold; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"sass": { | |
"compiler": "dart-sass/1.32.12", | |
"extensions": {}, | |
"syntax": "SCSS", | |
"outputStyle": "expanded" | |
}, | |
"autoprefixer": false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment