Experiment using Sass maps to organize Susy Next configuration. Generated by SassMeister.com.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// Sass (v3.3.0.rc.1) | |
// Compass (v0.13.alpha.10) | |
// ---- | |
$grid: ( | |
small: 90% 8 1/4, | |
medium: 80% 8 1/4, | |
large: 80% 12 1/4, | |
); | |
$content-grid: ( | |
left: 100% (4 8) 1/4, | |
right: 100% (8 4) 1/4 | |
); | |
@function _grid($map, $g, $attr: false) { | |
$list: map-get($map, $g); | |
@if $attr == container-width { @return nth($list, 1) } | |
@if $attr == columns { @return nth($list, 2) } | |
@if $attr == gutters { @return nth($list, 3) } | |
@if $attr == total-columns { | |
$columns: nth($list, 2); | |
@if type-of($columns) != list { @return $columns } | |
$sum: 0; | |
@each $n in $columns { | |
$sum: $sum + $n; | |
} | |
@return $sum; | |
} | |
@return $list; | |
} | |
@function grid($g, $attr: false) { | |
@return _grid($grid, $g, $attr); | |
} | |
@function content-grid($g, $attr: false) { | |
@return _grid($content-grid, $g, $attr); | |
} | |
output { | |
a: length(map-get($grid, small)); | |
b: grid(small); | |
c: grid(small, container-width); | |
d: content-grid(left, gutters); | |
e: grid(medium, columns); | |
f: grid(medium, total-columns); | |
g: content-grid(left, total-columns); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output { | |
a: 3; | |
b: 90% 8 1/4; | |
c: 90%; | |
d: 1/4; | |
e: 8; | |
f: 8; | |
g: 12; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So if Susy used this pattern, my example
grid()
function above would correspond tosusy-get()
.Question: does
susy-get()
return the total number of columns in a grid? Not sure the best way to phrase this, but for instance, a grid withcolumns: (4 8)
has a total of 12 columns. I think that would be a useful feature.