Last active
August 29, 2015 13:57
-
-
Save genesy/9740346 to your computer and use it in GitHub Desktop.
@mixin breakpoint
This file contains hidden or 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
@mixin breakpoint($size-or-width) { | |
$merged-breakpoints: null; | |
$max-width: null; | |
$default-breakpoints:( | |
XL: 2000px, | |
L: 1250px, | |
M: 950px, | |
S: 650px, | |
XS: 450px | |
); | |
@if global-variable-exists(breakpoints) { | |
$merged-breakpoints: map-merge($default-breakpoints, $breakpoints); | |
} | |
@else { | |
$merged-breakpoints: $default-breakpoints; | |
} | |
@if type-of($size-or-width) == number { | |
$max-width: $size-or-width; | |
} | |
@else { | |
@each $size, $width in $merged-breakpoints { | |
@if $size-or-width == $size { | |
$max-width: $width; | |
} | |
} | |
} | |
@media (max-width: $max-width) { | |
@content; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment