Last active
August 29, 2015 14:15
-
-
Save maggo/878d63414566c0769543 to your computer and use it in GitHub Desktop.
Mixin for centralized media query management in SCSS
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
/** | |
* Mediaquery collection, used to build responsive features. | |
*/ | |
$mediaqueries: | |
small "only screen", | |
medium "only screen and (min-width: 768px)", | |
large "only screen and (min-width: 1024px)" | |
!default; | |
@mixin media($query-id) { | |
$check: null; | |
@each $mediaquery in $mediaqueries { | |
@if nth($mediaquery, 1) == $query-id { | |
$check: $query-id; | |
@media #{nth($mediaquery, 2)} { | |
@content; | |
} | |
} | |
} | |
@if not $check { @warn "Mediaquery #{id} is not defined." } | |
} | |
/** | |
* Usage: | |
* @include media('small') { | |
* //breakpoint here | |
* } | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment