Last active
December 4, 2017 17:22
-
-
Save joe-bell/c5ef9f006ee2fd445467af30118c8795 to your computer and use it in GitHub Desktop.
Conditional Modifiers
This file contains hidden or 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
/** | |
* Conditional Modifiers | |
* | |
* For example, here's a basic component with a "spaced" modifier: | |
* | |
* <div class="foo foo--spaced"> | |
* <p class="foo__child"> | |
* Hello | |
* </p> | |
* <p class="foo__child"> | |
* I'm Spaced | |
* </p> | |
* </div> | |
* | |
* +----------+---------------+ | |
* |Hello |I'm spaced | | |
* +----------+---------------+ | |
* | |
* When we apply an extra "reversed" modifer, we want to flip the spacing, but | |
* we obviously don't want to apply this to all of our "foo" components right? | |
* | |
* TL;DR: Only if it's spaced *and* reversed: | |
* | |
* +----------+---------------+ | |
* | Hello| I'm spaced| | |
* +----------+---------------+ | |
*/ | |
.foo--spaced { | |
> .foo__child { | |
padding-left: 20px; | |
/* .foo--reverse.foo--spaced > .foo__child { … } */ | |
@at-root .foo--reverse#{&} { | |
padding-left: 0; | |
padding-right: 20px; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment