Created
September 18, 2021 00:45
-
-
Save Brlaney/b162b35eedb3155d28e0e0205dce5a65 to your computer and use it in GitHub Desktop.
scss/mixins/_width.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
$breakpoints: ( | |
xs: 600px, | |
sm: 800px, | |
md: 1000px, | |
lg: 1200px, | |
xl: 1500px, | |
); | |
@mixin respond-above-width($breakpoint) { | |
@if map-has-key($breakpoints, $breakpoint) { | |
$breakpoint-value: map-get($breakpoints, $breakpoint); | |
@media (min-width: $breakpoint-value) { | |
@content; | |
} | |
} @else { | |
@warn 'Invalid breakpoint: #{$breakpoint}.'; | |
} | |
} | |
@mixin respond-below-width($breakpoint) { | |
@if map-has-key($breakpoints, $breakpoint) { | |
$breakpoint-value: map-get($breakpoints, $breakpoint); | |
@media (max-width: ($breakpoint-value - 1)) { | |
@content; | |
} | |
} @else { | |
@warn 'Invalid breakpoint: #{$breakpoint}.'; | |
} | |
} | |
@mixin respond-between-width($lower, $upper) { | |
@if map-has-key($breakpoints, $lower) and map-has-key($breakpoints, $upper) { | |
$lower-breakpoint: map-get($breakpoints, $lower); | |
$upper-breakpoint: map-get($breakpoints, $upper); | |
@media (min-width: $lower-breakpoint) and (max-width: ($upper-breakpoint - 1)) { | |
@content; | |
} | |
} @else { | |
@if (map-has-key($breakpoints, $lower) ==false) { | |
@warn 'Your lower breakpoint was invalid: #{$lower}.'; | |
} | |
@if (map-has-key($breakpoints, $upper) ==false) { | |
@warn 'Your upper breakpoint was invalid: #{$upper}.'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment