diff --git a/scss/jeet/_grid.scss b/scss/jeet/_grid.scss index 5fa4786e..79257cb8 100644 --- a/scss/jeet/_grid.scss +++ b/scss/jeet/_grid.scss @@ -72,39 +72,19 @@ /** * Get the width of a column and nothing else. * @param {number} [$ratios=1] - A width relative to its container as a fraction. - * @param {number} [$g=$jeet-gutter] - Specify the gutter width as a percentage of the containers width. + * @param {number} [$gutter=$jeet-gutter] - Specify the gutter width as a percentage of the containers width. */ -@function column-width($ratios: 1, $g: $jeet-gutter) { - @if ($jeet-parent-first != 'true') { - $ratios: jeet-reverse($ratios); - } - - $w: 100; - - @each $ratio in $ratios { - $w: 100 * $ratio - $g + $ratio * $g; - } - - @return unquote($w + '%'); +@function column-width($ratios: 1, $gutter: $jeet-gutter) { + @return unquote(nth(jeet-get-column($ratios, $gutter), 1) + '%'); } /** * Get the gutter size of a column and nothing else. * @param {number} [ratios=1] - A width relative to its container as a fraction. - * @param {number} [g=jeet.gutter] - Specify the gutter width as a percentage of the containers width. + * @param {number} [gutter=jeet.gutter] - Specify the gutter width as a percentage of the containers width. */ -@function column-gutter($ratios: 1, $g: $jeet-gutter) { - @if ($jeet-parent-first != 'true') { - $ratios: jeet-reverse($ratios); - } - - $w: 100; - - @each $ratio in $ratios { - $g: $g / $w * 100; - } - - @return unquote($g + '%'); +@function column-gutter($ratios: 1, $gutter: $jeet-gutter) { + @return unquote(nth(jeet-get-column($ratios, $gutter), 2) + '%'); } /** diff --git a/stylus/jeet/_grid.styl b/stylus/jeet/_grid.styl index 09a2556f..b6edcadb 100644 --- a/stylus/jeet/_grid.styl +++ b/stylus/jeet/_grid.styl @@ -56,16 +56,10 @@ col = column /** * Get the width of a column and nothing else. * @param {number} [ratios=1] - A width relative to its container as a fraction. - * @param {number} [g=jeet.gutter] - Specify the gutter width as a percentage of the containers width. + * @param {number} [gutter=jeet.gutter] - Specify the gutter width as a percentage of the containers width. */ -column-width(ratios = 1, g = jeet.gutter) - ratios = jeet-reverse(ratios) unless jeet.parent-first is true - w = 100 - - for ratio in ratios - w = 100 * ratio - g + ratio * g - - return w + '%' +column-width(ratios = 1, gutter = jeet.gutter) + return jeet-get-column(ratios, gutter)[0] + '%' /** * An alias for the column-width function. @@ -75,16 +69,10 @@ cw = column-width /** * Get the gutter size of a column and nothing else. * @param {number} [ratios=1] - A width relative to its container as a fraction. - * @param {number} [g=jeet.gutter] - Specify the gutter width as a percentage of the containers width. + * @param {number} [gutter=jeet.gutter] - Specify the gutter width as a percentage of the containers width. */ -column-gutter(ratios = 1, g = jeet.gutter) - ratios = jeet-reverse(ratios) unless jeet.parent-first is true - w = 100 - - for ratio in ratios - g = g / w * 100 - - return g + '%' +column-gutter(ratios = 1, gutter = jeet.gutter) + return jeet-get-column(ratios, gutter)[1] + '%' /** * An alias for the column-gutter function. diff --git a/tests/functions/column-gutter/column-gutter.scss b/tests/functions/column-gutter/column-gutter.scss index b56a1754..2034e144 100644 --- a/tests/functions/column-gutter/column-gutter.scss +++ b/tests/functions/column-gutter/column-gutter.scss @@ -1,5 +1,5 @@ @import 'scss/jeet/index'; .test { - margin-right: column-gutter($ratios: 1/5, $g: 5); + margin-right: column-gutter($ratios: 1/5, $gutter: 5); } diff --git a/tests/functions/column-gutter/column-gutter.styl b/tests/functions/column-gutter/column-gutter.styl index 369cea6b..097934e9 100644 --- a/tests/functions/column-gutter/column-gutter.styl +++ b/tests/functions/column-gutter/column-gutter.styl @@ -1,4 +1,4 @@ @import 'stylus/jeet/index' .test - margin-right: column-gutter(ratios: 1/5, g: 5) + margin-right: column-gutter(ratios: 1/5, gutter: 5) diff --git a/tests/functions/column-width/column-width.scss b/tests/functions/column-width/column-width.scss index ce79b318..834b6cc4 100644 --- a/tests/functions/column-width/column-width.scss +++ b/tests/functions/column-width/column-width.scss @@ -1,5 +1,5 @@ @import 'scss/jeet/index'; .test { - margin-right: column-width($ratios: 1/5, $g: 5); + margin-right: column-width($ratios: 1/5, $gutter: 5); } diff --git a/tests/functions/column-width/column-width.styl b/tests/functions/column-width/column-width.styl index e992d203..6b5c0e35 100644 --- a/tests/functions/column-width/column-width.styl +++ b/tests/functions/column-width/column-width.styl @@ -1,4 +1,4 @@ @import 'stylus/jeet/index' .test - margin-right: column-width(ratios: 1/5, g: 5) + margin-right: column-width(ratios: 1/5, gutter: 5)