Created
April 24, 2019 13:59
-
-
Save jnschrag/39ccf5b7b2e6f7a22699b460e52e664a to your computer and use it in GitHub Desktop.
SASS Media Query Mixin
This file contains 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
// Breakpoints | |
// $break: Breakpoint to use | |
// $dir: 'min-width' or 'max-width' | |
// $until: Maximum width | |
// @include breakpoint('medium'); | |
// @include breakpoint($break: 'medium', $until: 'large'); | |
// @include breakpoint($break: 'medium', $dir: 'max-width'); | |
@mixin breakpoint($break, $dir: 'min-width', $until: null, $breakpoints-map: $breakpoints) { | |
@if not map-has-key($breakpoints-map, $break) { | |
$break: $break; | |
} @else { | |
$break: map-get($breakpoints-map, $break); | |
} | |
@if $break and $until { | |
@if not map-has-key($breakpoints-map, $until) { | |
$until: $until; | |
} @else { | |
$until: map-get($breakpoints-map, $until); | |
} | |
@media screen and (min-width: $break) and (max-width: $until) { | |
@content; | |
} | |
} @else { | |
@media screen and ($dir: $break) { | |
@content; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment