Created
September 1, 2017 12:44
-
-
Save 7iomka/73f4728b8c04d687dac8530e6ad6ad84 to your computer and use it in GitHub Desktop.
Sass helper function to get the block in the current selector
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
@function b() { | |
$selector: str-slice(inspect(&), 2, -2); | |
@each $type in '__', '--' { | |
@if str-index($selector, $type) { | |
$selector: str-slice($selector, 0, str-index($selector, $type) - 1); | |
} | |
} | |
@return $selector; | |
} | |
.media { | |
border: 1px solid; | |
&__content { | |
font-size: 10px; | |
} | |
&--large { | |
#{b()}__content { | |
font-size: 20px; | |
} | |
} | |
} |
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
.media { | |
border: 1px solid; | |
} | |
.media__content { | |
font-size: 10px; | |
} | |
.media--large .media__content { | |
font-size: 20px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment