Skip to content

Instantly share code, notes, and snippets.

@genesy
Last active August 29, 2015 13:57
Show Gist options
  • Save genesy/9740346 to your computer and use it in GitHub Desktop.
Save genesy/9740346 to your computer and use it in GitHub Desktop.
@mixin breakpoint
@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