Skip to content

Commit 4276aac

Browse files
mfranzkenmerget
andcommitted
refactor(tabs): integrate v2 design (#895)
* refactor(tabs): integrate v2 design closes db-ux-design-system/design-feedback#85 Co-Authored-By: Nicolas Merget <[email protected]> * refactor: corrected styling Co-Authored-By: Nicolas Merget <[email protected]> * feat: added icon * refactor: added small size * feat: added small items with icons * refactor: added correct color value * refactor: button vertical alignment * refactor: added pressed state * Update tab-bar.scss * refactor: simplification * Update tab-bar.scss * refactor: added missing parameter * refactor: add relevant comment * refactor: simply enabled multi-line content * style: feedback * refactor: we don't want to advertise for this one * style: adaptions out of feedback * refactor: corrected these declarations --------- Co-authored-by: Nicolas Merget <[email protected]>
1 parent e487b21 commit 4276aac

8 files changed

+71
-25
lines changed

source/_patterns/02-components/tab-bar/_tab-bar.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ state: complete
44
tags: [style-1.6]
55
---
66

7+
## Multi-line
8+
9+
The multi-line tabs haven't been developed, but are only available in the Sketch library. If you really need this pattern even also in the development, please set it up yourself e.g. with a `<br>` or differentiated label texts e.g. by `<span>` elements.
10+
711
## Accessibility
812

913
This pattern has been tested and approved regarding accessibility.

source/_patterns/02-components/tab-bar/_tab-bar.variables.scss

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ $tabBar-tabSection--backgroundColor: #fdfdfd !default; // TODO: This would need
55

66
$tabBar-tab-focus-outline: 1px dotted $db-color-cool-gray-400 !default;
77

8-
$tabBar-tab-hover-backgroundColor: $db-color-cool-gray-100 !default;
8+
// $db-color-cool-gray-100
9+
$tabBar-tab-hover-backgroundColor: #{$db-color-cool-gray-700} + "1F" !default;
10+
$tabBar-tab-pressed-backgroundColor: #{$db-color-cool-gray-700} + "3D" !default;
911
$tabBar-tab-active-border: #{to-rem(
1012
$pxValue: 1
1113
)} solid $db-color-cool-gray-500 !default;

source/_patterns/02-components/tab-bar/tab-bar.hbs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{{! TODO: evaluate on the correct role and aria-label in here }}
2-
<div class="cmp-tab-bar" role="tablist">
2+
<div class="cmp-tab-bar" role="tablist"{{#if size}} data-size="{{ size }}"{{/if }}>
33
<!-- Pay attention to use a component wide, but component instance specific name to the following input[type="radio"] elements //-->
44
{{#each tabs }}
5-
<input type="radio" name="cmp-tab-bar-tabs-01" id="radio_{{ @index }}" {{#if active }} checked{{/if }}{{#if disabled }}
5+
<input type="radio" name="cmp-tab-bar-tabs-{{ ../identifier }}" id="tab_{{ ../identifier }}_{{ @index }}" {{#if active }} checked{{/if }}{{#if disabled }}
66
disabled{{/if }}>
7-
<label for="radio_{{ @index }}" role="tab">{{ @index }}</label>
8-
<section id="content_{{ @index }}" role="tabpanel">
7+
<label for="tab_{{ ../identifier }}_{{ @index }}" role="tab"{{#if ../icon}} data-icon="{{ ../icon }}"{{/if }}>{{ label }}{{#if label2 }}<br>{{ label2 }}{{/if }}</label>
8+
<section id="content_{{ ../identifier }}_{{ @index }}" role="tabpanel">
99
{{ content }}
1010
</section>
1111
{{/each }}

source/_patterns/02-components/tab-bar/tab-bar.listitems.json source/_patterns/02-components/tab-bar/tab-bar.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"identifier": "regular",
23
"tabs": [
34
{
45
"label": "Tab 01",
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
11
@import "../../../css/partials.meta";
22
@import "tab-bar.variables";
3+
@import "../../00-base/icons/icons.helpers";
4+
5+
@mixin tab() {
6+
& > input[type="radio"],
7+
& > * > input[type="radio"] {
8+
@content;
9+
}
10+
}
311

412
.cmp-tab-bar {
513
display: flex;
614
flex-wrap: wrap;
715

8-
label[role="tab"],
9-
section[role="tabpanel"] {
10-
background-color: $tabBar-tabSection--backgroundColor;
11-
}
16+
gap: 0.25rem;
1217

13-
& > input[type="radio"],
14-
& > * > input[type="radio"] {
18+
@include tab() {
1519
@include a11y-visually-hidden($partial: $partial);
1620

1721
& + label[role="tab"] {
18-
border-top-left-radius: 4px;
19-
border-top-right-radius: 4px;
2022
cursor: pointer;
21-
display: inline-block;
22-
margin-left: to-rem($pxValue: 8);
23-
padding: #{to-rem($pxValue: 5)} #{to-rem($pxValue: 32)};
23+
display: flex;
24+
padding: 0.875rem $db-spacing-m;
2425
position: relative;
2526
z-index: 1;
27+
border-radius: 4px;
28+
align-items: center;
2629

27-
&:first-of-type {
28-
margin-left: to-rem($pxValue: 16);
30+
&::before {
31+
margin-inline-start: -0.125rem;
2932
}
3033
}
3134

@@ -39,6 +42,10 @@
3942
&:focus {
4043
background-color: $tabBar-tab-hover-backgroundColor;
4144
}
45+
46+
&:active {
47+
background-color: $tabBar-tab-pressed-backgroundColor;
48+
}
4249
}
4350
}
4451

@@ -55,25 +62,44 @@
5562

5663
&:checked {
5764
& + label[role="tab"] {
58-
border: $tabBar-tab-active-border;
59-
border-bottom: none;
6065
font-weight: 700;
61-
padding-top: to-rem($pxValue: 3);
62-
transform: translateY(to-rem($pxValue: 1));
6366

6467
& + section[role="tabpanel"] {
6568
display: initial;
6669
}
70+
71+
// Puls
72+
&::after {
73+
background-color: $db-color-red-500;
74+
border-radius: 5px;
75+
content: "";
76+
display: block;
77+
height: 0.25rem;
78+
inset-block-end: 0;
79+
inset-inline: 0;
80+
position: absolute;
81+
}
6782
}
6883
}
6984
}
7085

86+
label[role="tab"],
87+
section[role="tabpanel"] {
88+
background-color: $tabBar-tabSection--backgroundColor;
89+
}
90+
7191
section[role="tabpanel"] {
72-
border-top: $tabBar-tabpanel--borderTop;
73-
box-shadow: $tabBar-tabpanel--boxShadow;
7492
display: none;
7593
flex-basis: 100%;
7694
order: 1;
77-
padding: to-rem($pxValue: 46) to-rem($pxValue: 50);
95+
margin-block-start: 0.125rem;
96+
}
97+
98+
&[data-size="small"] {
99+
@include tab() {
100+
& + label[role="tab"] {
101+
padding-block: 0.625rem;
102+
}
103+
}
78104
}
79105
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"identifier": "small-icon",
3+
"icon": "account"
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"identifier": "icon",
3+
"icon": "account",
4+
"size": "small"
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"identifier": "small",
3+
"size": "small"
4+
}

0 commit comments

Comments
 (0)