Skip to content

Commit

Permalink
Merge pull request #358 from Morhaus/master
Browse files Browse the repository at this point in the history
Fix column-width and column-gutter
  • Loading branch information
corysimmons committed Sep 19, 2014
2 parents 5ffc2e4 + 5e15644 commit f3d2469
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 48 deletions.
32 changes: 6 additions & 26 deletions scss/jeet/_grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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) + '%');
}

/**
Expand Down
24 changes: 6 additions & 18 deletions stylus/jeet/_grid.styl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/functions/column-gutter/column-gutter.scss
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 1 addition & 1 deletion tests/functions/column-gutter/column-gutter.styl
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion tests/functions/column-width/column-width.scss
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 1 addition & 1 deletion tests/functions/column-width/column-width.styl
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit f3d2469

Please sign in to comment.