| 1 |
@charset "UTF-8"; |
| 2 |
|
| 3 |
/// Removes the element's gutter margin, regardless of its position in the grid hierarchy or display property. It can target a specific element, or every `nth-child` occurrence. Works only with `block` layouts. |
| 4 |
/// |
| 5 |
/// @param {List} $query [block] |
| 6 |
/// List of arguments. Supported arguments are `nth-child` selectors (targets a specific pseudo element) and `auto` (targets `last-child`). |
| 7 |
/// |
| 8 |
/// When passed an `nth-child` argument of type `*n` with `block` display, the omega mixin automatically adds a clear to the `*n+1` th element. Note that composite arguments such as `2n+1` do not support this feature. |
| 9 |
/// |
| 10 |
/// **Deprecation warning**: The omega mixin will no longer take a `$direction` argument. To change the layout direction, use `row($direction)` or set `$default-layout-direction` instead. |
| 11 |
/// |
| 12 |
/// @example scss - Usage |
| 13 |
/// .element { |
| 14 |
/// @include omega; |
| 15 |
/// } |
| 16 |
/// |
| 17 |
/// .nth-element { |
| 18 |
/// @include omega(4n); |
| 19 |
/// } |
| 20 |
/// |
| 21 |
/// @example css - CSS Output |
| 22 |
/// .element { |
| 23 |
/// margin-right: 0; |
| 24 |
/// } |
| 25 |
/// |
| 26 |
/// .nth-element:nth-child(4n) { |
| 27 |
/// margin-right: 0; |
| 28 |
/// } |
| 29 |
/// |
| 30 |
/// .nth-element:nth-child(4n+1) { |
| 31 |
/// clear: left; |
| 32 |
/// } |
| 33 |
|
| 34 |
@mixin omega($query: block, $direction: default) { |
| 35 |
$table: belongs-to(table, $query); |
| 36 |
$auto: belongs-to(auto, $query); |
| 37 |
|
| 38 |
@if $direction != default { |
| 39 |
@include -neat-warn("The omega mixin will no longer take a $direction argument. To change the layout direction, use the direction(){...} mixin."); |
| 40 |
} @else { |
| 41 |
$direction: get-direction($layout-direction, $default-layout-direction); |
| 42 |
} |
| 43 |
|
| 44 |
@if $table { |
| 45 |
@include -neat-warn("The omega mixin no longer removes padding in table layouts."); |
| 46 |
} |
| 47 |
|
| 48 |
@if length($query) == 1 { |
| 49 |
@if $auto { |
| 50 |
&:last-child { |
| 51 |
margin-#{$direction}: 0; |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
@else if contains-display-value($query) and $table == false { |
| 56 |
margin-#{$direction}: 0; |
| 57 |
} |
| 58 |
|
| 59 |
@else { |
| 60 |
@include nth-child($query, $direction); |
| 61 |
} |
| 62 |
} @else if length($query) == 2 { |
| 63 |
@if $auto { |
| 64 |
&:last-child { |
| 65 |
margin-#{$direction}: 0; |
| 66 |
} |
| 67 |
} @else { |
| 68 |
@include nth-child(nth($query, 1), $direction); |
| 69 |
} |
| 70 |
} @else { |
| 71 |
@include -neat-warn("Too many arguments passed to the omega() mixin."); |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
@mixin nth-child($query, $direction) { |
| 76 |
$opposite-direction: get-opposite-direction($direction); |
| 77 |
|
| 78 |
&:nth-child(#{$query}) { |
| 79 |
margin-#{$direction}: 0; |
| 80 |
} |
| 81 |
|
| 82 |
@if type-of($query) == string { |
| 83 |
$query: str-replace($query, " ", ""); |
| 84 |
$operator: false; |
| 85 |
|
| 86 |
@if str_index($query, "+") { |
| 87 |
$operator: "+"; |
| 88 |
} @else if str_index($query, "-") { |
| 89 |
$operator: "-"; |
| 90 |
} |
| 91 |
|
| 92 |
@if $operator { |
| 93 |
$operator-index: str_index($query, $operator); |
| 94 |
$first: str-slice($query, 0, ($operator-index - 1)); |
| 95 |
$last: to-number(str-slice($query, ($operator-index + 1), -1)); |
| 96 |
@if $operator == "+" { |
| 97 |
$last: $last + 1; |
| 98 |
} @else if $operator == "-" { |
| 99 |
$last: $last - 1; |
| 100 |
} |
| 101 |
$nth: "#{$first}#{$operator}#{$last}"; |
| 102 |
|
| 103 |
&:nth-child(#{$nth}) { |
| 104 |
clear: $opposite-direction; |
| 105 |
} |
| 106 |
} |
| 107 |
} @else if type-of($query) == number and unit($query) == "n" { |
| 108 |
&:nth-child(#{$query}+1) { |
| 109 |
clear: $opposite-direction; |
| 110 |
} |
| 111 |
} |
| 112 |
} |