]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Add class to ease padding containers below max-width
authorKevin Ball <kmball11@gmail.com>
Mon, 26 Jun 2017 20:15:12 +0000 (13:15 -0700)
committerKevin Ball <kmball11@gmail.com>
Mon, 26 Jun 2017 20:15:12 +0000 (13:15 -0700)
docs/pages/xy-grid.md
scss/xy-grid/_classes.scss
scss/xy-grid/_grid.scss
scss/xy-grid/_xy-grid.scss
test/visual/xy-grid/containers.html [new file with mode: 0644]

index 977c68de2eb592548dd756db22ea2238e5569b0f..c903fbda493eb3e1362ab9eb3251fdcdd32fbfb0 100644 (file)
@@ -102,6 +102,21 @@ The grid defaults to the full width of its container. In order to contain the gr
   </div>
 </div>
 ```
+
+By default, the container will be centered and have a max-width equal to your
+`$max-width` setting (1200px by default), and be flush to the screen for widths
+below that. If you want to add padding below the `$max-width`, simply add the
+`.grid-container-padded` class to your grid container.
+
+```html
+<div class="grid-container grid-container-padded">
+  <div class="grid-x">
+    <div class="cell small-4">cell</div>
+    <div class="cell small-4">cell</div>
+    <div class="cell small-4">cell</div>
+  </div>
+</div>
+```
 ---
 
 ## Auto Sizing
index b4d3e115f7da0de27bf8ce3255025bee8b1d259c..f31b75a05f3fe88967a7bb48333ecc6a55261d83 100644 (file)
     @include xy-grid-container;
   }
 
+  .grid-container-padded {
+    @include xy-grid-container-padding;
+  }
+
   // Base grid styles
   .grid-x {
     @include xy-grid;
index 45eff29b3e3dc7e64162f6dd330cea1fc639fc49..33020ff91adf5381939eb787e3aa733761bf4cdf 100644 (file)
   margin: 0 auto;
 }
 
+/// Add padding to your container, up to a particular size
+///
+/// @param {Number} $width [$grid-container] - a width to limit the container to.
+@mixin xy-grid-container-padding(
+  $padding: $grid-container-padding,
+  $max: $grid-container-max
+) {
+  // Output our margin gutters.
+  @if (type-of($padding) == 'map') {
+    @include -zf-breakpoint-value(auto, $padding) {
+      padding-left: rem-calc($-zf-bp-value / 2);
+      padding-right: rem-calc($-zf-bp-value / 2);
+    }
+  }
+  @elseif (type-of($padding) == 'number') {
+    padding-left: rem-calc($padding) / 2;
+    padding-right: rem-calc($padding) / 2;
+  }
+  @include breakpoint($max) {
+    padding-left: 0;
+    padding-right: 0;
+  }
+}
+
 /// Creates a container for your flex cells.
 ///
 /// @param {Keyword} $direction [horizontal] - Either horizontal or vertical direction of cells within.
index 5bce738755e06a62d701d208772ccb038e29580e..0dda0833e6b31f27feb879538658b7b771cd6092 100644 (file)
@@ -29,6 +29,9 @@ $grid-margin-gutters: (
 /// @type Map | Length
 $grid-padding-gutters: $grid-margin-gutters !default;
 
+$grid-container-padding: $grid-padding-gutters !default;
+$grid-container-max: $global-width !default;
+
 /// The maximum number of cells in a block grid.
 /// @type Number
 $block-grid-max: 8 !default;
diff --git a/test/visual/xy-grid/containers.html b/test/visual/xy-grid/containers.html
new file mode 100644 (file)
index 0000000..1e6846a
--- /dev/null
@@ -0,0 +1,51 @@
+<!doctype html>
+<!--[if IE 9]><html class="lt-ie10" lang="en" > <![endif]-->
+<html class="no-js" lang="en" dir="ltr">
+  <head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
+    <title>xy margin grid</title>
+    <link href="../assets/css/foundation.css" rel="stylesheet" />
+    <style>
+      .demo {
+        background: #1779ba;
+      }
+
+      .cell {
+        /*background: dodgerblue;*/
+        line-height: 50px;
+        height: 50px;
+        color: white;
+        text-align: center;
+        margin-bottom: 30px;
+      }
+    </style>
+  </head>
+  <body>
+    <h1>Grid Container</h1>
+
+    <h2>With no `grid-container-padding` should be flush below 1200px, and bounded and centered above</h2>
+
+    <div class="grid-container">
+      <div class="grid-x grid-margin-x">
+        <div class="cell medium-12"><div class="demo">12/12</div></div>
+      </div>
+    </div>
+
+    <h2>With `grid-container-padded` should have padding below 1200px, corresponding to responsive gutters</h2>
+
+    <div class="grid-container grid-container-padded">
+      <div class="grid-x grid-margin-x">
+        <div class="cell medium-12"><div class="demo">12/12</div></div>
+      </div>
+    </div>
+
+
+    <script src="../assets/js/vendor.js"></script>
+    <script src="../assets/js/foundation.js"></script>
+    <script>
+      $(document).foundation();
+    </script>
+  </body>
+</html>