// calculate the width of individual columns //@function list-column-width($location, $columns) { // // send a warning if this is used when $columns is not a list // @if type-of($columns) != list { // @warn "The column-list-sum function requires the variable $columns to be a list."; // } // @else { // // divide the column from its context // @return nth(nth($columns, $location), 1) / list-sum($columns); // } //} // Calculate the width spanning multiple columns @function column-span($span, $location: 1, $columns: $columns) { $columns-and-gutters: column-sum($columns, $gutter); // Equal width columns @if type-of($columns) == number { $span-and-gutter: $span + (($span - 1) * $gutter); @return $span-and-gutter / $columns-and-gutters * 100%; } // Variable width columns @if type-of($columns) == list { // zero out initial sum $sum: 0; $holder: (); // from start point to end point @for $i from $location to $location + $span { $holder: append($holder, nth(nth($columns, $i), 1), comma); } @return column-sum($holder, $gutter) / $columns-and-gutters * 100%; } @return 10%; } @function column-sum($columns: $columns, $gutter: $gutter) { @if type-of($columns) == 'number' { @return $columns + ((column-count($columns) - 1) * $gutter); } @else if type-of($columns) == 'list' { $sum: 0; @each $column in $columns { $sum: $sum + nth($column, 1); } $sum: $sum + (column-count($columns) - 1) * $gutter; @return $sum; } }