mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-04-16 21:35:13 +00:00
127 lines
4.3 KiB
SCSS
127 lines
4.3 KiB
SCSS
// Media step breakpoint mixin based on Angular Material lib
|
|
$breakpoints: (
|
|
xs: 'screen and (max-width: 599px)',
|
|
sm: 'screen and (min-width: 600px) and (max-width: 959px)',
|
|
md: 'screen and (min-width: 960px) and (max-width: 1279px)',
|
|
lg: 'screen and (min-width: 1280px) and (max-width: 1919px)',
|
|
xl: 'screen and (min-width: 1920px) and (max-width: 5000px)',
|
|
lt-sm: 'screen and (max-width: 599px)',
|
|
lt-md: 'screen and (max-width: 959px)',
|
|
lt-lg: 'screen and (max-width: 1279px)',
|
|
lt-xl: 'screen and (max-width: 1919px)',
|
|
gt-xs: 'screen and (min-width: 600px)',
|
|
gt-sm: 'screen and (min-width: 960px)',
|
|
gt-md: 'screen and (min-width: 1280px)',
|
|
gt-lg: 'screen and (min-width: 1920px)'
|
|
) !default;
|
|
|
|
$grid-breakpoints: (
|
|
xs: 0,
|
|
sm: 600px,
|
|
md: 960px,
|
|
lg: 1280px,
|
|
xl: 1920px
|
|
) !default;
|
|
|
|
@mixin media-breakpoint($breakpointName) {
|
|
|
|
$mediaQuery: map_get($breakpoints, $breakpointName);
|
|
|
|
@if ($mediaQuery != null) {
|
|
|
|
@media #{$mediaQuery} {
|
|
@content
|
|
}
|
|
}
|
|
}
|
|
|
|
// >> breakpoint-next(sm)
|
|
// md
|
|
// >> breakpoint-next(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
|
|
// md
|
|
// >> breakpoint-next(sm, $breakpoint-names: (xs sm md lg xl))
|
|
// md
|
|
@function breakpoint-next($name, $breakpoints: $grid-breakpoints, $breakpoint-names: map-keys($breakpoints)) {
|
|
$n: index($breakpoint-names, $name);
|
|
@return if($n < length($breakpoint-names), nth($breakpoint-names, $n + 1), null);
|
|
}
|
|
|
|
// Minimum breakpoint width. Null for the smallest (first) breakpoint.
|
|
//
|
|
// >> breakpoint-min(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
|
|
// 576px
|
|
@function breakpoint-min($name, $breakpoints: $grid-breakpoints) {
|
|
$min: map-get($breakpoints, $name);
|
|
@return if($min != 0, $min, null);
|
|
}
|
|
|
|
// Maximum breakpoint width. Null for the largest (last) breakpoint.
|
|
// The maximum value is calculated as the minimum of the next one less 0.1.
|
|
//
|
|
// >> breakpoint-max(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
|
|
// 767px
|
|
@function breakpoint-max($name, $breakpoints: $grid-breakpoints) {
|
|
$next: breakpoint-next($name, $breakpoints);
|
|
@return if($next, breakpoint-min($next, $breakpoints) - 1px, null);
|
|
}
|
|
|
|
// Returns a blank string if smallest breakpoint, otherwise returns the name with a dash infront.
|
|
// Useful for making responsive utilities.
|
|
//
|
|
// >> breakpoint-infix(xs, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
|
|
// "" (Returns a blank string)
|
|
// >> breakpoint-infix(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
|
|
// "-sm"
|
|
@function breakpoint-infix($name, $breakpoints: $grid-breakpoints) {
|
|
@return if(breakpoint-min($name, $breakpoints) == null, "", "-#{$name}");
|
|
}
|
|
|
|
// Media of at least the minimum breakpoint width. No query for the smallest breakpoint.
|
|
// Makes the @content apply to the given breakpoint and wider.
|
|
@mixin media-breakpoint-up($name, $breakpoints: $grid-breakpoints) {
|
|
$min: breakpoint-min($name, $breakpoints);
|
|
@if $min {
|
|
@media (min-width: $min) {
|
|
@content;
|
|
}
|
|
} @else {
|
|
@content;
|
|
}
|
|
}
|
|
|
|
// Media of at most the maximum breakpoint width. No query for the largest breakpoint.
|
|
// Makes the @content apply to the given breakpoint and narrower.
|
|
@mixin media-breakpoint-down($name, $breakpoints: $grid-breakpoints) {
|
|
$max: breakpoint-max($name, $breakpoints);
|
|
@if $max {
|
|
@media (max-width: $max) {
|
|
@content;
|
|
}
|
|
} @else {
|
|
@content;
|
|
}
|
|
}
|
|
|
|
// Media that spans multiple breakpoint widths.
|
|
// Makes the @content apply between the min and max breakpoints
|
|
@mixin media-breakpoint-between($lower, $upper, $breakpoints: $grid-breakpoints) {
|
|
$min: breakpoint-max($lower, $breakpoints);
|
|
$max: breakpoint-max($upper, $breakpoints);
|
|
|
|
@media (min-width: $min) and (max-width: $max) {
|
|
@content;
|
|
}
|
|
}
|
|
|
|
// Media between the breakpoint's minimum and maximum widths.
|
|
// No minimum for the smallest breakpoint, and no maximum for the largest one.
|
|
// Makes the @content apply only to the given breakpoint, not viewports any wider or narrower.
|
|
@mixin media-breakpoint-only($name, $breakpoints: $grid-breakpoints) {
|
|
$min: breakpoint-min($name, $breakpoints);
|
|
$max: breakpoint-max($name, $breakpoints);
|
|
|
|
@media (min-width: $min) and (max-width: $max) {
|
|
@content;
|
|
}
|
|
}
|