Skip to content

Instantly share code, notes, and snippets.

@gisu
Last active July 25, 2017 10:20
Show Gist options
  • Save gisu/568cf870d8860fbd0ec1225a05122c4e to your computer and use it in GitHub Desktop.
Save gisu/568cf870d8860fbd0ec1225a05122c4e to your computer and use it in GitHub Desktop.
/// Generate a Grid Template Area from a Grid Map
///
/// @group core - cssgrid
///
/// @param {string} $area - Name of the Area
/// @param {map} $map - Map of your grid area matrix
///
/// @example scss - scss
/// $gridAreaMap: (
/// row1: ('logo', 'nav', 'nav', 'nav'),
/// row2: ('logo', 'empty', 'search', 'search')
/// );
/// @include grid-matrix($gridAreaMap);
@mixin grid-matrix($map) {
$matrix: ();
@each $index, $row in $map {
$list: null;
@for $i from 1 through length($row) {
$list: append($list, unquote(nth(($row), $i)), space);
}
$matrix: append($matrix, quote($list), space);
}
grid-template-areas: $matrix;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment