Skip to content

A platform for community discussion. Free, open, simple.

DEV: Introduce new breakpoints (#31886)

David Taylora4b2b57db7fd
diff --git a/app/assets/stylesheets/common/foundation/mixins.scss b/app/assets/stylesheets/common/foundation/mixins.scss
index 8e59fd3f047..410a225de3b 100644
--- a/app/assets/stylesheets/common/foundation/mixins.scss
+++ b/app/assets/stylesheets/common/foundation/mixins.scss
@@ -8,6 +8,7 @@
@use "sass:color";
@use "sass:math";
@use "sass:string";
+@use "sass:map";
$breakpoints: (
mobile-small: 320px,
diff --git a/app/assets/stylesheets/lib/viewport.scss b/app/assets/stylesheets/lib/viewport.scss
new file mode 100644
index 00000000000..aea427a9457
--- /dev/null
+++ b/app/assets/stylesheets/lib/viewport.scss
@@ -0,0 +1,35 @@
+@use "sass:map";
+
+$breakpoints: (
+ sm: 40rem,
+ md: 48rem,
+ lg: 64rem,
+ xl: 80rem,
+ 2xl: 96rem,
+);
+
+@function _get-breakpoint($bp) {
+ @if not map.has-key($breakpoints, $bp) {
+ @error "Invalid breakpoint: #{$bp}";
+ }
+
+ @return map.get($breakpoints, $bp);
+}
+
+@mixin from($bp) {
+ @media (width >= #{_get-breakpoint($bp)}) {
+ @content;
+ }
+}
+
+@mixin until($bp) {
+ @media (width < #{_get-breakpoint($bp)}) {
+ @content;
+ }
+}
+
+@mixin between($from, $until) {
+ @media (#{_get-breakpoint($from)} <= width < #{_get-breakpoint($until)}) {
+ @content;
+ }
+}