Last active
December 20, 2015 01:19
-
-
Save dvessel/6048607 to your computer and use it in GitHub Desktop.
Ensure component modifiers have a set base. @extend in Sass can get out of hand. Manually setting both base and modifiers can trim down the compiled styles.
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
// Find modifer without base. | |
// .[base--]modifier - yes | |
// .[base-s]ubelement - no | |
// .foo-[base--]modifier - no | |
// .bar[base--]modifier - uhh.. Just name your classes correctly. | |
[class*="base--"]:not([class*="-base--"]) { | |
outline: 2px solid red; | |
} | |
// Base exists, cancel. | |
[class*="base--"]:not([class*="-base--"]).base { | |
outline: none; | |
} |
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
$debug-enable-modifier-has-base: false !default; | |
$debug-base-component-list: ( | |
'base' | |
); | |
$debug-enable-modifier-has-base: true; | |
@if ($debug-enable-modifier-has-base) { | |
@each $base in $debug-base-component-list { | |
[class*="#{$base}--"]:not([class*="-#{$base}--"]) { | |
outline: 2px solid red; | |
&.#{$base} { | |
outline: none; | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment