Created
January 12, 2020 07:00
-
-
Save francosalcedo/21a3f4167613aba63fed211cd80249d2 to your computer and use it in GitHub Desktop.
Scss breakpoints mixins
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
// Default max limits widths | |
$container-max-widths: ( | |
sm: 540px, | |
md: 720px, | |
lg: 960px, | |
xl: 1280px | |
) !default; | |
/* Breakpoints */ | |
@mixin breakpoint($point) { | |
@if $point == dad { | |
@media (max-width: map-get($container-max-widths, 'xl')) { @content; } | |
} | |
@else if $point == mom { | |
@media (max-width: map-get($container-max-widths, 'lg')) { @content; } | |
} | |
@else if $point == baby { | |
@media (max-width: map-get($container-max-widths, 'md')) { @content; } | |
} | |
@else if $point == minibaby { | |
@media (max-width: map-get($container-max-widths, 'sm')) { @content; } | |
} | |
} | |
@mixin reverse-breakpoint($point) { | |
@if $point == dad { | |
@media (min-width: map-get($container-max-widths, 'xl')) { @content; } | |
} | |
@else if $point == mom { | |
@media (min-width: map-get($container-max-widths, 'lg')) { @content; } | |
} | |
@else if $point == baby { | |
@media (min-width: map-get($container-max-widths, 'md')) { @content; } | |
} | |
@else if $point == minibaby { | |
@media (min-width: map-get($container-max-widths, 'sm')) { @content; } | |
} | |
} | |
// Alias | |
@mixin bp($args...) { | |
@include breakpoint($args...){ | |
@content; | |
} | |
} | |
@mixin rbp($args...) { | |
@include breakpoint($args...){ | |
@content; | |
} | |
} | |
// Usage | |
/* | |
@include rbp(dad){ | |
body { | |
background-color: blue !important; | |
} | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment