Refactored callouts using maps, loops, placeholders, and mixins #314
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.
Hi! I wanted to combine your callouts with my own custom CSS. But I needed to understand how they worked, and I ended up refactoring a lot of them using some nifty SCSS features that help avoid repetition.
I only noticed Prettier was on after doing some work, and it killed your formatting. I tried to get your stylelinter to work, but it didn't seem in the mood.
Here it is anyway. Hope you'll find it useful!
And thank you so much for your work ❤️
Mixins
repeat-selector (mixin/function)
This is a mixin and a function. Both repeat a selector (usually
.callout
) N times so you don't have to copy it, and you can easily adjust the specificity.select-by-data-callout
This mixin selects using:
.callout
repeated N times using the previous mixindata-callout
attribute selectors using:is
.select-by-callout-metadata
This mixin selects using:
.callout
repeated N timesdata-callout-metadata
attribute selectors using:is
Sections
In most files I used the above mixins to make the code smaller or make it so the specificity is clear.
There are some files that I made larger changes to.
Coloring
I replaced the different coloring selectors using some lists and loops.
Kith
Replaced the kith type selectors with a map of type to color/icon.
Timeline
Replaced the
t-N
selectors with a map and a loop.Columns
More loops here
Callout styling
Used some placeholders and
@extends
together with the above mixins.Formatting
I use Prettier, and it killed your formatting before I knew what was happening.
Hi! I wanted to steal parts of your theme for my own, especially the callouts. But I needed to understand how they worked, and I ended up refactoring a lot of them using some nifty SCSS features that help avoid repetition.
Mixins
repeat-selector (mixin/function)
This is a mixin and a function. Both repeat a selector (usually
.callout
) N times so you don't have to copy it, and you can easily adjust the specificity.select-by-data-callout
This mixin selects using:
.callout
repeated N times using the previous mixindata-callout
attribute selectors using:is
.select-by-callout-metadata
This mixin selects using:
.callout
repeated N timesdata-callout-metadata
attribute selectors using:is
Sections
In most files I used the above mixins to make the code smaller or make it so the specificity is clear.
There are some files that I made larger changes to.
Coloring
I replaced the different coloring selectors using some lists and loops.
Kith
Replaced the kith type selectors with a map of type to color/icon.
Timeline
Replaced the
t-N
selectors with a map and a loop.Columns
More loops here
Callout styling
Used some placeholders and
@extends
together with the above mixins.