Add extract-match mixin
Works similar to apply-match but exports the @__match variable to the parent scope instead of accepting a ruleset. I have a suspicion that this will generally be easier to wield and produce more predictable results than all the crazy extra scoping bullshit I always have to try and do when using the "closure"-ish approach I use with apply-match.
This commit is contained in:
parent
d7a0db958f
commit
dc73e0a578
2 changed files with 18 additions and 5 deletions
|
|
@ -14,3 +14,17 @@
|
|||
@ruleset();
|
||||
}
|
||||
}
|
||||
|
||||
.extract-match(@map; @search) {
|
||||
@current: extract(extract(@map, 1), 1);
|
||||
.extract-match(@map; @search; @current; 1);
|
||||
}
|
||||
|
||||
.extract-match(@map; @search; @current; @i) when not (@search = @current) and (@i <= length(@map)) {
|
||||
@current: extract(extract(@map, @i + 1), 1);
|
||||
.extract-match(@map; @search; @current; @i + 1);
|
||||
}
|
||||
|
||||
.extract-match(@map; @search; @current; @i) when (@search = @current) and (@i <= length(@map)) {
|
||||
@__match: extract(extract(@map, @i), 2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,11 +16,10 @@
|
|||
}
|
||||
|
||||
.screen(@screen, @ruleset) {
|
||||
.apply-match(@screens; @screen; {
|
||||
@media (min-width: @__match) {
|
||||
@ruleset();
|
||||
}
|
||||
});
|
||||
.extract-match(@screens; @screen);
|
||||
@media (min-width: @__match) {
|
||||
@ruleset();
|
||||
}
|
||||
}
|
||||
|
||||
.no-focus {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue