Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Move Foundations grid styles to core

Henriette Darge2fcd7f89a147
diff --git a/frontend/src/global_styles/layout/_grid.sass b/frontend/src/global_styles/layout/_grid.sass
index 908fd418725..dbb0131d9fc 100644
--- a/frontend/src/global_styles/layout/_grid.sass
+++ b/frontend/src/global_styles/layout/_grid.sass
@@ -26,6 +26,310 @@
// See COPYRIGHT and LICENSE files for more details.
//++
+@use "sass:math"
+
+/*
+ THE GRID
+ --------
+
+ Foundation's magical, flexbox-powered grid.
+
+ Features:
+ - Horizontal or vertical grids
+ - Auto-sizing or percentage width grid blocks
+ - Independently-scrollable blocks
+ - Column alignment
+ - Source ordering
+ - Offsets
+
+
+/// @Foundation.settings
+// Grid
+$container-width: rem-calc(900) !default
+$block-padding: 1rem !default
+$total-columns: 12 !default
+$block-grid-max-size: 6 !default
+///
+
+/*
+ Define the size of a grid block. Blocks are flex items. By default, they stretch to fill all available space, based on the size of sibling blocks. This is the "expand" behavior.
+ If set to "shrink", the block will contract and only fill as much space as it needs for its content.
+ If set to a number, the block will be given a percentage width, based on the total number of columns (12 by default). Percentage widths don't work if a block is inside a vertical grid.
+
+ @group grid
+ @param {number|string} $size - Sizing behavior of the block. Should be expand, shrink, or a number.
+ @output The flex-basis, flex-grow, and flex-shrink properties.
+@mixin grid-size($size: expand)
+ @if (type-of($size) == 'number')
+ $pct: percentage(math.div($size, $total-columns))
+ flex: 0 0 $pct
+ // max-width prevents columns from wrapping early in IE10/11
+ max-width: $pct
+
+ @else if ($size == shrink)
+ flex: 0 0 auto
+
+ @else if ($size == expand)
+ flex: 1 1 auto
+
+
+/*
+ Set the orientation of blocks within this block. The grid is re-oriented by changing the flex direction of the block.
+
+ @group grid
+ @param {string} $orientation - Direction of the grid, either horizontal or vertical.
+ @output A flex-flow property to match the direction given.
+@mixin grid-orient($orientation: horizontal)
+ @if ($orientation == vertical)
+ flex-flow: column nowrap
+ align-items: stretch
+ @else
+ flex-flow: row wrap
+
+
+/*
+ Stretch a grid's child blocks across its cross-axis, making every column appear to have the same height.
+
+ @group grid
+ @param {bool} $stretch - Stretch blocks if true, or align blocks to top if false.
+ @output Sets align-items to "stretch" if $stretch is true, or "flex-start" (the default value) if false.
+@mixin grid-wrap($wrap: true)
+ @if $wrap
+ flex-wrap: wrap
+ align-items: flex-start
+ @else
+ flex-wrap: nowrap
+ align-items: stretch
+
+
+/*
+ Set the alignment of blocks within a grid.
+
+ left: Items align to the left.
+ right: Items align to the right.
+ center: Items align to the center.
+ justify: Items are spaced equally apart so they occupy the space of the entire grid.
+ spaced: Items are given equal space to their left and right.
+
+ @group grid
+ @param {string} $align - Alignment to use.
+ @output An appropriate justify-content value.
+@mixin grid-align($align: left)
+ $options: (left: flex-start, right: flex-end, center: center, justify: space-between, spaced: space-around)
+ justify-content: map-get($options, $align)
+
+
+/*
+ Set the source order of a block. Items with lower numbers appear first. If multiple items have the same number, the one in the HTML first will appear first.
+
+ @group grid
+ @param {number} $order - Position in source order.
+ @output An order property.
+@mixin grid-order($order: 0)
+ order: $order
+
+
+/*
+ Constrain the size of a block to the size of the average grid row, and center-align it. This imitates the behavior of ordinary Foundation rows.
+
+ @group grid
+ @param {bool} $container - Adds container styles if true.
+ @output A maximum width and the good old margin: 0 auto for center alignment.
+@mixin grid-container($width: $container-width, $align: center)
+ $margins: (left: 0 auto 0 0, right: 0 0 0 auto, center: 0 auto)
+ max-width: $width
+ margin: map-get($margins, $align)
+
+
+/*
+ Offset a block by adding a left margin.
+
+ @group grid
+ @param {number | bool} $offset - If false, nothing is output. If a number, offsets the column by the specified number of columns.
+ @output A left margin based on the number of columns specified, and the global number of columns.
+@mixin grid-offset($offset: false)
+ @if ($offset != false)
+ margin-left: percentage(math.div($offset, $total-columns))
+
+
+/*
+ Frames are containers that stretch to the full dimensions of the browser window.
+@mixin grid-frame($size: expand, $orientation: horizontal, $wrap: false, $align: left, $order: 0)
+ display: flex
+ height: 100vh
+ position: relative
+ overflow: hidden
+
+ @include grid-size($size)
+ @include grid-orient($orientation)
+ @include grid-wrap($wrap)
+ @include grid-align($align)
+ @include grid-order($order)
+
+
+/*
+ Groups are collections of content items. They're the "rows" of Foundation for Apps.
+@mixin grid-block($size: expand, $orientation: horizontal, $wrap: false, $align: left, $order: 0)
+ @include grid-frame($size, $orientation, $wrap, $align, $order)
+
+ // Reset the height used by frames
+ height: auto
+
+ // Blocks will scroll by default if their content overflows
+ @if ($orientation == vertical)
+ overflow-x: auto
+ @else
+ overflow-y: auto
+
+ // Add scrolling with inertia
+ -webkit-overflow-scrolling: touch
+ -ms-overflow-style: -ms-autohiding-scrollbar
+
+
+/*
+ Blocks are containers for actual content. They're the "columns" of Foundation for Apps.
+@mixin grid-content($size: expand, $offset: null, $order: null)
+ // Content blocks are not flex items and have padding
+ display: block
+ padding: 0 $block-padding
+
+ // Add scrolling with inertia
+ overflow-y: auto
+ -webkit-overflow-scrolling: touch
+ -ms-overflow-style: -ms-autohiding-scrollbar
+
+ @include grid-size($size)
+ @if $offset != null
+ @include grid-offset($offset)
+ @if $order != null
+ @include grid-order($order)
+
+
+@mixin grid-layout($up)
+ flex-flow: row wrap
+ overflow: visible
+ list-style-type: none
+
+ > li, > div, > section
+ padding: 0 1rem 1rem
+ flex: 0 0 percentage(math.div(1, $up))
+
+// CSS Output
+// - - - - - - - - - - - - - - - - - - - -
+
+// Shared styles for frames and blocks (parent elements)
+%block-core
+ // Change the direction children flow
+ &.vertical
+ @include grid-orient(vertical)
+ @each $size in $breakpoint-classes
+ @include breakpoint($size)
+ &.#{$size}-vertical
+ @include grid-orient(vertical)
+ &.#{$size}-horizontal
+ @include grid-orient(horizontal)
+
+ // Align the children of a grid block
+ &.align-right
+ @include grid-align(right)
+ &.align-center
+ @include grid-align(center)
+ &.align-justify
+ @include grid-align(justify)
+ &.align-spaced
+ @include grid-align(spaced)
+
+ // Allow child elements to wrap
+ &.wrap
+ @include grid-wrap(true)
+
+
+// Shared styles for blocks and content blocks (child elements)
+%child-core
+ // Shrink a flex item so it only takes up the space it needs
+ &.shrink
+ @include grid-size(shrink)
+
+ // Prevent an element from scrolling
+ &.noscroll
+ overflow: hidden
+
+// The core grid elements:
+// - Frame
+// - Block
+// - Content block
+// - Container
+.grid-block
+ @extend %block-core
+ @extend %child-core
+ @include grid-block
+
+ &_visible-overflow
+ &, .grid-content
+ overflow: visible
+
+.grid-content
+ @extend %child-core
+ @include grid-content
+
+ &.collapse
+ padding: 0
+
+ // Grids inside content blocks should wrap by default, so they mimic traditional float grids
+ .grid-block
+ margin-left: -($block-padding)
+ margin-right: -($block-padding)
+ flex-wrap: wrap
+ overflow: visible
+
+ // Reverse the above wrapping behavior
+ &.nowrap
+ @include grid-wrap(false)
+
+ .grid-content
+ overflow: visible
+
+.grid-container
+ @include grid-container
+
+ &.contain-left
+ @include grid-container($align: left)
+ &.contain-right
+ @include grid-container($align: right)
+
+// Sizing and ordering classes
+@for $i from 1 through $total-columns
+ // Source ordering
+ .order-#{$i}
+ @include grid-order($i)
+
+@each $size in $breakpoint-classes
+ @for $i from 1 through $total-columns
+ @include breakpoint($size)
+ // Block sizing
+ .#{$size}-#{$i}
+ @include grid-size($i)
+
+ // Source ordering
+ .#{$size}-order-#{$i}
+ @include grid-order($i)
+
+ // Offsets
+ .#{$size}-offset-#{$i}
+ @include grid-offset($i)
+
+ // Parent sizing (block grids)
+ .#{$size}-up-#{$i}
+ @include grid-layout($i)
+
+.grid-content .modal .grid-block
+ flex-wrap: nowrap
+
+
+
+
+// ----------------------------------------------------------------------------------------------------------
+
// Cancel Foundation overflow defaults (overflow: auto, overflow-y: auto)
@mixin grid-visible-overflow
overflow: visible
diff --git a/frontend/src/global_styles/vendor/foundation-apps/scss/components/_grid.scss b/frontend/src/global_styles/vendor/foundation-apps/scss/components/_grid.scss
deleted file mode 100644
index 90f2d1b4ee2..00000000000
--- a/frontend/src/global_styles/vendor/foundation-apps/scss/components/_grid.scss
+++ /dev/null
@@ -1,399 +0,0 @@
-@use "sass:math";
-/*
- THE GRID
- --------
-
- Foundation's magical, flexbox-powered grid.
-
- Features:
- - Horizontal or vertical grids
- - Auto-sizing or percentage width grid blocks
- - Independently-scrollable blocks
- - Column alignment
- - Source ordering
- - Offsets
-*/
-
-/// @Foundation.settings
-// Grid
-$container-width: rem-calc(900) !default;
-$block-padding: $global-padding !default;
-$total-columns: 12 !default;
-$block-grid-max-size: 6 !default;
-///
-
-/*
- Define the size of a grid block. Blocks are flex items. By default, they stretch to fill all available space, based on the size of sibling blocks. This is the "expand" behavior.
-
- If set to "shrink", the block will contract and only fill as much space as it needs for its content.
-
- If set to a number, the block will be given a percentage width, based on the total number of columns (12 by default). Percentage widths don't work if a block is inside a vertical grid.
-
- @group grid
-
- @param {number|string} $size - Sizing behavior of the block. Should be expand, shrink, or a number.
-
- @output The flex-basis, flex-grow, and flex-shrink properties.
-*/
-@mixin grid-size($size: expand) {
- @if (type-of($size) == 'number') {
- $pct: percentage(math.div($size, $total-columns));
- flex: 0 0 $pct;
- // max-width prevents columns from wrapping early in IE10/11
- max-width: $pct;
- }
- @else if ($size == shrink) {
- flex: 0 0 auto;
- }
- @else if ($size == expand) {
- flex: 1 1 auto;
- }
-}
-/*
- Set the orientation of blocks within this block. The grid is re-oriented by changing the flex direction of the block.
-
- @group grid
-
- @param {string} $orientation - Direction of the grid, either horizontal or vertical.
-
- @output A flex-flow property to match the direction given.
-*/
-@mixin grid-orient($orientation: horizontal) {
- @if ($orientation == vertical) {
- flex-flow: column nowrap;
- align-items: stretch;
- }
- @else {
- flex-flow: row wrap;
- }
-}
-/*
- Stretch a grid's child blocks across its cross-axis, making every column appear to have the same height.
-
- @group grid
-
- @param {bool} $stretch - Stretch blocks if true, or align blocks to top if false.
-
- @output Sets align-items to "stretch" if $stretch is true, or "flex-start" (the default value) if false.
-*/
-@mixin grid-wrap($wrap: true) {
- @if $wrap {
- flex-wrap: wrap;
- align-items: flex-start;
- }
- @else {
- flex-wrap: nowrap;
- align-items: stretch;
- }
-}
-/*
- Set the alignment of blocks within a grid.
-
- left: Items align to the left.
- right: Items align to the right.
- center: Items align to the center.
- justify: Items are spaced equally apart so they occupy the space of the entire grid.
- spaced: Items are given equal space to their left and right.
-
- @group grid
-
- @param {string} $align - Alignment to use.
-
- @output An appropriate justify-content value.
-*/
-@mixin grid-align($align: left) {
- $options: (
- left: flex-start,
- right: flex-end,
- center: center,
- justify: space-between,
- spaced: space-around,
- );
- justify-content: map-get($options, $align);
-}
-/*
- Set the source order of a block. Items with lower numbers appear first. If multiple items have the same number, the one in the HTML first will appear first.
-
- @group grid
-
- @param {number} $order - Position in source order.
-
- @output An order property.
-*/
-@mixin grid-order($order: 0) {
- order: $order;
-}
-/*
- Collapse a content block by removing the padding.
-
- @group grid
-
- @param {bool} $collapse - Collapses the block if true.
-
- @output A padding value.
-
- @todo No way to reverse collapse using this mixin. Solution:
- - If true, add padding: 0;
- - If false, add padding: 1rem;
- - If null, add nothing, to cut down on CSS output
- - Make null the default value
-*/
-@mixin grid-collapse($collapse: true) {
- @if ($collapse) {
- padding: 0;
- }
-}
-/*
- Constrain the size of a block to the size of the average grid row, and center-align it. This imitates the behavior of ordinary Foundation rows.
-
- @group grid
-
- @param {bool} $container - Adds container styles if true.
-
- @output A maximum width and the good old margin: 0 auto for center alignment.
-*/
-@mixin grid-container($width: $container-width, $align: center) {
- $margins: (
- left: 0 auto 0 0,
- right: 0 0 0 auto,
- center: 0 auto,
- );
- max-width: $width;
- margin: map-get($margins, $align);
-}
-/*
- Add negative margins to a block, equal to the padding of a content block. This aligns the edges of a block nested inside a content block.
-
- @group grid
-
- @param {bool} $nest - Adds negative margins if true.
-
- @output Negative margin values.
-*/
-@mixin grid-nest($nest: true) {
- @if ($nest) {
- margin-left: -1rem;
- margin-right: -1rem;
- }
-}
-/*
- Offset a block by adding a left margin.
-
- @group grid
-
- @param {number | bool} $offset - If false, nothing is output. If a number, offsets the column by the specified number of columns.
-
- @output A left margin based on the number of columns specified, and the global number of columns.
-*/
-@mixin grid-offset($offset: false) {
- @if ($offset != false) {
- margin-left: percentage(math.div($offset, $total-columns));
- }
-}
-
-/*
- Resets styles set by panels. Use this when a panel transforms into a block on larger screens.
-
- @group grid
-
- @output Resets to transform, position, and a few visual styles.
-*/
-@mixin grid-panel-reset() {
- transform: none;
- position: relative;
- width: auto;
- height: auto;
- z-index: auto;
- box-shadow: none;
- background: transparent;
- top: auto;
- right: auto;
- bottom: auto;
- left: auto;
-}
-
-/*
- Frames are containers that stretch to the full dimensions of the browser window.
-*/
-@mixin grid-frame($size: expand, $orientation: horizontal, $wrap: false, $align: left, $order: 0) {
- display: flex;
- height: 100vh;
- position: relative;
- overflow: hidden;
-
- @include grid-size($size);
- @include grid-orient($orientation);
- @include grid-wrap($wrap);
- @include grid-align($align);
- @include grid-order($order);
-}
-
-/*
- Groups are collections of content items. They're the "rows" of Foundation for Apps.
-*/
-@mixin grid-block($size: expand, $orientation: horizontal, $wrap: false, $align: left, $order: 0) {
- @include grid-frame($size, $orientation, $wrap, $align, $order);
-
- // Reset the height used by frames
- height: auto;
-
- // Blocks will scroll by default if their content overflows
- @if ($orientation == vertical) {
- overflow-x: auto;
- }
- @else {
- overflow-y: auto;
- }
-
- // Add scrolling with inertia
- -webkit-overflow-scrolling: touch;
- -ms-overflow-style: -ms-autohiding-scrollbar;
-}
-
-/*
- Blocks are containers for actual content. They're the "columns" of Foundation for Apps.
-*/
-@mixin grid-content($size: expand, $offset: null, $order: null) {
- // Content blocks are not flex items and have padding
- display: block;
- padding: 0 $block-padding;
-
- // Add scrolling with inertia
- overflow-y: auto;
- -webkit-overflow-scrolling: touch;
- -ms-overflow-style: -ms-autohiding-scrollbar;
-
- @include grid-size($size);
- @if $offset != null { @include grid-offset($offset); }
- @if $order != null { @include grid-order($order); }
-}
-
-@mixin grid-layout($up) {
- flex-flow: row wrap;
- overflow: visible;
- list-style-type: none;
-
- > li, > div, > section {
- padding: 0 1rem 1rem;
- flex: 0 0 percentage(math.div(1, $up));
- }
-}
-
-// CSS Output
-// - - - - - - - - - - - - - - - - - - - -
-
-// Shared styles for frames and blocks (parent elements)
-%block-core {
- // Change the direction children flow
- &.vertical { @include grid-orient(vertical); }
- @each $size in $breakpoint-classes {
- @include breakpoint($size) {
- &.#{$size}-vertical { @include grid-orient(vertical); }
- &.#{$size}-horizontal { @include grid-orient(horizontal); }
- }
- }
-
- // Align the children of a grid block
- &.align-right { @include grid-align(right); }
- &.align-center { @include grid-align(center); }
- &.align-justify { @include grid-align(justify); }
- &.align-spaced { @include grid-align(spaced); }
-
- // Allow child elements to wrap
- &.wrap { @include grid-wrap(true); }
-}
-
-// Shared styles for blocks and content blocks (child elements)
-%child-core {
- // Shrink a flex item so it only takes up the space it needs
- &.shrink { @include grid-size(shrink); }
-
- // Prevent an element from scrolling
- &.noscroll { overflow: hidden; }
-}
-
-@include exports(grid) {
- // The core grid elements:
- // - Frame
- // - Block
- // - Content block
- // - Container
- .grid-frame {
- @extend %block-core;
- @include grid-frame;
- }
- .grid-block {
- @extend %block-core;
- @extend %child-core;
- @include grid-block;
-
- &_visible-overflow {
- &, .grid-content {
- overflow: visible;
- }
- }
- }
- .grid-content {
- @extend %child-core;
- @include grid-content;
-
- &.collapse {
- padding: 0;
- }
-
- // Grids inside content blocks should wrap by default, so they mimic traditional float grids
- .grid-block {
- margin-left: -($block-padding);
- margin-right: -($block-padding);
- flex-wrap: wrap;
- overflow: visible;
-
- // Reverse the above wrapping behavior
- &.nowrap {
- @include grid-wrap(false);
- }
-
- .grid-content {
- overflow: visible;
- }
- }
- }
- .grid-container {
- @include grid-container;
-
- &.contain-left { @include grid-container($align: left); }
- &.contain-right { @include grid-container($align: right); }
- }
-
- // Sizing and ordering classes
- @for $i from 1 through $total-columns {
- // Source ordering
- .order-#{$i} { @include grid-order($i); }
- }
- @each $size in $breakpoint-classes {
- @for $i from 1 through $total-columns {
- @include breakpoint($size) {
- // Block sizing
- .#{$size}-#{$i} {
- @include grid-size($i);
- }
- // Source ordering
- .#{$size}-order-#{$i} {
- @include grid-order($i);
- }
- // Offsets
- .#{$size}-offset-#{$i} {
- @include grid-offset($i);
- }
- // Parent sizing (block grids)
- .#{$size}-up-#{$i} {
- @include grid-layout($i);
- }
- }
- }
- }
-
- .grid-content .modal .grid-block {
- flex-wrap: nowrap;
- }
-}
diff --git a/frontend/src/global_styles/vendor/foundation-apps/scss/foundation.scss b/frontend/src/global_styles/vendor/foundation-apps/scss/foundation.scss
index f11c5630be0..146eb6daebe 100755
--- a/frontend/src/global_styles/vendor/foundation-apps/scss/foundation.scss
+++ b/frontend/src/global_styles/vendor/foundation-apps/scss/foundation.scss
@@ -18,5 +18,4 @@ $foundation-version: '1.1.0';
@import "global";
// Components
-@import "components/forms",
-"components/grid";
+@import "components/forms";