Skip to content

Commit

Permalink
Merge pull request #10448 from zurb/xy-grid-frame-fix
Browse files Browse the repository at this point in the history
Xy grid frame fix for margin grids
  • Loading branch information
brettsmason authored and kball committed Jul 25, 2017
1 parent 909cf94 commit a24cc43
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 12 deletions.
4 changes: 4 additions & 0 deletions docs/pages/xy-grid.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ You can also apply margin or padding with `.grid-margin-y` and `.grid-padding-y`
The XY grid incorporates the grid frame from Foundation for Apps plus many other useful features.
To start, add `.grid-frame` to the grid. This sets the grid to be 100vh (the full height of the browser window).

<div class="callout warning">
Please note to use `.grid-margin-x` or `.grid-margin-y` with `.grid-frame` you need to hide the overflow on the body like so: `body {overflow: hidden;}`.
</div>

Here's an example of what you can do:
<div class="docs-codepen-container">
<a class="codepen-logo-link" href="https://codepen.io/ZURBFoundation/pen/MogrXG?editors=1000" target="_blank"><img src="{{root}}assets/img/logos/edit-in-browser.svg" class="" height="" width="" alt="edit on codepen button"></a>
Expand Down
17 changes: 14 additions & 3 deletions scss/xy-grid/_classes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,10 @@
@if $margin-grid {
@include xy-margin-grid-classes(top bottom, true, '.grid-margin-y')
}

}

@mixin xy-frame-grid-classes($vertical-grid: true) {
@mixin xy-frame-grid-classes($vertical-grid: true, $margin-grid: true) {
// Framed grid styles
.grid-frame {
@include xy-grid-frame;
Expand Down Expand Up @@ -374,7 +375,6 @@
}

@if $vertical-grid {

.grid-y {
&.grid-frame {
width: auto;
Expand All @@ -400,6 +400,17 @@
}
}
}
@if $margin-grid {
@include xy-margin-grid-classes(top bottom, true, '.grid-margin-y')
.grid-frame.grid-margin-y {
@include xy-grid-frame(true, false, $grid-margin-gutters, $include-base: false)
}
@include -zf-each-breakpoint(false) {
.grid-margin-y.#{$-zf-size}-grid-frame {
@include xy-grid-frame(true, false, $grid-margin-gutters, $-zf-size, false)
}
}
}
}

// Final classes
Expand Down Expand Up @@ -450,6 +461,6 @@
}

@if ($frame-grid) {
@include xy-frame-grid-classes($vertical-grid)
@include xy-frame-grid-classes($vertical-grid, $margin-grid)
}
}
49 changes: 40 additions & 9 deletions scss/xy-grid/_frame.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,52 @@
///
/// @param {Boolean} $vertical [false] - Is grid vertical or horizontal. Should match grid.
/// @param {Boolean} $nested [false] - Is grid nested or not. If nested is true this sets the frame to 100% height, otherwise will be 100vh.
/// @param {Number|Map} $gutters [null] - Map or single value for gutters.
/// @param {String} $breakpoint [null] - The name of the breakpoint size in your gutters map to get the size from.
/// @param {Boolean} $include-base [true] - Include the base styles that don't vary per breakpoint.
@mixin xy-grid-frame(
$vertical: false,
$nested: false
$nested: false,
$gutters: null,
$breakpoint: null,
$include-base: true
) {

@if $vertical == true {
height: if($nested == true, 100%, 100vh);
} @else {
width: if($nested == true, 100%, 100vw);
@if $include-base {
overflow: hidden;
position: relative;
flex-wrap: nowrap;
align-items: stretch;
}

overflow: hidden;
position: relative;
flex-wrap: nowrap;
align-items: stretch;
@if $breakpoint == null and type-of($gutters) == 'map' {
@include -zf-each-breakpoint() {
@include xy-grid-frame($vertical, $nested, $gutters, $-zf-size, false);
}
} @else {
// Get our gutters if applicable
$gutter: -zf-get-bp-val($gutters, $breakpoint);

// If we have a gutter, add it to the width/height
@if $gutter {
@if $vertical == true {
$unit: if($nested == true, 100%, 100vh);
$gutter: rem-calc($gutter);
height: calc(#{$unit} + #{$gutter});
} @else {
$unit: if($nested == true, 100%, 100vw);
$gutter: rem-calc($gutter);
width: calc(#{$unit} + #{$gutter});
}
}
@else {
@if $vertical == true {
height: if($nested == true, 100%, 100vh);
} @else {
width: if($nested == true, 100%, 100vw);
}
}
}
}

/// Modifies a cell to give it "block" behavior (overflow auto, inertial scrolling)
Expand Down

0 comments on commit a24cc43

Please sign in to comment.