diff --git a/stylesheets/zen/_grids.scss b/stylesheets/zen/_grids.scss index 59a411b..82757ee 100644 --- a/stylesheets/zen/_grids.scss +++ b/stylesheets/zen/_grids.scss @@ -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 { @@ -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. @@ -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, @@ -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 { @@ -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".