Skip to content

Instantly share code, notes, and snippets.

@michael-letcher
Created August 30, 2022 11:34
Show Gist options
  • Save michael-letcher/03312120a6dc53ea68ba3bd24fd132b2 to your computer and use it in GitHub Desktop.
Save michael-letcher/03312120a6dc53ea68ba3bd24fd132b2 to your computer and use it in GitHub Desktop.
Breakpoint SCSS Module
$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