Skip to content

Commit

Permalink
Allow negative span
Browse files Browse the repository at this point in the history
This allows negative span computation for usage such as margins, left/right values, etc.
  • Loading branch information
qtgye committed Jul 21, 2018
1 parent 00d3ffa commit 9124907
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions simple-grids/_span.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,20 @@
$container: compute-total-container($columns, $gutters);
$will-use-calc: not is-plain-number($gutters);

$gutter-span: if($column-span > 1, ($gutters * ($column-span - 1)), 0);
$gutter-span: if(unsigned($column-span) > 1, ($gutters * (unsigned($column-span) - 1)), 0);
@if $column-spread == wide {
$gutter-span: $gutter-span + $gutters;
} @else if $column-spread == wider {
$gutter-span: $gutter-span + ($gutters * 2);
}

@if $will-use-calc {
$total-span: "#{$column-span} * (100% - #{$gutters * ($columns - 1)}) / #{$columns}";
$total-span: "#{unsigned($column-span)} * (100% - #{$gutters * ($columns - 1)}) / #{$columns}";
$total-span: if($gutter-span == 0, $total-span, #{$total-span} + #{$gutter-span});
@return calc(#{$total-span});
$total-span: if($column-span < 0, "(#{$total-span}) * -1", $total-span);
@return calc(#{unquote(#{$total-span})});
} @else {
$total-span: $column-span + $gutter-span;
$total-span: unsigned($column-span) + $gutter-span;
@return percentage($total-span / $container);
}

Expand Down

0 comments on commit 9124907

Please sign in to comment.