From 32a5651e9606203eb5f76b0493d49df53a6bcf55 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Fri, 16 Aug 2024 12:38:26 +0100 Subject: [PATCH] Chore: Remove `breakpoints` SCSS (#91883) remove breakpoints mixins --- public/sass/_angular.scss | 13 ++++ public/sass/_grafana.scss | 3 - public/sass/base/_grid.scss | 14 +++++ public/sass/mixins/_breakpoints.scss | 88 ---------------------------- 4 files changed, 27 insertions(+), 91 deletions(-) delete mode 100644 public/sass/mixins/_breakpoints.scss diff --git a/public/sass/_angular.scss b/public/sass/_angular.scss index fb061a83a7a..d6e75e4d31b 100644 --- a/public/sass/_angular.scss +++ b/public/sass/_angular.scss @@ -5,6 +5,19 @@ @use 'sass:color'; @use 'sass:list'; +// 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: if(map.get($breakpoints, $name) != 0, map.get($breakpoints, $name), null); + @if $min { + @media (min-width: $min) { + @content; + } + } @else { + @content; + } +} + // Gradients @mixin gradient-vertical($startColor: #555, $endColor: #333) { background-color: color.mix($startColor, $endColor, 60%); diff --git a/public/sass/_grafana.scss b/public/sass/_grafana.scss index f9eedb5bf43..127d6ead988 100644 --- a/public/sass/_grafana.scss +++ b/public/sass/_grafana.scss @@ -1,6 +1,3 @@ -// MIXINS -@import 'mixins/breakpoints'; - // BASE @import 'base/reboot'; @import 'base/forms'; diff --git a/public/sass/base/_grid.scss b/public/sass/base/_grid.scss index 481d04f799a..75deba50990 100644 --- a/public/sass/base/_grid.scss +++ b/public/sass/base/_grid.scss @@ -1,4 +1,18 @@ @use 'sass:math'; +@use 'sass:map'; + +// 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: if(map.get($breakpoints, $name) != 0, map.get($breakpoints, $name), null); + @if $min { + @media (min-width: $min) { + @content; + } + } @else { + @content; + } +} /// Grid system // diff --git a/public/sass/mixins/_breakpoints.scss b/public/sass/mixins/_breakpoints.scss deleted file mode 100644 index 1655be26647..00000000000 --- a/public/sass/mixins/_breakpoints.scss +++ /dev/null @@ -1,88 +0,0 @@ -@use 'sass:list'; -@use 'sass:map'; -// Breakpoint viewport sizes and media queries. -// -// Breakpoints are defined as a map of (name: minimum width), order from small to large: -// -// (xs: 0, sm: 544px, md: 768px) -// -// The map defined in the `$grid-breakpoints` global variable is used as the `$breakpoints` argument by default. - -// Name of the next breakpoint, or null for the last breakpoint. -// -// >> breakpoint-next(sm) -// md -// >> breakpoint-next(sm, (xs: 0, sm: 544px, md: 768px)) -// md -// >> breakpoint-next(sm, $breakpoint-names: (xs sm md)) -// md -@function breakpoint-next($name, $breakpoints: $grid-breakpoints, $breakpoint-names: map-keys($breakpoints)) { - $n: list.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: 544px, md: 768px)) -// 544px -@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: 544px, md: 768px)) -// 767px -@function breakpoint-max($name, $breakpoints: $grid-breakpoints) { - $next: breakpoint-next($name, $breakpoints); - @return if($next, breakpoint-min($next, $breakpoints) - 1px, null); -} - -// 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 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) { - @include media-breakpoint-up($name, $breakpoints) { - @include media-breakpoint-down($name, $breakpoints) { - @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) { - @include media-breakpoint-up($lower, $breakpoints) { - @include media-breakpoint-down($upper, $breakpoints) { - @content; - } - } -}