UNPKG

9.21 kBSCSSView Raw
1//
2// Copyright IBM Corp. 2016, 2018
3//
4// This source code is licensed under the Apache-2.0 license found in the
5// LICENSE file in the root directory of this source tree.
6//
7
8@import '../../globals/scss/css--typography';
9@import '../../globals/scss/functions';
10@import '../../globals/scss/vendor/@carbon/elements/scss/import-once/import-once';
11@import '../../globals/scss/vars';
12
13@mixin data-table-v2-core {
14 .#{$prefix}--data-table-v2-container {
15 width: 100%;
16 min-width: rem(500px);
17 overflow-x: auto;
18 padding-top: $spacing-3xs; // allow space for focus styles
19 }
20
21 .#{$prefix}--data-table-v2 {
22 border-collapse: collapse;
23 border-spacing: 0;
24 width: 100%;
25 border-bottom: 1px solid $ui-03;
26
27 @if feature-flag-enabled('breaking-changes-x') {
28 min-width: rem(500px);
29 }
30
31 thead {
32 @include typescale('zeta');
33 background-color: $ui-02;
34 font-weight: 700;
35 border-right: 1px solid $ui-03;
36 }
37
38 tbody {
39 @include typescale('zeta');
40 background-color: $ui-01;
41 border-right: 1px solid $ui-03;
42 }
43
44 tr {
45 height: rem(48px);
46
47 &:hover {
48 td {
49 background-color: rgba($brand-02, 0.1);
50 border-top: 1px solid $brand-01;
51 border-bottom: 1px solid $brand-01;
52
53 &:first-of-type {
54 border-left: 1px solid $brand-01;
55 }
56
57 &:last-of-type {
58 border-right: 1px solid $brand-01;
59 }
60 }
61
62 .#{$prefix}--overflow-menu {
63 opacity: 1;
64 }
65 }
66 }
67
68 th {
69 border-top: 1px solid $ui-03;
70 }
71
72 th,
73 td {
74 @include typescale('zeta');
75 border-top: 1px solid $ui-03;
76 padding-left: $spacing-sm;
77 vertical-align: middle;
78 text-align: left;
79 color: $text-01;
80
81 &:first-of-type {
82 padding-left: rem(24px);
83 border-left: 1px solid $ui-03;
84 }
85
86 &:last-of-type {
87 padding-right: $spacing-lg;
88 }
89 }
90
91 // Overrrides
92 .#{$prefix}--checkbox-label {
93 padding-left: rem(28px);
94 }
95
96 .#{$prefix}--overflow-menu {
97 opacity: 0;
98
99 &:focus {
100 outline: 0;
101 opacity: 1;
102 box-shadow: none;
103
104 .#{$prefix}--overflow-menu__icon {
105 box-shadow: inset 0px 0px 0px 1px $brand-01;
106 }
107 }
108 }
109
110 .#{$prefix}--overflow-menu__icon {
111 transform: rotate(90deg);
112 }
113 }
114
115 // Options
116
117 .#{$prefix}--data-table-v2-header {
118 margin-bottom: $spacing-xs;
119 color: $text-01;
120 }
121
122 .#{$prefix}--data-table-v2--zebra {
123 tbody tr:nth-child(even) {
124 background-color: $ui-02;
125 }
126 }
127
128 .#{$prefix}--data-table-v2--no-border {
129 & {
130 border-bottom-color: transparent;
131 }
132
133 thead,
134 tbody {
135 border-right-color: transparent;
136 }
137
138 th,
139 td {
140 &:first-of-type {
141 border-left-color: transparent;
142 }
143 }
144 }
145
146 .#{$prefix}--data-table-v2--compact {
147 tbody tr {
148 height: rem(24px);
149 }
150 }
151
152 .#{$prefix}--data-table-v2--short {
153 tbody tr {
154 height: rem(32px);
155 }
156 }
157
158 .#{$prefix}--data-table-v2--tall {
159 tbody tr {
160 height: rem(64px);
161 }
162 }
163
164 .#{$prefix}--data-table-v2--static {
165 width: auto;
166 }
167
168 .#{$prefix}--data-table-v2--zebra tbody tr.#{$prefix}--data-table-v2--selected,
169 tbody tr.#{$prefix}--data-table-v2--selected {
170 background-color: rgba($brand-02, 0.1);
171 }
172}
173
174@mixin data-table-v2-core--x {
175 //----------------------------------------------------------------------------
176 // Container
177 //----------------------------------------------------------------------------
178 .#{$prefix}--data-table-v2-container {
179 min-width: rem(500px);
180 overflow-x: auto;
181 padding-top: $spacing-01; // allow space for focus styles
182 }
183
184 //----------------------------------------------------------------------------
185 // Table title text
186 //----------------------------------------------------------------------------
187 .#{$prefix}--data-table-v2-header {
188 background: $ui-01;
189 height: rem(88px);
190 padding: rem(22px) 0 0 $spacing-05;
191 }
192
193 .#{$prefix}--data-table-v2-header__title {
194 @include type-style('productive-heading-03');
195 color: $text-01;
196 }
197
198 .#{$prefix}--data-table-v2-header__description {
199 @include type-style('body-short-01');
200 color: $text-02;
201 }
202
203 //----------------------------------------------------------------------------
204 // Data table
205 //----------------------------------------------------------------------------
206 .#{$prefix}--data-table-v2 {
207 border-collapse: collapse;
208 border-spacing: 0;
209 width: 100%;
210 }
211
212 .#{$prefix}--data-table-v2 thead {
213 @include type-style('heading-01');
214 background-color: $ui-03;
215 }
216
217 .#{$prefix}--data-table-v2 tbody {
218 @include type-style('body-short-01');
219 background-color: $ui-01;
220 width: 100%;
221 }
222
223 .#{$prefix}--data-table-v2 tr {
224 border: none;
225 height: $layout-04;
226 width: 100%;
227 }
228
229 .#{$prefix}--data-table-v2 tbody tr:hover {
230 background: $hover-field;
231 }
232
233 .#{$prefix}--data-table-v2 tbody tr:hover td {
234 color: $text-01;
235 background: $hover-field;
236 border-bottom: 1px solid $hover-field;
237 border-top: 1px solid $hover-field;
238 }
239
240 .#{$prefix}--data-table-v2 th,
241 .#{$prefix}--data-table-v2 td {
242 padding-left: $spacing-04;
243 padding-right: $spacing-04;
244 vertical-align: top;
245 text-align: left;
246 }
247
248 .#{$prefix}--data-table-v2 th {
249 color: $text-01;
250 background-color: $ui-03;
251 border-top: 1px solid $ui-03;
252 border-bottom: 1px solid $ui-03;
253 }
254
255 .#{$prefix}--data-table-v2 th:first-of-type {
256 padding-left: $spacing-05;
257 }
258
259 .#{$prefix}--data-table-v2 .#{$prefix}--table-header-label {
260 display: block;
261 padding: rem(14px) 0;
262 }
263
264 .#{$prefix}--data-table-v2 td {
265 background: $ui-01;
266 color: $text-02;
267 border-top: 1px solid $ui-01;
268 border-bottom: 1px solid $ui-03;
269 padding: rem(14px) $spacing-04;
270 padding-bottom: rem(13px);
271 }
272
273 .#{$prefix}--data-table-v2 td:first-of-type {
274 padding-left: $spacing-05;
275 }
276
277 .#{$prefix}--data-table-v2 td:last-of-type {
278 padding-right: $spacing-05;
279 }
280
281 // specific padding for overflow menu columns
282 .#{$prefix}--data-table-v2 .#{$prefix}--table-column-menu,
283 .#{$prefix}--data-table-v2 .#{$prefix}--table-column-menu:last-of-type {
284 padding-top: $spacing-03;
285 padding-right: $spacing-03;
286 }
287
288 .#{$prefix}--data-table-v2 td.#{$prefix}--table-column-menu .#{$prefix}--overflow-menu[aria-expanded='false']:hover {
289 background: $ui-03;
290 }
291
292 // Overflow Menu Overrides
293 .#{$prefix}--data-table-v2 td.#{$prefix}--table-column-menu .#{$prefix}--overflow-menu[aria-expanded='false']:focus {
294 @include focus-outline('outline');
295 }
296
297 .#{$prefix}--data-table-v2 td.#{$prefix}--table-column-menu .#{$prefix}--overflow-menu[aria-expanded='true']:focus {
298 outline: none;
299 }
300
301 .#{$prefix}--data-table-v2 td.#{$prefix}--table-column-menu .#{$prefix}--overflow-menu .#{$prefix}--overflow-menu__icon {
302 opacity: 0;
303 }
304
305 .#{$prefix}--data-table-v2 td.#{$prefix}--table-column-menu .#{$prefix}--overflow-menu:hover .#{$prefix}--overflow-menu__icon,
306 .#{$prefix}--data-table-v2 td.#{$prefix}--table-column-menu .#{$prefix}--overflow-menu:focus .#{$prefix}--overflow-menu__icon,
307 .#{$prefix}--data-table-v2
308 tr:hover
309 td.#{$prefix}--table-column-menu
310 .#{$prefix}--overflow-menu
311 .#{$prefix}--overflow-menu__icon {
312 opacity: 1;
313 }
314
315 //----------------------------------------------------------------------------
316 // Select
317 //----------------------------------------------------------------------------
318 .#{$prefix}--table-column-checkbox .#{$prefix}--checkbox-label {
319 padding-left: $spacing-05;
320 }
321
322 .#{$prefix}--data-table-v2 th.#{$prefix}--table-column-checkbox {
323 padding: rem(12px) $spacing-03 0 $spacing-05;
324 width: rem(44px); // 16px padding left + 8px padding right + 20px checkbox width
325 }
326
327 th.#{$prefix}--table-column-checkbox:hover {
328 background: $data-table-column-hover;
329 }
330
331 // default selected row
332 tr.#{$prefix}--data-table-v2--selected td {
333 background-color: $ui-03;
334 border-top: 1px solid $ui-03;
335 border-bottom: 1px solid $active-01; //bottom border acts as separator from other rows
336 }
337
338 // first row
339 tr.#{$prefix}--data-table-v2--selected:first-of-type td {
340 border-top: 1px solid $active-01; //top border acts as separator from thead
341 }
342
343 // last row
344 tr.#{$prefix}--data-table-v2--selected:last-of-type td {
345 border-top: 1px solid $ui-03; // doesn't need separators
346 border-bottom: 1px solid $ui-03;
347 }
348
349 // hover
350 .#{$prefix}--data-table-v2 tbody .#{$prefix}--data-table-v2--selected:hover td {
351 color: $text-01;
352 background: $data-table-column-hover;
353 border-top: 1px solid $data-table-column-hover;
354 border-bottom: 1px solid $data-table-column-hover;
355 }
356
357 // selected overflow menu
358 .#{$prefix}--data-table-v2--selected .#{$prefix}--overflow-menu .#{$prefix}--overflow-menu__icon {
359 opacity: 1;
360 }
361}
362
363@include exports('data-table-v2-core') {
364 @if feature-flag-enabled('components-x') {
365 @include data-table-v2-core--x;
366 } @else {
367 @include data-table-v2-core;
368 }
369}