Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xy grid frame fix for margin grids #10448

Merged
merged 8 commits into from
Jul 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/pages/xy-grid.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,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 @@ -334,9 +334,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 @@ -384,7 +385,6 @@
}

@if $vertical-grid {

.grid-y {
&.grid-frame {
width: auto;
Expand All @@ -410,6 +410,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 @@ -460,6 +471,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