From: Geoff Kimball Date: Tue, 19 Jan 2016 21:38:52 +0000 (-0800) Subject: Add block grid classes to the flex grid, closes #7924 X-Git-Tag: v6.2.0-rc.1~67 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1aae2bf5a6e954c71dcbc9fd3c60b93eb63cc396;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Add block grid classes to the flex grid, closes #7924 --- diff --git a/docs/pages/flex-grid.md b/docs/pages/flex-grid.md index 6bece974b..1971daac5 100644 --- a/docs/pages/flex-grid.md +++ b/docs/pages/flex-grid.md @@ -306,3 +306,21 @@ We have a set of classes that make it easy to setup source ordering in your HTML ``` + +--- + +## Block Grids + +To define column widths at the row-level, instead of the individual column level, add the class `.[size]-up-[n]` to a row, where `[n]` is the number of columns to display per row, and `[size]` is the breakpoint at which to apply the effect. + +
+

A block grid row has the property align-items: stretch by default, meaning the columns in each row are equal height. To change this, change the align-items property of the row, or use one of the vertical alignment flexbox classes.

+
+ +```html_example +
+
1 per row on small
+
2 per row on medium
+
3 per row on large
+
+``` diff --git a/scss/grid/_flex-grid.scss b/scss/grid/_flex-grid.scss index 87e87c84c..72cb74e50 100644 --- a/scss/grid/_flex-grid.scss +++ b/scss/grid/_flex-grid.scss @@ -94,6 +94,24 @@ } } +/// Creates a block grid for a flex grid row. +/// +/// @param {Number} $n - Number of columns to display on each row. +/// @param {String} $selector - Selector to use to target columns within the row. +@mixin flex-grid-layout( + $n, + $selector: '.column' +) { + flex-wrap: wrap; + + > #{$selector} { + $pct: percentage(1/$n); + + flex: 0 0 $pct; + max-width: $pct; + } +} + /// Changes the source order of a flex grid column. Columns with lower numbers appear first in the layout. /// @param {Number} $order [0] - Order number to apply. @mixin flex-grid-order($order: 0) { @@ -160,10 +178,17 @@ } } + // Source ordering @for $i from 1 through 6 { - // Source ordering - .#{$-zf-size}-order-#{$i} { - @include flex-order($i); + .#{$-zf-size}-up-#{$i} { + @include flex-grid-layout($i); + } + } + + // Block grid + @for $i from 1 through $block-grid-max { + .#{$-zf-size}-up-#{$i} { + @include grid-layout($i); } }