Skip to content

Instantly share code, notes, and snippets.

@lukasborawski
Last active December 31, 2015 08:49
Show Gist options
  • Save lukasborawski/7962838 to your computer and use it in GitHub Desktop.
Save lukasborawski/7962838 to your computer and use it in GitHub Desktop.
SCSS multiclass BEM model @mixin.
<div class="bg_white-black"></div>
@mixin el($name) {
@at-root #{&}[class*="_#{$name}"] {
@content;
}
}
@mixin md($name) {
@at-root #{&}[class*="-#{$name}"] {
@content;
}
}
$model: bg;
[class*="#{$model}"] {
border: gray 1px solid;
@mixin colors() {
@include md(black){
color: black;
}
}
@at-root {
@include el(white) {
background-color: white;
@include colors;
}
@include el(lightgray) {
background-color: lightgray;
}
}
}
[class*="bg"] {
border: gray 1px solid;
}
[class*="bg"][class*="_white"] {
background-color: white;
}
[class*="bg"][class*="_white"][class*="-black"] {
color: black;
}
[class*="bg"][class*="_lightgray"] {
background-color: lightgray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment