|
1 | 1 | @use "sass:map"; |
2 | 2 | @use "../settings" as *; |
3 | 3 |
|
4 | | -// Variables for striped rows |
5 | | -$color-dark: var(#{$css-var-prefix}table-row-stripped-background-color); |
6 | | -$color-light: var(#{$css-var-prefix}background-color); |
7 | | - |
8 | | -// Adjust this number to control how many <tr hidden> rows are expected. |
9 | | -$hidden-levels: $hidden-table-levels; |
10 | | - |
11 | | -// Do not change, or remove the following line |
12 | | -// needed this outside of the mixin to compile, idk why |
13 | | -// sass --version = 1.83.4 compiled with dart2js 3.6.1 |
14 | | -$selector: "& ~ tr"; |
15 | | - |
16 | | -// This is the work around because the compiler changes |
17 | | -// :nth-child(odd of :not(:hidden)) to :nth-child(oddof:not(:hidden)) |
18 | | -// which makes the stripes fail. |
19 | | -// Mixin to handle the hidden row with striped backgrounds patterns |
20 | | -// Thanks Shaggy: https://stackoverflow.com/questions/3773890/zebra-striping-a-table-with-hidden-rows-using-css3/36892714#36892714 |
21 | | -@mixin hidden-row-patterns($levels: 2, $dark-color: $color-dark, $light-color: $color-light) { |
22 | | - $current-color-odd: $light-color; |
23 | | - $current-color-even: $dark-color; |
24 | | - // Generate nested s electors for each level |
25 | | - $selector: "& ~ tr"; |
26 | | - |
27 | | - &[hidden] { |
28 | | - display: none; |
29 | | - |
30 | | - @for $i from 1 through $levels { |
31 | | - @if $i > 1 { |
32 | | - // Swap colors for next iteration |
33 | | - $temp: $current-color-odd; |
34 | | - $current-color-odd: $current-color-even; |
35 | | - $current-color-even: $temp; |
36 | | - |
37 | | - // Add another level of nesting to the selector |
38 | | - $selector: "#{$selector}[hidden] ~ tr"; |
39 | | - } |
40 | | - #{$selector} { |
41 | | - &:nth-child(odd) { |
42 | | - > th, |
43 | | - > td { |
44 | | - background: $current-color-odd; |
45 | | - } |
46 | | - } |
47 | | - |
48 | | - &:nth-child(even) { |
49 | | - > th, |
50 | | - > td { |
51 | | - background: $current-color-even; |
52 | | - } |
53 | | - } |
54 | | - } |
55 | | - } |
56 | | - } |
57 | | -} |
58 | | - |
59 | 4 | @if map.get($modules, "content/table") { |
60 | 5 | /** |
61 | 6 | * Table |
@@ -126,23 +71,11 @@ $selector: "& ~ tr"; |
126 | 71 | @if enable-classes { |
127 | 72 | #{$parent-selector} table { |
128 | 73 | &.striped { |
129 | | - > tbody > tr { |
130 | | - &:nth-child(odd) { |
131 | | - > th, |
132 | | - > td { |
133 | | - background: $color-dark; |
134 | | - } |
135 | | - } |
136 | | - |
137 | | - &:nth-child(even) { |
138 | | - > th, |
139 | | - > td { |
140 | | - background: $color-light; |
141 | | - } |
142 | | - } |
143 | | - |
144 | | - // Apply the hidden row patterns |
145 | | - @include hidden-row-patterns($hidden-levels); |
| 74 | + /* clean-css ignore:start */ |
| 75 | + tbody tr:nth-child(odd of :not([hidden])) th, |
| 76 | + tbody tr:nth-child(odd of :not([hidden])) td { |
| 77 | + /* clean-css ignore:end */ |
| 78 | + background-color: var(#{$css-var-prefix}table-row-stripped-background-color); |
146 | 79 | } |
147 | 80 | } |
148 | 81 | } |
|
0 commit comments