Home › Forums › CSS › Simplify Sass include (uses sass maps) possible? › Reply To: Simplify Sass include (uses sass maps) possible?
January 20, 2016 at 1:43 am
#237011
Ilan Firsov
Participant
I tried my hand with it. Note that I am pretty new to SASS so maybe it’s not the best way to do this. In any case it seems to do the job.
@mixin respond-at($name) {
$index: index(map_keys($breakpoints), $name);
@if map-has-key($breakpoints, $name) {
@if $index == length($breakpoints) {
@media only screen and (min-width: map-get($breakpoints, $name)) {
@content;
}
} @else {
@media only screen and (min-width: map-get($breakpoints, $name)) and (max-width: nth(map_values($breakpoints), ( $index + 1 ))) {
@content;
}
}
}
}