Skip to content

Commit 3e41a1d

Browse files
authored
feat(tabs): active tab underline transition (#DS-2935) (#343)
1 parent f6c5eed commit 3e41a1d

File tree

6 files changed

+39
-15
lines changed

6 files changed

+39
-15
lines changed

packages/components/tabs/_tabs-common.scss

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,6 @@
7979
bottom: -10px;
8080
}
8181

82-
&.kbq-tab-label_underlined:not(.kbq-tab-label_vertical).kbq-selected:after {
83-
content: '';
84-
position: absolute;
85-
left: 0;
86-
right: 0;
87-
bottom: -10px;
88-
height: 3px;
89-
border-radius: 2px 2px 0 0;
90-
background: rgba(33, 34, 44, 1);
91-
}
92-
9382
&.kbq-tab-label_vertical {
9483
justify-content: flex-start;
9584

packages/components/tabs/tab-header.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ export class KbqTabHeader extends KbqPaginatedTabHeader {
6060
@ViewChild('nextPaginator') nextPaginator: ElementRef<HTMLElement>;
6161
@ViewChild('previousPaginator') previousPaginator: ElementRef<HTMLElement>;
6262

63+
get activeTabOffsetWidth() {
64+
return this.items.get(this.selectedIndex)?.elementRef?.nativeElement?.offsetWidth + 'px';
65+
}
66+
67+
get activeTabOffsetLeft() {
68+
return this.items.get(this.selectedIndex)?.elementRef?.nativeElement?.offsetLeft + 'px';
69+
}
70+
6371
constructor(
6472
readonly elementRef: ElementRef,
6573
readonly changeDetectorRef: ChangeDetectorRef,

packages/components/tabs/tab-header.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
>
2222
<div class="kbq-tab-list__content">
2323
<ng-content />
24+
<div
25+
class="kbq-tab-list__active-tab-underline"
26+
[ngStyle]="{
27+
width: activeTabOffsetWidth,
28+
left: activeTabOffsetLeft
29+
}"
30+
></div>
2431
</div>
2532
</div>
2633
</div>

packages/components/tabs/tab-header.scss

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525
}
2626

2727
.kbq-tab-header_underlined:not(.kbq-tab-header_vertical) .kbq-tab-list__content {
28-
position: relative;
2928
padding: 8px 0;
3029
}
3130

32-
.kbq-tab-header_underlined:not(.kbq-tab-header_vertical) .kbq-tab-list__content:after {
31+
.kbq-tab-header_underlined:not(.kbq-tab-header_vertical):after {
3332
content: '';
3433
position: absolute;
3534
left: 0;
@@ -39,6 +38,20 @@
3938
background: rgba(13, 14, 18, 0.12);
4039
}
4140

41+
.kbq-tab-list__active-tab-underline {
42+
display: none;
43+
}
44+
45+
.kbq-tab-header_underlined:not(.kbq-tab-header_vertical) .kbq-tab-list__active-tab-underline {
46+
display: block;
47+
position: absolute;
48+
bottom: 0;
49+
height: 3px;
50+
border-radius: 2px 2px 0 0;
51+
background: rgba(33, 34, 44, 1);
52+
transition: all 0.2s ease-in-out;
53+
}
54+
4255
.kbq-tab-header__pagination {
4356
@include vendor-prefixes.user-select(none);
4457

packages/components/tabs/tabs.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { A11yModule } from '@angular/cdk/a11y';
22
import { PortalModule } from '@angular/cdk/portal';
33
import { CdkScrollableModule } from '@angular/cdk/scrolling';
4+
import { NgStyle } from '@angular/common';
45
import { NgModule } from '@angular/core';
56
import { KbqCommonModule } from '@koobiq/components/core';
67
import { KbqIconModule } from '@koobiq/components/icon';
@@ -28,7 +29,8 @@ import { KbqTab } from './tab.component';
2829
CdkScrollableModule,
2930
KbqCommonModule,
3031
KbqIconModule,
31-
KbqToolTipModule
32+
KbqToolTipModule,
33+
NgStyle
3234
],
3335
// Don't export all components because some are only to be used internally.
3436
exports: [

tools/public_api_guard/components/tabs.api.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import * as i11 from '@angular/cdk/scrolling';
2929
import * as i12 from '@koobiq/components/core';
3030
import * as i13 from '@koobiq/components/icon';
3131
import * as i14 from '@koobiq/components/tooltip';
32+
import * as i15 from '@angular/common';
3233
import * as i9 from '@angular/cdk/portal';
3334
import { InjectionToken } from '@angular/core';
3435
import { NgZone } from '@angular/core';
@@ -255,6 +256,10 @@ export const KbqTabGroupMixinBase: CanDisableCtor & typeof KbqTabGroupBase;
255256
export class KbqTabHeader extends KbqPaginatedTabHeader {
256257
constructor(elementRef: ElementRef, changeDetectorRef: ChangeDetectorRef, viewportRuler: ViewportRuler, ngZone: NgZone, platform: Platform, dir: Directionality, animationMode?: string);
257258
// (undocumented)
259+
get activeTabOffsetLeft(): string;
260+
// (undocumented)
261+
get activeTabOffsetWidth(): string;
262+
// (undocumented)
258263
readonly changeDetectorRef: ChangeDetectorRef;
259264
// (undocumented)
260265
readonly elementRef: ElementRef;
@@ -383,7 +388,7 @@ export class KbqTabsModule {
383388
// Warning: (ae-forgotten-export) The symbol "i8" needs to be exported by the entry point index.d.ts
384389
//
385390
// (undocumented)
386-
static ɵmod: i0.ɵɵNgModuleDeclaration<KbqTabsModule, [typeof i1.KbqTabGroup, typeof i2.KbqTabLabel, typeof i3.KbqTab, typeof i4.KbqTabLabelWrapper, typeof i5.KbqTabNav, typeof i5.KbqTabLink, typeof i6.KbqTabBody, typeof i6.KbqTabBodyPortal, typeof i7.KbqTabHeader, typeof i8.KbqTabContent, typeof i1.KbqAlignTabsCenterCssStyler, typeof i1.KbqAlignTabsEndCssStyler, typeof i1.KbqStretchTabsCssStyler, typeof i1.KbqUnderlinedTabsCssStyler, typeof i1.KbqVerticalTabsCssStyler], [typeof i9.PortalModule, typeof i10.A11yModule, typeof i11.CdkScrollableModule, typeof i12.KbqCommonModule, typeof i13.KbqIconModule, typeof i14.KbqToolTipModule], [typeof i12.KbqCommonModule, typeof i1.KbqTabGroup, typeof i2.KbqTabLabel, typeof i3.KbqTab, typeof i5.KbqTabNav, typeof i5.KbqTabLink, typeof i8.KbqTabContent, typeof i1.KbqAlignTabsCenterCssStyler, typeof i1.KbqAlignTabsEndCssStyler, typeof i1.KbqStretchTabsCssStyler, typeof i1.KbqUnderlinedTabsCssStyler, typeof i1.KbqVerticalTabsCssStyler]>;
391+
static ɵmod: i0.ɵɵNgModuleDeclaration<KbqTabsModule, [typeof i1.KbqTabGroup, typeof i2.KbqTabLabel, typeof i3.KbqTab, typeof i4.KbqTabLabelWrapper, typeof i5.KbqTabNav, typeof i5.KbqTabLink, typeof i6.KbqTabBody, typeof i6.KbqTabBodyPortal, typeof i7.KbqTabHeader, typeof i8.KbqTabContent, typeof i1.KbqAlignTabsCenterCssStyler, typeof i1.KbqAlignTabsEndCssStyler, typeof i1.KbqStretchTabsCssStyler, typeof i1.KbqUnderlinedTabsCssStyler, typeof i1.KbqVerticalTabsCssStyler], [typeof i9.PortalModule, typeof i10.A11yModule, typeof i11.CdkScrollableModule, typeof i12.KbqCommonModule, typeof i13.KbqIconModule, typeof i14.KbqToolTipModule, typeof i15.NgStyle], [typeof i12.KbqCommonModule, typeof i1.KbqTabGroup, typeof i2.KbqTabLabel, typeof i3.KbqTab, typeof i5.KbqTabNav, typeof i5.KbqTabLink, typeof i8.KbqTabContent, typeof i1.KbqAlignTabsCenterCssStyler, typeof i1.KbqAlignTabsEndCssStyler, typeof i1.KbqStretchTabsCssStyler, typeof i1.KbqUnderlinedTabsCssStyler, typeof i1.KbqVerticalTabsCssStyler]>;
387392
}
388393

389394
// @public (undocumented)

0 commit comments

Comments
 (0)