UNPKG

5.86 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/vars';
9@import '../../globals/scss/css--typography';
10@import '../../globals/scss/helper-mixins';
11@import '../../globals/scss/functions';
12@import '../checkbox/checkbox';
13@import '../../globals/scss/vendor/@carbon/elements/scss/import-once/import-once';
14@import '../../components/overflow-menu/overflow-menu';
15
16@mixin data-table {
17 @include deprecate(
18 'The `data-table` component in `carbon-components` has been deprecated. ' + 'It will be removed in the next major release. ' +
19 'If you still need this component, please use the `data-table-v2` component.'
20 ) {
21 .#{$prefix}--responsive-table-container {
22 @include reset;
23 @include font-family;
24 overflow-x: auto;
25 overflow-y: hidden;
26 width: 99.9%;
27 }
28
29 .#{$prefix}--responsive-table {
30 @include reset;
31 background-color: $ui-01;
32 width: 100%;
33 min-width: 500px;
34 border-collapse: collapse;
35 border-spacing: 0;
36 border: 2px solid $ui-03;
37
38 td {
39 @include reset;
40 @include typescale('zeta');
41 padding: 0 rem(6px);
42 vertical-align: middle;
43 color: $text-01;
44 }
45
46 td p {
47 @include typescale('zeta');
48 }
49
50 th {
51 @include reset;
52 @include typescale('omega');
53 padding: rem(9px) rem(6px);
54 vertical-align: middle;
55 font-weight: 600;
56 color: $text-01;
57
58 &:focus {
59 outline: 1px solid transparent;
60
61 span {
62 @include focus-outline('border');
63 }
64 }
65 }
66
67 table {
68 @include reset;
69 }
70
71 &--tall {
72 td,
73 th {
74 padding-top: rem(15px);
75 padding-bottom: rem(15px);
76 }
77 }
78
79 &--static-size {
80 @include reset;
81 border-collapse: collapse;
82 width: auto;
83 border: 2px solid $ui-03;
84
85 tr td:first-child,
86 tr th:first-child {
87 padding-left: 1.5rem;
88 }
89 }
90 }
91
92 .#{$prefix}--responsive-table--tall {
93 td,
94 th {
95 padding-top: rem(10px);
96 padding-bottom: rem(10px);
97 }
98 }
99
100 .#{$prefix}--table-row {
101 @include reset;
102 height: $data-table-row-height;
103 padding-left: 1rem;
104 }
105
106 .#{$prefix}--table-head .#{$prefix}--table-row {
107 border-bottom: $data-table-heading-border-bottom;
108 height: rem(32px);
109 }
110
111 .#{$prefix}--table-header {
112 @include reset;
113 @include typescale('omega');
114 font-weight: 600;
115 text-align: left;
116 text-transform: $data-table-heading-transform;
117 height: rem(40px);
118 }
119
120 // zebra stripes
121 .#{$prefix}--table-body {
122 > .#{$prefix}--parent-row,
123 > .#{$prefix}--parent-row {
124 background-color: $ui-01;
125
126 & + .#{$prefix}--expandable-row {
127 background-color: $ui-01;
128 }
129
130 &--even {
131 background-color: $ui-02;
132
133 & + .#{$prefix}--expandable-row {
134 background-color: $ui-02;
135 }
136 }
137 }
138 }
139
140 .#{$prefix}--table-body .#{$prefix}--table-row {
141 border: 1px solid transparent;
142
143 &:first-child:hover,
144 &:first-child:focus {
145 border-left: 2px solid $brand-02;
146 outline: 1px solid $brand-02;
147 }
148
149 &:not(:first-child):hover,
150 &:not(:first-child):focus {
151 border-left: 2px solid $brand-02;
152 outline: 1px solid $brand-02;
153 }
154 }
155
156 // expandable styles
157 .#{$prefix}--expandable-row {
158 > td {
159 border-left: 4px solid $brand-01;
160 padding: 2rem;
161 }
162
163 &--hidden {
164 visibility: hidden;
165 }
166 }
167
168 // actions
169 .#{$prefix}--table-expand {
170 padding-left: rem(8px);
171 padding-right: rem(12px);
172 text-align: center;
173 width: rem(20px);
174 cursor: pointer;
175
176 &:focus {
177 outline: 1px solid transparent;
178
179 svg {
180 @include focus-outline('border');
181 }
182 }
183 }
184
185 .#{$prefix}--table-expand__svg {
186 fill: $ui-05;
187 transform: rotate(0deg);
188 transition: transform 200ms $carbon--standard-easing;
189 width: 12px;
190 height: 12px;
191 margin-left: rem(7px);
192 margin-right: rem(2px);
193
194 @media all and (min--moz-device-pixel-ratio: 0) and (min-resolution: 3e1dpcm) {
195 margin-top: 2px;
196 }
197 }
198
199 .#{$prefix}--table-expand[data-previous-value='collapsed'] .#{$prefix}--table-expand__svg {
200 transform: rotate(90deg);
201 transition: transform 200ms $carbon--standard-easing;
202 }
203
204 [data-event='sort'] {
205 cursor: pointer;
206 }
207
208 .#{$prefix}--table-sort__svg {
209 fill: $ui-05;
210 width: 8px;
211 height: 8px;
212 transform: rotate(0deg);
213 transition: transform 200ms $carbon--standard-easing;
214 }
215
216 .#{$prefix}--table-sort--ascending .#{$prefix}--table-sort__svg {
217 transform: rotate(180deg);
218 transition: transform 200ms $carbon--standard-easing;
219 }
220
221 .#{$prefix}--table-select {
222 @include reset;
223 width: rem(30px);
224 text-align: center;
225 padding-left: 0;
226 padding-right: 0;
227
228 .#{$prefix}--checkbox-label {
229 display: inline-flex;
230 margin: 0;
231
232 @media all and (min--moz-device-pixel-ratio: 0) and (min-resolution: 3e1dpcm) {
233 margin-top: 2px;
234 }
235 }
236
237 .#{$prefix}--checkbox-appearance {
238 margin: 0;
239 }
240 }
241
242 .#{$prefix}--table-overflow {
243 width: rem(40px);
244 text-align: center;
245
246 .#{$prefix}--overflow-menu {
247 padding: 0;
248 }
249 }
250 }
251}
252
253@include exports('data-table') {
254 @if not(feature-flag-enabled('breaking-changes-x')) {
255 @include data-table;
256 }
257}