// 16 arguments can be passed into this function // a max of 16 comma seperated grids @function compound($compound-grids...) { @if length($compound-grids) == 1 { $compound-grids: nth($compound-grids, 1); } // merge arguments into a single list. // Find the base resolution of grid $resolution: 1; @each $item in $compound-grids { $resolution: $resolution * $item; } $compound-grid: (); $compound-counter: 1; // cycle through each step in grid resolution @for $i from 1 through $resolution { // dont add a column by default $add-col: false; // cycle through all grids to see if any grids match @each $grid in $compound-grids { // if the grid divides evenly into the resolution, add a column // divide the resolution by number of columns to get the column resolution @if $i / ($resolution / $grid) == round($i / ($resolution / $grid)) { $add-col: true; } } // add the counter value to the compound grid list, reset counter // this marks where one column ends and a new one begins @if $add-col { $compound-grid: join($compound-grid, $compound-counter); $compound-counter: 1; } // if no column is added, bump up counter @else { $compound-counter: $compound-counter + 1; } } @return $compound-grid; }