Created
August 30, 2022 11:34
-
-
Save michael-letcher/03312120a6dc53ea68ba3bd24fd132b2 to your computer and use it in GitHub Desktop.
Breakpoint SCSS Module
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
$breakpoints: ( | |
'xs': 599px, | |
'sm': 768px, | |
'md': 904px, | |
'lg': 1239px, | |
) !default; | |
/// Mixin to manage responsive breakpoints | |
/// @author Kitty Giraudel | |
/// @param {String} $breakpoint - Breakpoint name | |
/// @require $breakpoints | |
@mixin break($breakpoint) { | |
// If the key exists in the map | |
@if map-has-key($breakpoints, $breakpoint) { | |
// Prints a media query based on the value | |
@media (min-width: map-get($breakpoints, $breakpoint)) { | |
@content; | |
} | |
} | |
// If the key doesn't exist in the map | |
@else { | |
@warn "No value could be retrieved from `#{$breakpoint}`. " | |
+ "Available breakpoints are: #{map-keys($breakpoints)}."; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment