Created
January 6, 2018 01:59
-
-
Save johnsylvain/47a54f3a9790ee532e0d8554539025a7 to your computer and use it in GitHub Desktop.
BEM SCSS Mixin
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
/// Block Element | |
/// @access public | |
/// @param {String} $element - Element's name | |
@mixin element($element) { | |
&__#{$element} { | |
@content; | |
} | |
} | |
/// Block Modifier | |
/// @access public | |
/// @param {String} $modifier - Modifier's name | |
@mixin modifier($modifier) { | |
&--#{$modifier} { | |
@content; | |
} | |
} | |
/// @alias element | |
@mixin e($element) { | |
@include element($element) { | |
@content; | |
} | |
} | |
/// @alias modifier | |
@mixin m($modifier) { | |
@include modifier($modifier) { | |
@content; | |
} | |
} |
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
@import 'bem'; | |
.button { | |
background-color: $bada55; | |
@include e('text') { | |
color: white; | |
font-weight: bold; | |
} | |
@include m('red') { | |
background-color: red; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment