| 1 |
@charset "UTF-8"; |
| 2 |
|
| 3 |
/// Specifies the number of columns an element should span. If the selector is nested the number of columns of its parent element should be passed as an argument as well. |
| 4 |
/// |
| 5 |
/// @param {List} $span |
| 6 |
/// A list containing `$columns`, the unitless number of columns the element spans (required), and `$container-columns`, the number of columns the parent element spans (optional). |
| 7 |
/// |
| 8 |
/// If only one value is passed, it is assumed that it's `$columns` and that that `$container-columns` is equal to `$grid-columns`, the total number of columns in the grid. |
| 9 |
/// |
| 10 |
/// The values can be separated with any string such as `of`, `/`, etc. |
| 11 |
/// |
| 12 |
/// `$columns` also accepts decimals for when it's necessary to break out of the standard grid. E.g. Passing `2.4` in a standard 12 column grid will divide the row into 5 columns. |
| 13 |
/// |
| 14 |
/// @param {String} $display [block] |
| 15 |
/// Sets the display property of the element. By default it sets the display property of the element to `block`. |
| 16 |
/// |
| 17 |
/// If passed `block-collapse`, it also removes the margin gutter by adding it to the element width. |
| 18 |
/// |
| 19 |
/// If passed `table`, it sets the display property to `table-cell` and calculates the width of the element without taking gutters into consideration. The result does not align with the block-based grid. |
| 20 |
/// |
| 21 |
/// @example scss - Usage |
| 22 |
/// .element { |
| 23 |
/// @include span-columns(6); |
| 24 |
/// |
| 25 |
/// .nested-element { |
| 26 |
/// @include span-columns(2 of 6); |
| 27 |
/// } |
| 28 |
/// } |
| 29 |
/// |
| 30 |
/// @example css - CSS Output |
| 31 |
/// .element { |
| 32 |
/// display: block; |
| 33 |
/// float: left; |
| 34 |
/// margin-right: 2.35765%; |
| 35 |
/// width: 48.82117%; |
| 36 |
/// } |
| 37 |
/// |
| 38 |
/// .element:last-child { |
| 39 |
/// margin-right: 0; |
| 40 |
/// } |
| 41 |
/// |
| 42 |
/// .element .nested-element { |
| 43 |
/// display: block; |
| 44 |
/// float: left; |
| 45 |
/// margin-right: 4.82916%; |
| 46 |
/// width: 30.11389%; |
| 47 |
/// } |
| 48 |
/// |
| 49 |
/// .element .nested-element:last-child { |
| 50 |
/// margin-right: 0; |
| 51 |
/// } |
| 52 |
|
| 53 |
@mixin span-columns($span: $columns of $container-columns, $display: block) { |
| 54 |
$columns: nth($span, 1); |
| 55 |
$container-columns: container-span($span); |
| 56 |
|
| 57 |
$parent-columns: get-parent-columns($container-columns) !global; |
| 58 |
|
| 59 |
$direction: get-direction($layout-direction, $default-layout-direction); |
| 60 |
$opposite-direction: get-opposite-direction($direction); |
| 61 |
|
| 62 |
$display-table: is-display-table($container-display-table, $display); |
| 63 |
|
| 64 |
@if $display-table { |
| 65 |
display: table-cell; |
| 66 |
width: percentage($columns / $container-columns); |
| 67 |
} @else { |
| 68 |
float: #{$opposite-direction}; |
| 69 |
|
| 70 |
@if $display != no-display { |
| 71 |
display: block; |
| 72 |
} |
| 73 |
|
| 74 |
@if $display == collapse { |
| 75 |
@include -neat-warn("The 'collapse' argument will be deprecated. Use 'block-collapse' instead."); |
| 76 |
} |
| 77 |
|
| 78 |
@if $display == collapse or $display == block-collapse { |
| 79 |
width: flex-grid($columns, $container-columns) + flex-gutter($container-columns); |
| 80 |
|
| 81 |
&:last-child { |
| 82 |
width: flex-grid($columns, $container-columns); |
| 83 |
} |
| 84 |
|
| 85 |
} @else { |
| 86 |
margin-#{$direction}: flex-gutter($container-columns); |
| 87 |
width: flex-grid($columns, $container-columns); |
| 88 |
|
| 89 |
&:last-child { |
| 90 |
margin-#{$direction}: 0; |
| 91 |
} |
| 92 |
} |
| 93 |
} |
| 94 |
} |