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

Expand use and function of zen-grid-item-width() #21

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
49 changes: 20 additions & 29 deletions stylesheets/zen/_grids.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ $zen-reverse-all-floats: false !default;
$reverse-all-floats: $zen-reverse-all-floats,
$auto-include-item-base: $zen-auto-include-item-base
) {

// Calculate the unit width.
$unit-width: zen-unit-width($column-count, $grid-width);

// Determine the float direction and its reverse.
$dir: $float-direction;
@if $reverse-all-floats {
Expand All @@ -104,19 +100,10 @@ $zen-reverse-all-floats: false !default;
$rev: zen-direction-flip($dir);

float: $dir;
$width: $column-span * $unit-width;
@if $box-sizing == content-box {
@if not comparable($width, $gutter-width) {
$units-gutter: unit($gutter-width);
$units-grid: unit($grid-width);
@warn "The layout cannot be calculated correctly; when using box-sizing: content-box, the units of the gutter (#{$units-gutter} did not match the units of the grid width (#{$units-grid}).";
}
$width: $width - $gutter-width;
}
width: $width;
width: zen-grid-item-width($column-span, $column-position, $column-count, $gutter-width, $grid-width, $box-sizing);
margin: {
#{$dir}: ($column-position - 1) * $unit-width;
#{$rev}: (1 - $column-position - $column-span) * $unit-width;
#{$dir}: zen-grid-item-width(($column-position - 1), 1, $column-count, $gutter-width, $grid-width, border-box);
#{$rev}: - zen-grid-item-width(($column-position + $column-span - 1), 1, $column-count, $gutter-width, $grid-width, border-box);
}

// Auto-apply the unit base mixin.
Expand Down Expand Up @@ -218,6 +205,7 @@ $zen-reverse-all-floats: false !default;
//
@mixin zen-grid-flow-item (
$column-span,
$column-position,
$parent-column-count: false,
$alpha-gutter: false,
$omega-gutter: true,
Expand Down Expand Up @@ -261,16 +249,7 @@ $zen-reverse-all-floats: false !default;
}

// Calculate the item's width.
$width: zen-grid-item-width($column-span, $columns, $grid-width);
@if $box-sizing == content-box {
@if not comparable($width, $gutter-width) {
$units-gutter: unit($gutter-width);
$units-grid: unit($grid-width);
@warn "The layout cannot be calculated correctly; when using box-sizing: content-box, the units of the gutter (#{$units-gutter} did not match the units of the grid width (#{$units-grid}).";
}
$width: $width - $gutter-width;
}
width: $width;
$width: zen-grid-item-width($column-span, $column-position, $columns, $gutter-width, $grid-width, $box-sizing);

// Auto-apply the unit base mixin.
@if $auto-include-flow-item-base {
Expand Down Expand Up @@ -316,11 +295,23 @@ $zen-reverse-all-floats: false !default;

// Calculates the width of a grid item that spans the specified number of columns.
@function zen-grid-item-width (
$column-span,
$column-span: $zen-column-count,
$column-position: 1,
$column-count: $zen-column-count,
$grid-width: $zen-grid-width
$gutter-width: $zen-gutter-width,
$grid-width: $zen-grid-width,
$box-sizing: $zen-box-sizing
) {
@return $column-span * zen-unit-width($column-count, $grid-width);
$width: $column-span * zen-unit-width($column-count, $grid-width);
@if $box-sizing == content-box {
@if not comparable($width, $gutter-width) {
$units-gutter: unit($gutter-width);
$units-grid: unit($grid-width);
@warn "The layout cannot be calculated correctly; when using box-sizing: content-box, the units of the gutter (#{$units-gutter} did not match the units of the grid width (#{$units-grid}).";
}
$width: $width - $gutter-width;
}
@return $width;
}

// Returns the opposite direction, given "left" or "right".
Expand Down