Add support for sub-blocks in mixins#264
Merged
snoyberg merged 2 commits intoyesodweb:masterfrom May 22, 2022
SupercedeTech:css-sublocks
Merged
Add support for sub-blocks in mixins#264snoyberg merged 2 commits intoyesodweb:masterfrom SupercedeTech:css-sublocks
snoyberg merged 2 commits intoyesodweb:masterfrom
SupercedeTech:css-sublocks
Conversation
snoyberg
reviewed
Mar 20, 2022
This allows mixin blocks to themselves contain other blocks, which are then mixed in correctly in the parent block wherever the mixin is used. This allows for things like nesting subclasses in the mixin, and (in particular) nesting pseudoselectors! This is a use-case we had where we wanted to mixin `:hover`, but we couldn't because blocks weren't supported. Instead, we had to use multiple mixins everywhere, complicating our code. This makes a little change to how mixins are represented to track leading spaces - this is to support ampersand blocks in mixins. It's not a functional change for existing CSS.
This means that assertion errors from `celper` will display the line where it is called, not the line of `celper` that errored.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a TODO!
This has been a recent pain point for us, because we have a button mixin that basically wants to do this
But we can't, because of the lack of blocks in mixins. Instead, we're forced to have multiple mixins per call-site, which is nasty.