beyond-css-course-material/challenges/06-custom-props/_mixins.scss

24 lines
586 B
SCSS
Raw Permalink Normal View History

2023-01-03 22:28:17 +00:00
@use 'sass:map';
@use 'sass:math';
@use 'sass:meta';
@use 'breakpoints' as *;
@mixin mq($size) {
@if map.has-key($breakpoints, $size) {
$breakpoint: map-get($breakpoints, $size);
@media screen and (min-width: $breakpoint) {
@content;
}
} @else if meta.type-of($size) == number {
@if math.is-unitless($size) {
@error 'when using a number with @mq() make sure to include a unit';
} @else {
@media screen and (min-width: $size) {
@content;
}
}
} @else {
@error 'the keyword #{$size} is not in the $breakpoints map';
}
}