Skip to content

Instantly share code, notes, and snippets.

@acdlite
Created November 4, 2013 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acdlite/7298865 to your computer and use it in GitHub Desktop.
Save acdlite/7298865 to your computer and use it in GitHub Desktop.
Experiment using Sass maps to organize Susy Next configuration. Generated by SassMeister.com.
// ----
// 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);
}
output {
a: 3;
b: 90% 8 1/4;
c: 90%;
d: 1/4;
e: 8;
f: 8;
g: 12;
}
@acdlite
Copy link
Author

acdlite commented Nov 4, 2013

I went ahead and created another Gist for the above: https://gist.github.com/acdlite/7308879

@acdlite
Copy link
Author

acdlite commented Nov 4, 2013

So if Susy used this pattern, my example grid() function above would correspond to susy-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 with columns: (4 8) has a total of 12 columns. I think that would be a useful feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment