Skip to content

Instantly share code, notes, and snippets.

@francosalcedo
Created January 12, 2020 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save francosalcedo/21a3f4167613aba63fed211cd80249d2 to your computer and use it in GitHub Desktop.
Save francosalcedo/21a3f4167613aba63fed211cd80249d2 to your computer and use it in GitHub Desktop.
Scss breakpoints mixins
// 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