]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Replace concept of offset with explicit 'start' for CSS Grid feature/css-grid
authorKevin Ball <kmball11@gmail.com>
Sat, 22 Apr 2017 00:18:35 +0000 (17:18 -0700)
committerKevin Ball <kmball11@gmail.com>
Sat, 22 Apr 2017 00:18:35 +0000 (17:18 -0700)
docs/pages/css-grid.md
scss/grid/_css-grid.scss

index 15f9abc620f4ef2c0f66844c8373d9817c10da3f..6d596ed7e1f5b35b29b40f2e535d8a86d8a1b1c8 100644 (file)
@@ -55,182 +55,6 @@ The structure of the flex grid is identical to that of the float grid. Rows use
 
 ---
 
-## 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
 
@@ -272,48 +96,19 @@ The `.is-collapse-child` class removes negative margins from nested row under co
 
 ---
 
-## Offsets
+## Starts
 
-Offsets work identically to the float grid, by applying `margin-left` to a column.
+CSS Grid doesn't use the concept of an "offset" in the same way that the float and flex grids do, it is more explicit. You can specify exactly the row that you want things to start on.
 
 ```html_example
 <div class="row">
-  <div class="small-4 large-offset-2 columns">Offset 2 on large</div>
+  <div class="small-4 large-start-3 columns">Start in column 3 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.
index a247040e6b36d23c57070af913b2dc27d19ad59a..552dd6a31d86a2e380eb5be3d19d28f2550ca3f0 100644 (file)
   grid-column-end: $column-end;
 }
 
+@mixin css-grid-column-start($n) {
+  grid-column-start: $n;
+}
+
 @mixin foundation-css-grid {
   .row {
     @include css-grid-container;
     }
 
     // TODO:  Figure out stack/unstack
+
+    @for $i from 1 through $grid-column-count {
+      // Offsets
+      $o: $i - 1;
+
+      .#{$-zf-size}-start-#{$o} {
+        @include css-grid-column-start($o);
+      }
+    }
   }
 
   .columns {