Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
80 lines (61 sloc) 1.59 KB
$grid-namespace: 'grid' !default;
$grid-columns-namespace: 'col' !default;
$column-prefixes: () !default;
$columns: 2 3 4 5 6 !default;
$gutters: 1.5em !default;
@mixin _column-setup ($prefix: false) {
$cache: ();
@each $group in $columns {
$include: ();
@if (length($group) == 2) {
$include: nth($group, 2);
$group: nth($group, 1);
}
@for $i from 1 to $group {
@if (length($include) and index($include, $i)) or length($include) == 0 {
$value: 100% / $group * $i;
$index: index($cache, $value);
@if not $index {
$cache: append($cache, $value);
$index: length($cache);
%#{$prefix + '-' + $index} { width: $value; }
}
$selector: if($prefix, $prefix, "") + $i + '-' + $group;
[data-#{$grid-columns-namespace}~="#{$selector}"] {
@extend %#{$prefix + '-' + $index};
}
}
}
}
}
[data-#{$grid-namespace}] {
display: block;
margin-left: -$gutters;
&::after {
content: "";
display: table;
clear: both;
}
}
[data-#{$grid-namespace}~="gutterless"] {
margin-left: 0;
}
[data-#{$grid-columns-namespace}] {
position: relative;
display: block;
width: 100%;
float: left;
padding-left: $gutters;
[data-#{$grid-namespace}~="rev"] & {
float: right;
}
[data-#{$grid-namespace}~="gutterless"] & {
padding-left: 0;
}
}
@include _column-setup();
@each $prefix, $media-query in $column-prefixes {
@media #{$media-query} {
@include _column-setup($prefix);
}
}