]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Start putting together CSS-grid docs page to give us testbed for finishing out protot...
authorKevin Ball <kmball11@gmail.com>
Thu, 20 Apr 2017 18:55:47 +0000 (11:55 -0700)
committerKevin Ball <kmball11@gmail.com>
Thu, 20 Apr 2017 18:55:47 +0000 (11:55 -0700)
_vendor/normalize-scss/sass/normalize/_normalize-mixin.scss
docs/assets/scss/examples/_grid.scss
docs/pages/css-grid.md [new file with mode: 0644]
docs/partials/component-list.html
scss/foundation.scss

index edfd399a2a27b6a9fbe91c0cd9af11d5b2f97b5f..70a8d3d371e7fa432b243941e0a7fd88e44ddda6 100644 (file)
     optgroup,
     select,
     textarea {
-      font-family: inherit; /* 1 */
+      font-family: $base-font-family; /* 1 */
       font-size: 100%; /* 1 */
       @if $normalize-vertical-rhythm {
         line-height: ($base-line-height / $base-font-size) * 1em; /* 1 */
index 01bf80394ee1b5ce60f67b0682638162c99b3e9a..40f69e9f4abb260e1a303d29cbb351114f19a564 100644 (file)
 // Flex Grid
 [id^="docs-flex"].docs-component .docs-code-live {
   @include foundation-flex-grid;
+}
+// CSS Grid
+[id^="docs-css"].docs-component .docs-code-live {
+  @include foundation-css-grid;
+}
 
+[id^="docs-flex"].docs-component .docs-code-live,
+[id^="docs-css"].docs-component .docs-code-live {
   .row {
     background: #f9f9f9;
     font-size: 11px;
diff --git a/docs/pages/css-grid.md b/docs/pages/css-grid.md
new file mode 100644 (file)
index 0000000..15f9abc
--- /dev/null
@@ -0,0 +1,331 @@
+---
+title: CSS-Grid Layout Grid
+description: New in Foundation 6.4 is a CSS-grid layout powered grid, which you can use instead of the float and flex based grids.
+sass: scss/grid/_css-grid.scss
+---
+
+The CSS Grid Layout based grid is intended to give an "easy onboarding" way to begin experimenting with CSS Grid Layout. CSS Grid Layout provides advanced grid tooling beyond the original capabilities of the Foundation grid, but they can be a lot to get your head around. To provide a gentler onboarding, we've recreated the Foundation Grid using CSS Grid Layout so you can use your existing skills and sites to begin experimentation.
+
+---
+
+## Browser support
+
+CSS Grid Layout is only supported in Chrome, Firefox, Safari 10.1+, IE11+, and iOS 10.3+. As of release time it is not supported in any non-chrome android browsers. ([View css grid browser support.](http://caniuse.com/#feat=css-grid)) We recommend only using CSS Grid at this time for experimental or internal projects where browser support is not a concern.
+
+---
+
+## Importing
+
+If you're using the CSS version of Foundation, you can generate a <a href="https://foundation.zurb.com/sites/download">custom download of Foundation</a> with css grid mode enabled.
+
+If you're using the Sass version of Foundation, you can enable a framework-wide css-grid mode, which will enable the css-grid based mode for the grid, as well as flexbox mode for other components. [Learn more about enabling flexbox mode.](flexbox.html#enabling-flexbox-mode)
+
+```scss
+@import 'foundation';
+
+// @include foundation-grid;
+@include foundation-flex-classes;
+@include foundation-css-grid;
+```
+
+<div class="primary callout">
+  <p>The flex grid uses the same settings variables as the float grid to adjust gutter size, column count, and so on. Refer to the <a href="grid.html#sass-variables">Sass variable reference</a> for the default grid to see how the flex grid can be customized.</p>
+</div>
+
+<div class="warning callout">
+  <p>The standard grid and flex grid use some of the same classes, namely <code>.row</code> and <code>.column</code>, and don't play nice together. If you want to use both in the same project, we recommend using the Sass mixins for each grid, instead of the default CSS.</p>
+</div>
+
+---
+
+## Basics
+
+The structure of the flex grid is identical to that of the float grid. Rows use the class `.row`, and columns use the class `.column` (or `.columns`). Basic percentage-based sizing can also be done using the same grid classes you're used to: `.small-6`, `.medium-12`, and so on.
+
+```html_example
+<div class="row">
+  <div class="small-6 columns">6 columns</div>
+  <div class="small-6 columns">6 columns</div>
+</div>
+<div class="row">
+  <div class="medium-6 large-4 columns">12/6/4 columns</div>
+  <div class="medium-6 large-8 columns">12/6/8 columns</div>
+</div>
+```
+
+---
+
+## Advanced Sizing
+
+If no sizing class is added to the column, it will simply expand to fill the leftover space. We call this an *expand behavior*.
+
+```html_example
+<div class="row">
+  <div class="small-4 columns">4 columns</div>
+  <div class="columns">Whatever's left!</div>
+</div>
+```
+
+---
+
+Multiple expanding columns will share the leftover space equally.
+
+```html_example
+<div class="row">
+  <div class="small-4 columns">4 columns</div>
+  <div class="columns">Whatever's left!</div>
+  <div class="columns">Whatever's left!</div>
+</div>
+```
+
+---
+
+A column can also be made to *shrink*, by adding the `.shrink` class. This means it will only take up the horizontal space its contents need.
+
+```html_example
+<div class="row">
+  <div class="shrink columns">Shrink!</div>
+  <div class="columns">Expand!</div>
+</div>
+```
+
+---
+
+## Responsive Adjustments
+
+Columns in a flex grid will not wrap if not given an explicit size&mdash;this is what allows the magical auto-sizing to work. To make columns stack on smaller screens, add the class `.small-12` manually.
+
+To switch back to the expand behavior from a percentage or shrink behavior, use the classes `.medium-expand` or `.large-expand`. In the below example, the columns stack on small screens, and become even-width on large screens.
+
+```html_example
+<div class="row">
+  <div class="small-12 large-expand columns">One</div>
+  <div class="small-12 large-expand columns">Two</div>
+  <div class="small-12 large-expand columns">Three</div>
+  <div class="small-12 large-expand columns">Four</div>
+  <div class="small-12 large-expand columns">Five</div>
+  <div class="small-12 large-expand columns">Six</div>
+</div>
+```
+
+---
+
+### Automatic Stacking
+
+We have a few shorthand classes for the above behavior. Use the `.[size]-unstack` classes to stack all columns in the row by default, and then unstack them on a larger screen size, making each one equal-width.
+
+```html_example
+<div class="row medium-unstack">
+  <div class="columns">One</div>
+  <div class="columns">Two</div>
+  <div class="columns">Three</div>
+  <div class="columns">Four</div>
+  <div class="columns">Five</div>
+  <div class="columns">Six</div>
+</div>
+```
+
+---
+
+## Column Alignment
+
+Columns in a flex grid can be aligned across the horizontal or vertical axis of their parent row.
+
+### Horizontal Alignment
+
+Columns can be aligned the same way you would align text in a paragraph. By default, all columns align to the left (or the right in RTL), but this can be overridden with by adding the `.align-[dir]` class to the flex row.
+
+```html
+<div class="row">
+  <div class="column small-4">Aligned to</div>
+  <div class="column small-4">the left</div>
+</div>
+<div class="row align-right">
+  <div class="column small-4">Aligned to</div>
+  <div class="column small-4">the right</div>
+</div>
+<div class="row align-center">
+  <div class="column small-4">Aligned to</div>
+  <div class="column small-4">the middle</div>
+</div>
+<div class="row align-justify">
+  <div class="column small-4">Aligned to</div>
+  <div class="column small-4">the edges</div>
+</div>
+<div class="row align-spaced">
+  <div class="column small-4">Aligned to</div>
+  <div class="column small-4">the space around</div>
+</div>
+```
+
+<div class="docs-code-live">
+  <div class="text-center">
+    <div class="row">
+      <div class="column small-4">Aligned to</div>
+      <div class="column small-4">the left</div>
+    </div>
+    <div class="row align-right">
+      <div class="column small-4">Aligned to</div>
+      <div class="column small-4">the right</div>
+    </div>
+    <div class="row align-center">
+      <div class="column small-4">Aligned to</div>
+      <div class="column small-4">the middle</div>
+    </div>
+    <div class="row align-justify">
+      <div class="column small-4">Aligned to</div>
+      <div class="column small-4">the edges</div>
+    </div>
+    <div class="row align-spaced">
+      <div class="column small-4">Aligned to</div>
+      <div class="column small-4">the space around</div>
+    </div>
+  </div>
+</div>
+
+You might be wondering what the difference between `.align-justify` and `.align-spaced` is. A justified grid (`justify-content: space-between`) evenly distributes the space *between* each column. The first and last columns pin to the edge of the grid.
+
+A spaced grid (`justify-content: space-around`) evenly distributes the space *around* each column. This means there will always be space to the left of the first column, and to the right of the last column.
+
+The horizontal alignment classes are shorthands for the `justify-content` CSS property. [Learn more about `justify-content`](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content).
+
+---
+
+### Vertical Alignment
+
+By default, all columns in a flex grid stretch to be equal height. This behavior can be changed with another set of alignment classes. That's right, *middle alignment in CSS*!
+
+Your options for vertical alignment are `top`, `middle`, `bottom`, and `stretch`. Note that we use the word *middle* for vertical alignment, and *center* for horizontal alignment.
+
+Applying a vertical alignment class to the flex row will affect every column directly inside it.
+
+```html_example
+<div class="row align-middle">
+  <div class="columns">I'm in the middle!</div>
+  <div class="columns">I am as well, but I have so much text I take up more space! Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quis facere ducimus earum minus, inventore, ratione doloremque deserunt neque perspiciatis accusamus explicabo soluta, quod provident distinctio aliquam omnis? Labore, ullam possimus.</div>
+</div>
+```
+
+```html_example
+<div class="row align-top">
+  <div class="columns">These columns align to the top.</div>
+  <div class="columns">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatum, tempora. Impedit eius officia possimus laudantium? Molestiae eaque, sapiente atque doloremque placeat! In sint, fugiat saepe sunt dolore tempore amet cupiditate.</div>
+</div>
+```
+
+---
+
+Similar alignment classes can also be applied to individual columns, which use the format `.align-self-*` instead of `.align-*`.
+
+<div class="warning callout">
+  <p>In Foundation 6.2, we introduced the <code>.align-self-&ast;</code> classes, which replace the old method of using <code>.align-&ast;</code> classes on columns. The old classes will be removed completely in Foundation 6.3.</p>
+</div>
+
+```html_example
+<div class="row">
+  <div class="column align-self-bottom">Align bottom</div>
+  <div class="column align-self-middle">Align middle</div>
+  <div class="column align-self-top">Align top</div>
+  <div class="column">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Non harum laborum cum voluptate vel, eius adipisci similique dignissimos nobis at excepturi incidunt fugit molestiae quaerat, consequuntur porro temporibus. Nisi, ex?</div>
+</div>
+```
+
+---
+
+## Collapse/Uncollapse Rows
+
+The `.collapse` class lets you remove column gutters (padding).
+
+There are times when you won't want each media query to be collapsed or uncollapsed. In this case, use the media query size you want and collapse or uncollapse and add that to your row element. Example shows no gutter at small media size and then adds the gutter to columns at medium.
+
+The `.is-collapse-child` class removes negative margins from nested row under collapsed parent.
+
+```html
+<div class="row small-collapse medium-uncollapse">
+  <div class="small-6 columns">
+    Removes gutter at small media query and adds at medium.
+  </div>
+  <div class="small-6 columns">
+    Removes gutter at small media query and adds at medium.
+  </div>
+</div>
+```
+
+<p class="lead">Scale the browser down to a medium size to see the difference.</p>
+
+<div class="row medium-uncollapse large-collapse">
+  <div class="small-6 columns">
+    <div class="callout secondary">
+      <p class="show-for-small-only">On a small screen, I have gutters!</p>
+      <p class="show-for-medium-only">On a medium screen, I have gutters!</p>
+      <p class="show-for-large">On a large screen, I have no gutters!</p>
+    </div>
+  </div>
+  <div class="small-6 columns">
+    <div class="callout secondary">
+      <p class="show-for-small-only">On a small screen, I have gutters!</p>
+      <p class="show-for-medium-only">On a medium screen, I have gutters!</p>
+      <p class="show-for-large">On a large screen, I have no gutters!</p>
+    </div>
+  </div>
+</div>
+
+---
+
+## Offsets
+
+Offsets work identically to the float grid, by applying `margin-left` to a column.
+
+```html_example
+<div class="row">
+  <div class="small-4 large-offset-2 columns">Offset 2 on large</div>
+  <div class="small-4 columns">4 columns</div>
+</div>
+```
+
+---
+
+## Source Ordering
+
+Flexbox supports source ordering, making it easy to rearrange columns on different screen sizes without weird relative positioning tricks.
+
+The CSS property is easy enough to remember.
+
+```scss
+.element {
+  order: 1;
+}
+```
+
+Columns within a row will be sorted by their `order` property. Lower numbers are placed first. If multiple columns have the same number, they're sorted in the order they appear in the HTML.
+
+We have a set of classes that make it easy to setup source ordering in your HTML. They also come in responsive flavors, allowing you to reorder a grid on different screen sizes.
+
+```html_example
+<div class="row">
+  <div class="column small-order-2 medium-order-1">
+    This column will come second on small, and first on medium and larger.
+  </div>
+  <div class="column small-order-1 medium-order-2">
+    This column will come first on small, and second on medium and larger.
+  </div>
+</div>
+```
+
+---
+
+## 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.
+
+<div class="primary callout">
+  <p>A block grid row has the property <code>align-items: stretch</code> by default, meaning the columns in each row are equal height. To change this, change the <code>align-items</code> property of the row, or use one of the <a href="flexbox.html#vertical-alignment">vertical alignment flexbox classes</a>.</p>
+</div>
+
+```html_example
+<div class="row small-up-1 medium-up-2 large-up-3">
+  <div class="column">1 per row on small</div>
+  <div class="column">2 per row on medium</div>
+  <div class="column">3 per row on large</div>
+</div>
+```
index cc3e6afc62ce097e73aea6655a9464785cd8e564..0a20411060ac8bffde9a7155f02b374456891acb 100644 (file)
@@ -23,6 +23,7 @@
   <li class="docs-nav-title">General</li>
   <li{{#ifpage 'grid'}} class="current"{{/ifpage}}><a href="grid.html">Grid</a></li>
   <li{{#ifpage 'flex-grid'}} class="current"{{/ifpage}}><a href="flex-grid.html">Flex Grid</a></li>
+  <li{{#ifpage 'css-grid'}} class="current"{{/ifpage}}><a href="css-grid.html">CSS Grid Layout</a></li>
   <li{{#ifpage 'forms'}} class="current"{{/ifpage}}><a href="forms.html">Forms</a></li>
   <li{{#ifpage 'visibility'}} class="current"{{/ifpage}}><a href="visibility.html">Visibility Classes</a></li>
   <li{{#ifpage 'float-classes'}} class="current"{{/ifpage}}><a href="float-classes.html">Float Classes</a></li>
index 6b7a4b6a8833160c8ef09fd2d527933d4dd39cbc..9668ac5edce5afdb61b5fb546ec81a7bb088ebf4 100644 (file)
@@ -71,6 +71,7 @@
   } @else {
     @if $css-grid {
       $global-css-grid: true !global;
+      $global-flexbox: true !global;
     }
   }
 
   @include foundation-visibility-classes;
   @include foundation-float-classes;
 
-  @if $flex {
+  @if $global-flexbox {
     @include foundation-flex-classes;
   }
 }