1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | $table-background: $white !default;
|
14 |
|
15 |
|
16 |
|
17 | $table-color-scale: 5% !default;
|
18 |
|
19 |
|
20 |
|
21 | $table-border: 1px solid smart-scale($table-background, $table-color-scale) !default;
|
22 |
|
23 |
|
24 |
|
25 | $table-padding: rem-calc(8 10 10) !default;
|
26 |
|
27 |
|
28 |
|
29 | $table-hover-scale: 2% !default;
|
30 |
|
31 |
|
32 |
|
33 | $table-row-hover: darken($table-background, $table-hover-scale) !default;
|
34 |
|
35 |
|
36 |
|
37 | $table-row-stripe-hover: darken($table-background, $table-color-scale + $table-hover-scale) !default;
|
38 |
|
39 |
|
40 |
|
41 | $table-is-striped: true !default;
|
42 |
|
43 |
|
44 |
|
45 | $table-striped-background: smart-scale($table-background, $table-color-scale) !default;
|
46 |
|
47 |
|
48 |
|
49 | $table-stripe: even !default;
|
50 |
|
51 |
|
52 |
|
53 | $table-head-background: smart-scale($table-background, $table-color-scale / 2) !default;
|
54 |
|
55 |
|
56 |
|
57 | $table-head-row-hover: darken($table-head-background, $table-hover-scale) !default;
|
58 |
|
59 |
|
60 |
|
61 | $table-foot-background: smart-scale($table-background, $table-color-scale) !default;
|
62 |
|
63 |
|
64 |
|
65 | $table-foot-row-hover: darken($table-foot-background, $table-hover-scale) !default;
|
66 |
|
67 |
|
68 |
|
69 | $table-head-font-color: $body-font-color !default;
|
70 |
|
71 |
|
72 |
|
73 | $table-foot-font-color: $body-font-color !default;
|
74 |
|
75 |
|
76 |
|
77 | $show-header-for-stacked: false !default;
|
78 |
|
79 |
|
80 |
|
81 | $table-stack-breakpoint: medium !default;
|
82 |
|
83 | @mixin -zf-table-stripe($stripe: $table-stripe) {
|
84 | tr {
|
85 |
|
86 | @if $stripe == even {
|
87 | &:nth-child(even) {
|
88 | border-bottom: 0;
|
89 | background-color: $table-striped-background;
|
90 | }
|
91 | }
|
92 |
|
93 |
|
94 | @else if $stripe == odd {
|
95 | &:nth-child(odd) {
|
96 | background-color: $table-striped-background;
|
97 | }
|
98 | }
|
99 | }
|
100 | }
|
101 |
|
102 | @mixin -zf-table-unstripe() {
|
103 | tr {
|
104 | border-bottom: 0;
|
105 | border-bottom: $table-border;
|
106 | background-color: $table-background;
|
107 | }
|
108 | }
|
109 |
|
110 | @mixin -zf-table-children-styles($stripe: $table-stripe, $is-striped: $table-is-striped) {
|
111 | thead,
|
112 | tbody,
|
113 | tfoot {
|
114 | border: $table-border;
|
115 | background-color: $table-background;
|
116 | }
|
117 |
|
118 |
|
119 | caption {
|
120 | padding: $table-padding;
|
121 | font-weight: $global-weight-bold;
|
122 | }
|
123 |
|
124 |
|
125 | thead {
|
126 | background: $table-head-background;
|
127 | color: $table-head-font-color;
|
128 | }
|
129 |
|
130 |
|
131 | tfoot {
|
132 | background: $table-foot-background;
|
133 | color: $table-foot-font-color;
|
134 | }
|
135 |
|
136 |
|
137 | thead,
|
138 | tfoot {
|
139 |
|
140 | tr {
|
141 | background: transparent;
|
142 | }
|
143 |
|
144 |
|
145 | th,
|
146 | td {
|
147 | padding: $table-padding;
|
148 | font-weight: $global-weight-bold;
|
149 | text-align: #{$global-left};
|
150 | }
|
151 | }
|
152 |
|
153 |
|
154 | tbody {
|
155 | th,
|
156 | td {
|
157 | padding: $table-padding;
|
158 | }
|
159 | }
|
160 |
|
161 |
|
162 | @if $is-striped == true {
|
163 | tbody {
|
164 | @include -zf-table-stripe($stripe);
|
165 | }
|
166 |
|
167 | &.unstriped {
|
168 | tbody {
|
169 | @include -zf-table-unstripe();
|
170 | background-color: $table-background;
|
171 | }
|
172 | }
|
173 | }
|
174 |
|
175 |
|
176 | @else if $is-striped == false {
|
177 | tbody {
|
178 | @include -zf-table-unstripe();
|
179 | }
|
180 |
|
181 | &.striped {
|
182 | tbody {
|
183 | @include -zf-table-stripe($stripe);
|
184 | }
|
185 | }
|
186 | }
|
187 | }
|
188 |
|
189 |
|
190 |
|
191 | @mixin table(
|
192 | $stripe: $table-stripe,
|
193 | $nest: false
|
194 | ) {
|
195 | border-collapse: collapse;
|
196 | width: 100%;
|
197 | margin-bottom: $global-margin;
|
198 | border-radius: $global-radius;
|
199 |
|
200 | @if $nest {
|
201 | @include -zf-table-children-styles($stripe);
|
202 | }
|
203 | @else {
|
204 | @at-root {
|
205 | @include -zf-table-children-styles($stripe);
|
206 | }
|
207 | }
|
208 | }
|
209 |
|
210 |
|
211 | @mixin table-scroll {
|
212 | display: block;
|
213 | width: 100%;
|
214 | overflow-x: auto;
|
215 | }
|
216 |
|
217 |
|
218 | @mixin table-hover {
|
219 | thead tr {
|
220 |
|
221 | &:hover {
|
222 | background-color: $table-head-row-hover;
|
223 | }
|
224 | }
|
225 |
|
226 | tfoot tr {
|
227 |
|
228 | &:hover {
|
229 | background-color: $table-foot-row-hover;
|
230 | }
|
231 | }
|
232 |
|
233 | tbody tr {
|
234 |
|
235 | &:hover {
|
236 | background-color: $table-row-hover;
|
237 | }
|
238 | }
|
239 |
|
240 | @if $table-is-striped == true {
|
241 |
|
242 | @if($table-stripe == even) {
|
243 | &:not(.unstriped) tr:nth-of-type(even):hover {
|
244 | background-color: $table-row-stripe-hover;
|
245 | }
|
246 | }
|
247 |
|
248 |
|
249 | @elseif($table-stripe == odd) {
|
250 | &:not(.unstriped) tr:nth-of-type(odd):hover {
|
251 | background-color: $table-row-stripe-hover;
|
252 | }
|
253 | }
|
254 | }
|
255 |
|
256 | @else if $table-is-striped == false {
|
257 |
|
258 | @if($table-stripe == even) {
|
259 | &.striped tr:nth-of-type(even):hover {
|
260 | background-color: $table-row-stripe-hover;
|
261 | }
|
262 | }
|
263 |
|
264 |
|
265 | @elseif($table-stripe == odd) {
|
266 | &.striped tr:nth-of-type(odd):hover {
|
267 | background-color: $table-row-stripe-hover;
|
268 | }
|
269 | }
|
270 | }
|
271 | }
|
272 |
|
273 |
|
274 |
|
275 | @mixin table-stack($header: $show-header-for-stacked) {
|
276 | @if $header {
|
277 | thead {
|
278 | th {
|
279 | display: block;
|
280 | }
|
281 | }
|
282 | }
|
283 | @else {
|
284 | thead {
|
285 | display: none;
|
286 | }
|
287 | }
|
288 |
|
289 | tfoot {
|
290 | display: none;
|
291 | }
|
292 |
|
293 | tr,
|
294 | th,
|
295 | td {
|
296 | display: block;
|
297 | }
|
298 |
|
299 | td {
|
300 | border-top: 0;
|
301 | }
|
302 | }
|
303 |
|
304 | @mixin foundation-table($nest: false) {
|
305 | table {
|
306 | @include table($nest: $nest);
|
307 | }
|
308 |
|
309 | table.stack {
|
310 | @include breakpoint($table-stack-breakpoint down) {
|
311 | @include table-stack;
|
312 | }
|
313 | }
|
314 |
|
315 | table.scroll {
|
316 | @include table-scroll;
|
317 | }
|
318 |
|
319 | table.hover {
|
320 | @include table-hover;
|
321 | }
|
322 |
|
323 | .table-scroll {
|
324 | overflow-x: auto;
|
325 |
|
326 | table {
|
327 | width: auto;
|
328 | }
|
329 | }
|
330 | }
|