@db-ux/core-components 4.7.0-tabs-34782eb → 4.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,25 +4,37 @@
4
4
  @use "../../styles/internal/db-puls";
5
5
  @use "@db-ux/core-foundations/build/styles/helpers";
6
6
 
7
- $pulse-gap-offset: calc(
8
- #{variables.$db-border-width-xs} + #{variables.$db-spacing-fixed-2xs}
9
- );
7
+ $max-tabs: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
8
+
9
+ %angular-workaround {
10
+ db-tab-list,
11
+ dbtablist {
12
+ @each $index in $max-tabs {
13
+ &:has([id$="-tab-#{$index}"]:checked) {
14
+ ~ dbtabpanel > [id$="-tab-panel-#{$index}"],
15
+ ~ db-tab-panel > [id$="-tab-panel-#{$index}"] {
16
+ @include helpers.display(block);
17
+ }
18
+ }
19
+ }
20
+ }
21
+ }
10
22
 
11
23
  %horizontal-pulse {
12
24
  .db-tab-item {
13
25
  @include db-puls.set-db-puls-horizontal;
14
26
 
15
- &::after {
16
- inset-block-end: calc(
17
- -1 * #{$pulse-gap-offset}
18
- ) !important; // overrides inset-block shorthand set in _db-puls.scss
19
- }
20
-
21
- &[aria-selected="true"] {
27
+ &:has(input:checked) {
22
28
  @include db-puls.show-db-puls-horizontal;
23
29
 
24
30
  &::after {
25
- inline-size: 100%;
31
+ inset-block-end: calc(
32
+ -1 *
33
+ (
34
+ #{variables.$db-spacing-fixed-2xs} +
35
+ #{variables.$db-border-width-xs}
36
+ )
37
+ );
26
38
  }
27
39
  }
28
40
  }
@@ -33,16 +45,12 @@ $pulse-gap-offset: calc(
33
45
  @include db-puls.set-db-puls-vertical;
34
46
 
35
47
  &::after {
36
- inset-inline: calc(-1 * var(--db-tabs-line-gap-vertical, 0px)) auto;
37
- z-index: 5;
48
+ inset-inline-start: 0;
49
+ z-index: -2;
38
50
  }
39
51
 
40
- &[aria-selected="true"] {
52
+ &:has(input:checked) {
41
53
  @include db-puls.show-db-puls-vertical;
42
-
43
- &::after {
44
- block-size: 100%;
45
- }
46
54
  }
47
55
  }
48
56
  }
@@ -54,291 +62,303 @@ $pulse-gap-offset: calc(
54
62
  position: absolute;
55
63
  }
56
64
 
65
+ @mixin angular-button-workaround() {
66
+ > .db-button,
67
+ &:is(.db-button) {
68
+ @content;
69
+ }
70
+ }
71
+
57
72
  .db-tabs {
58
73
  $db-tabs-z-index-tab-list: 20;
74
+ $db-tabs-z-index-button-background: 21;
75
+ $db-tabs-z-index-button: 22;
59
76
 
77
+ @extend %angular-workaround;
60
78
  @include helpers.display(flex);
61
79
 
62
80
  inline-size: 100%;
63
81
  position: relative;
64
82
 
65
83
  .db-tab-panel {
66
- padding: variables.$db-spacing-fixed-xs;
67
- position: relative;
68
- z-index: 1;
84
+ padding: 0 variables.$db-spacing-fixed-xs;
69
85
  }
70
86
 
71
87
  .db-tab-list {
72
- position: relative;
88
+ max-inline-size: 100%;
73
89
  z-index: $db-tabs-z-index-tab-list;
74
90
 
75
- db-tab-item,
76
- dbtabitem {
77
- display: contents;
91
+ @each $index in $max-tabs {
92
+ &:has([id$="-tab-#{$index}"]:checked)
93
+ ~ [id$="-tab-panel-#{$index}"] {
94
+ @include helpers.display(block);
95
+ }
78
96
  }
79
97
  }
80
98
 
99
+ .db-tab-item {
100
+ @extend %db-puls;
101
+ }
102
+
103
+ /*
104
+ Variant Orientation HORIZONTAL
105
+ */
81
106
  &:not([data-orientation="vertical"]) {
82
107
  flex-flow: column wrap;
83
108
 
84
- .db-tab-list {
85
- padding: variables.$db-spacing-fixed-xs
86
- variables.$db-spacing-fixed-xs 0 variables.$db-spacing-fixed-xs;
87
-
88
- @extend %horizontal-pulse;
109
+ .db-tab-panel {
110
+ inline-size: 100%;
111
+ }
89
112
 
90
- background-image: linear-gradient(
91
- colors.$db-adaptive-bg-basic-transparent-semi-default,
92
- colors.$db-adaptive-bg-basic-transparent-semi-default
93
- );
94
- background-position: left bottom;
95
- background-repeat: no-repeat;
113
+ .db-tab-list {
114
+ /* horizontal track for pulse */
115
+ &::before {
116
+ @extend %pulse-track;
96
117
 
97
- // Draw baseline flush with the first and last tab-item (content-box excludes padding).
98
- background-origin: content-box;
99
- background-size: 100% variables.$db-border-width-xs;
118
+ block-size: variables.$db-border-width-xs;
119
+ inset-inline: variables.$db-spacing-fixed-xs;
100
120
 
101
- .db-tab-item {
102
- // stylelint-disable-next-line db-ux/use-spacings
103
- margin-block-end: $pulse-gap-offset;
121
+ /* top position equals sum of: margin xs + padding xs + line-height + padding xs + margin 2xs */
122
+ inset-block-start: calc(
123
+ 3 * #{variables.$db-spacing-fixed-xs} +
124
+ #{variables.$db-spacing-fixed-2xs} +
125
+ #{form-components.$font-size-height}
126
+ );
104
127
  }
105
128
 
106
- &[role="tablist"],
107
- .db-tab-list {
108
- display: flex;
109
- align-items: stretch;
110
- overflow: auto;
129
+ > ul {
130
+ @extend %horizontal-pulse;
131
+
132
+ overflow: auto hidden;
111
133
  inline-size: 100%;
134
+
135
+ .db-tab-item {
136
+ margin-block: variables.$db-spacing-fixed-xs
137
+ calc(
138
+ 2 * #{variables.$db-spacing-fixed-2xs} +
139
+ #{variables.$db-border-width-xs}
140
+ );
141
+ }
142
+
143
+ db-tab-item,
144
+ dbtabitem {
145
+ &:first-of-type {
146
+ .db-tab-item {
147
+ margin-inline-start: variables.$db-spacing-fixed-xs;
148
+ }
149
+ }
150
+
151
+ &:last-of-type {
152
+ .db-tab-item {
153
+ margin-inline-end: variables.$db-spacing-fixed-xs;
154
+ }
155
+ }
156
+ }
157
+
158
+ &:not(:has(db-tab-item, dbtabitem)) {
159
+ .db-tab-item {
160
+ &:first-of-type {
161
+ margin-inline-start: variables.$db-spacing-fixed-xs;
162
+ }
163
+
164
+ &:last-of-type {
165
+ margin-inline-end: variables.$db-spacing-fixed-xs;
166
+ }
167
+ }
168
+ }
112
169
  }
113
170
  }
114
171
  }
115
172
 
173
+ /*
174
+ Variant Orientation VERTICAL
175
+ */
116
176
  &[data-orientation="vertical"] {
117
177
  flex-direction: row;
118
178
 
179
+ .db-tab-panel {
180
+ padding: variables.$db-spacing-fixed-xs 0;
181
+ }
182
+
119
183
  .db-tab-list {
120
- --db-tabs-line-gap-vertical: #{$pulse-gap-offset};
184
+ $width: var(
185
+ --db-tab-list-vertical-width,
186
+ #{variables.$db-sizing-3xl}
187
+ );
121
188
 
122
189
  /*
123
190
  min and nominal size must both be set to ensure
124
191
  - min-inline-size: tab-list is not displayed narrower than defined
125
192
  - max-inline-size: tab-list is not displayed wider than defined
126
193
  */
127
- min-inline-size: variables.$db-sizing-3xl;
128
- max-inline-size: variables.$db-sizing-3xl;
129
- // stylelint-disable-next-line db-ux/use-spacings
130
- padding-inline: variables.$db-spacing-fixed-xs
131
- var(--db-tabs-line-gap-vertical);
194
+ /* stylelint-disable-next-line db-ux/use-sizing */
195
+ min-inline-size: $width;
196
+ /* stylelint-disable-next-line db-ux/use-sizing */
197
+ max-inline-size: $width;
198
+
199
+ /* horizontal space to the tab panels */
200
+ padding-inline-end: variables.$db-spacing-fixed-xs;
201
+
202
+ /* ensures that tab-list (track) is only as high as all the tab-items together if open tab-panel is higher */
132
203
  margin-block-end: auto;
133
204
 
134
- @extend %vertical-pulse;
205
+ .db-tab-item {
206
+ label {
207
+ position: relative;
208
+ }
209
+
210
+ &:has(input:focus-visible),
211
+ &:hover {
212
+ inline-size: fit-content;
213
+
214
+ label {
215
+ overflow: visible;
216
+ }
217
+ }
218
+ }
135
219
 
220
+ /* vertical track for pulse */
136
221
  &::before {
137
222
  @extend %pulse-track;
138
223
 
139
- display: block;
140
- inset-inline-start: 0;
141
- inset-block: 0;
142
224
  inline-size: variables.$db-border-width-xs;
143
- z-index: 1;
225
+ inset-block: variables.$db-spacing-fixed-xs;
226
+ inset-inline-start: 0;
144
227
  }
145
228
 
146
- &[role="tablist"],
147
- .db-tab-list {
148
- display: flex;
229
+ > ul {
230
+ @extend %vertical-pulse;
231
+
149
232
  flex-direction: column;
150
- align-items: flex-start;
151
- }
152
- }
153
- }
233
+ block-size: 100%;
154
234
 
155
- &[data-tab-item-width="full"] {
156
- .db-tab-list {
157
- inline-size: 100%;
235
+ &:not(:has(db-tab-item, dbtabitem)) {
236
+ .db-tab-item {
237
+ &:first-of-type {
238
+ margin-block-start: variables.$db-spacing-fixed-xs;
239
+ }
240
+
241
+ &:last-of-type {
242
+ margin-block-end: variables.$db-spacing-fixed-xs;
243
+ }
244
+ }
245
+ }
246
+ }
158
247
  }
159
248
 
160
249
  .db-tab-item {
161
- flex: 1 0 0;
162
- inline-size: 0;
163
- max-inline-size: none;
164
- justify-content: flex-start;
165
- }
250
+ $padding-start-calc: calc(
251
+ #{variables.$db-border-width-xs} +
252
+ #{variables.$db-spacing-fixed-2xs}
253
+ );
166
254
 
167
- &[data-tab-item-alignment="center"] .db-tab-item {
168
- text-align: center;
169
- justify-content: center;
170
- }
255
+ padding-inline-start: $padding-start-calc;
171
256
 
172
- &[data-tab-item-alignment="end"] .db-tab-item {
173
- text-align: end;
174
- justify-content: end;
257
+ input {
258
+ padding-inline-start: $padding-start-calc;
259
+ }
175
260
  }
176
- }
177
-
178
- &[data-scroll-behavior="scrollbar"] {
179
- $db-tabs-z-index-track: 19;
180
261
 
181
- &:not([data-orientation="vertical"]) {
182
- // Keep the track outside the scrolling tab-list so the native scrollbar cannot cover it.
183
- &::before {
184
- content: "";
185
- position: absolute;
186
- z-index: $db-tabs-z-index-track;
187
- inset-block-start: calc(
188
- #{variables.$db-sizing-md} +
189
- #{variables.$db-spacing-fixed-xs} +
190
- #{variables.$db-border-width-xs}
191
- );
192
- inset-inline: variables.$db-spacing-fixed-xs;
193
- block-size: variables.$db-border-width-xs;
194
- background-color: colors.$db-adaptive-bg-basic-transparent-semi-default;
195
- pointer-events: none;
262
+ db-tab-item,
263
+ dbtabitem {
264
+ &:first-of-type {
265
+ .db-tab-item {
266
+ margin-block-start: variables.$db-spacing-fixed-xs;
267
+ }
196
268
  }
197
269
 
198
- [data-density="functional"] &::before {
199
- inset-block-start: calc(
200
- #{variables.$db-sizing-sm} +
201
- #{variables.$db-spacing-fixed-xs} +
202
- #{variables.$db-border-width-xs}
203
- );
270
+ &:last-of-type {
271
+ .db-tab-item {
272
+ margin-block-end: variables.$db-spacing-fixed-xs;
273
+ }
204
274
  }
275
+ }
276
+ }
205
277
 
206
- [data-density="expressive"] &::before {
207
- inset-block-start: calc(
208
- #{variables.$db-sizing-lg} +
209
- #{variables.$db-spacing-fixed-xs} +
210
- #{variables.$db-border-width-xs}
211
- );
212
- }
278
+ &[data-width="full"] {
279
+ .db-tab-list {
280
+ inline-size: 100%;
281
+ }
213
282
 
214
- .db-tab-list {
215
- background-image: none;
283
+ .db-tab-item,
284
+ .db-tab-item label {
285
+ inline-size: 100%;
286
+ }
216
287
 
217
- &::before {
218
- content: none;
219
- }
288
+ &[data-alignment="center"] {
289
+ .db-tab-item label {
290
+ text-align: center;
291
+ justify-content: center;
220
292
  }
221
293
  }
222
294
  }
223
295
 
224
296
  &[data-scroll-behavior="arrows"] {
225
- $db-tabs-z-index-button-background: 21;
226
- $db-tabs-z-index-button: 22;
227
- $db-tabs-z-index-track: 19;
228
-
229
- .db-tab-list::-webkit-scrollbar {
230
- display: none;
297
+ .db-tab-list {
298
+ > ul {
299
+ &::-webkit-scrollbar {
300
+ display: none;
301
+ }
302
+ }
231
303
  }
232
304
 
233
- &:not([data-orientation="vertical"]) {
234
- // Track für Arrow-Buttons-Modus als ::before Pseudo-Element auf .db-tabs
305
+ &:has(.tabs-scroll-left) {
235
306
  &::before {
236
307
  content: "";
237
- position: absolute;
238
- z-index: $db-tabs-z-index-track;
239
- inset-block-start: calc(
240
- #{variables.$db-sizing-md} +
241
- #{variables.$db-border-width-2xs}
242
- );
243
- inset-inline: 0;
244
- block-size: variables.$db-border-width-xs;
245
- background-color: colors.$db-adaptive-bg-basic-transparent-semi-default;
246
308
  }
309
+ }
247
310
 
248
- [data-density="functional"] &::before {
249
- inset-block-start: calc(
250
- #{variables.$db-sizing-sm} +
251
- #{variables.$db-border-width-2xs}
252
- );
311
+ &:has(.tabs-scroll-right) {
312
+ &::after {
313
+ content: "";
253
314
  }
315
+ }
254
316
 
255
- [data-density="expressive"] &::before {
256
- inset-block-start: calc(
257
- #{variables.$db-sizing-lg} +
258
- #{variables.$db-border-width-2xs}
317
+ &:has(.db-button) {
318
+ &::before,
319
+ &::after {
320
+ position: absolute;
321
+ z-index: $db-tabs-z-index-button-background;
322
+ background-color: colors.$db-adaptive-bg-basic-level-1-default;
323
+ inline-size: variables.$db-sizing-md;
324
+ block-size: calc(
325
+ #{variables.$db-spacing-fixed-sm} +
326
+ #{variables.$db-sizing-md}
259
327
  );
328
+ flex: 0 0 auto;
260
329
  }
261
330
 
262
- .db-tab-list {
263
- // stylelint-disable-next-line db-ux/use-spacings
264
- padding: 0 0 $pulse-gap-offset;
265
- margin-block-start: 0;
266
- background-image: none;
267
-
268
- &::before {
269
- content: none;
270
- }
271
-
272
- .db-tab-item {
273
- margin-block-end: 0;
274
-
275
- &::after {
276
- inset-block-end: calc(
277
- -1 *
278
- (
279
- #{variables.$db-spacing-fixed-xs} -
280
- #{variables.$db-border-width-2xs}
281
- )
282
- ) !important;
283
- }
284
- }
331
+ &::before {
332
+ inset-inline-start: 0;
285
333
  }
286
334
 
287
- .tabs-scroll-start,
288
- .tabs-scroll-end {
289
- position: absolute;
290
- z-index: $db-tabs-z-index-button;
291
- inset-block-start: 0;
292
- aspect-ratio: unset;
293
- min-block-size: unset;
294
- border-block-width: 0;
295
- padding-block: variables.$db-spacing-fixed-xs
296
- calc(
297
- #{variables.$db-spacing-fixed-xs} + #{$pulse-gap-offset}
298
- );
299
- align-items: flex-start;
300
- background-color: colors.$db-adaptive-bg-basic-level-1-default;
301
-
302
- @include helpers.hover {
303
- background-color: colors.$db-adaptive-bg-basic-level-1-hovered;
304
- }
305
-
306
- @include helpers.active {
307
- background-color: colors.$db-adaptive-bg-basic-level-1-pressed;
308
- }
309
-
310
- @media screen and (forced-colors: active) {
311
- border-block: variables.$db-border-width-xs solid
312
- transparent;
313
- inset-block-start: calc(
314
- -1 * #{variables.$db-border-width-xs}
315
- );
316
- }
317
-
318
- [data-density="functional"] & {
319
- padding-block: variables.$db-spacing-fixed-2xs
320
- calc(
321
- #{variables.$db-spacing-fixed-2xs} +
322
- #{$pulse-gap-offset}
323
- );
324
- }
325
-
326
- [data-density="expressive"] & {
327
- padding-block: variables.$db-spacing-fixed-sm
328
- calc(
329
- #{variables.$db-spacing-fixed-sm} +
330
- #{$pulse-gap-offset}
331
- );
332
- }
335
+ &::after {
336
+ inset-inline-end: 0;
333
337
  }
338
+ }
334
339
 
335
- .tabs-scroll-start {
340
+ /*
341
+ * Scroll left / right buttons
342
+ */
343
+ .tabs-scroll-left {
344
+ @include angular-button-workaround {
336
345
  inset-inline-start: 0;
337
346
  }
347
+ }
338
348
 
339
- .tabs-scroll-end {
349
+ .tabs-scroll-right {
350
+ @include angular-button-workaround {
340
351
  inset-inline-end: 0;
341
352
  }
342
353
  }
354
+
355
+ .tabs-scroll-left,
356
+ .tabs-scroll-right {
357
+ @include angular-button-workaround {
358
+ position: absolute;
359
+ z-index: $db-tabs-z-index-button;
360
+ inset-block: variables.$db-spacing-fixed-xs;
361
+ }
362
+ }
343
363
  }
344
364
  }