Last active
August 29, 2015 14:25
-
-
Save lmartins/be61e48a9354e21171af to your computer and use it in GitHub Desktop.
Mixins for BEM style selectors.
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
// ---- | |
// libsass (v3.2.5) | |
// ---- | |
// BEM Mixins for SASS | |
// http://www.sitepoint.com/structuring-css-class-selectors-with-sass/ | |
@mixin new($block) { | |
@at-root .#{$block} { | |
@content; | |
} | |
} | |
@mixin is($element) { | |
.is-#{$element} & { | |
@content; | |
} | |
} | |
@mixin has($element) { | |
&__#{$element} { | |
@content; | |
} | |
} | |
@mixin when($modifier) { | |
&--#{$modifier} { | |
@content; | |
} | |
} | |
@mixin when-inside($selector) { | |
#{$selector} & { | |
@content; | |
} | |
} | |
.media { | |
border: 1px solid red; | |
@include has("image") { | |
border: 1px solid green; | |
@include when('full') { | |
content: "full"; | |
} | |
@include is('modifier') { | |
content: "modifier"; | |
} | |
} | |
@include when-inside('.page-header') { | |
content: "new" | |
} | |
@include when('new') { | |
content: "new" | |
} | |
} |
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
.media { | |
border: 1px solid red; | |
} | |
.media__image { | |
border: 1px solid green; | |
} | |
.media__image--full { | |
content: "full"; | |
} | |
.is-modifier .media__image { | |
content: "modifier"; | |
} | |
.page-header .media { | |
content: "new"; | |
} | |
.media--new { | |
content: "new"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment