diff --git a/projects/demo/src/modules/components/tabs/examples/5/index.html b/projects/demo/src/modules/components/tabs/examples/5/index.html index f7a0ddba48d4..982108f22729 100644 --- a/projects/demo/src/modules/components/tabs/examples/5/index.html +++ b/projects/demo/src/modules/components/tabs/examples/5/index.html @@ -1,4 +1,5 @@ diff --git a/projects/demo/src/modules/components/tabs/examples/6/index.html b/projects/demo/src/modules/components/tabs/examples/6/index.html index d7f652f2f354..e79fff382b4a 100644 --- a/projects/demo/src/modules/components/tabs/examples/6/index.html +++ b/projects/demo/src/modules/components/tabs/examples/6/index.html @@ -50,6 +50,7 @@

diff --git a/projects/demo/src/modules/components/tabs/examples/import/import-module.md b/projects/demo/src/modules/components/tabs/examples/import/import.md similarity index 100% rename from projects/demo/src/modules/components/tabs/examples/import/import-module.md rename to projects/demo/src/modules/components/tabs/examples/import/import.md diff --git a/projects/demo/src/modules/components/tabs/examples/import/insert-template.md b/projects/demo/src/modules/components/tabs/examples/import/template.md similarity index 100% rename from projects/demo/src/modules/components/tabs/examples/import/insert-template.md rename to projects/demo/src/modules/components/tabs/examples/import/template.md diff --git a/projects/demo/src/modules/components/tabs/tabs.component.ts b/projects/demo/src/modules/components/tabs/tabs.component.ts index 5254e00bdd89..4e5195ca1494 100644 --- a/projects/demo/src/modules/components/tabs/tabs.component.ts +++ b/projects/demo/src/modules/components/tabs/tabs.component.ts @@ -1,6 +1,7 @@ import {Component} from '@angular/core'; import {changeDetection} from '@demo/emulate/change-detection'; import {tuiDocExampleOptionsProvider} from '@taiga-ui/addon-doc'; +import type {TuiSizeL} from '@taiga-ui/core'; @Component({ selector: 'example-tui-tabs', @@ -11,8 +12,8 @@ import {tuiDocExampleOptionsProvider} from '@taiga-ui/addon-doc'; export class ExampleTuiTabsComponent { protected buttons = ['Button 1', 'Button 2', 'Button 3', 'Button 4']; - protected readonly import = import('./examples/import/import-module.md?raw'); - protected readonly template = import('./examples/import/insert-template.md?raw'); + protected readonly import = import('./examples/import/import.md?raw'); + protected readonly template = import('./examples/import/template.md?raw'); protected readonly moreContentVariants = ['', 'And more']; @@ -23,4 +24,8 @@ export class ExampleTuiTabsComponent { protected activeItemIndex = 0; protected itemsLimit = 999; + + protected sizes: readonly TuiSizeL[] = ['m', 'l']; + + protected size = this.sizes[1]; } diff --git a/projects/demo/src/modules/components/tabs/tabs.template.html b/projects/demo/src/modules/components/tabs/tabs.template.html index 677aefe06b25..2dc5d2c0b879 100644 --- a/projects/demo/src/modules/components/tabs/tabs.template.html +++ b/projects/demo/src/modules/components/tabs/tabs.template.html @@ -76,6 +76,7 @@ @@ -129,6 +130,15 @@ only + + Size + !!this.rla?.isActive), ); - protected readonly margin = inject(TUI_TAB_MARGIN); protected readonly sub = merge( this.observer || EMPTY, this.rla?.isActiveChange.pipe(filter(Boolean)) || EMPTY, diff --git a/projects/kit/components/tabs/tabs-horizontal.directive.ts b/projects/kit/components/tabs/tabs-horizontal.directive.ts index 0fb658e5b07f..8e937190ce0d 100644 --- a/projects/kit/components/tabs/tabs-horizontal.directive.ts +++ b/projects/kit/components/tabs/tabs-horizontal.directive.ts @@ -26,7 +26,7 @@ import {TUI_TABS_OPTIONS} from './tabs.options'; hostDirectives: [ { directive: TuiTabsDirective, - inputs: ['activeItemIndex'], + inputs: ['activeItemIndex', 'size'], outputs: ['activeItemIndexChange'], }, ], diff --git a/projects/kit/components/tabs/tabs-vertical.directive.ts b/projects/kit/components/tabs/tabs-vertical.directive.ts index 608f1d476519..81720a979091 100644 --- a/projects/kit/components/tabs/tabs-vertical.directive.ts +++ b/projects/kit/components/tabs/tabs-vertical.directive.ts @@ -9,7 +9,7 @@ import {TuiTabsDirective} from './tabs.directive'; hostDirectives: [ { directive: TuiTabsDirective, - inputs: ['activeItemIndex'], + inputs: ['activeItemIndex', 'size'], outputs: ['activeItemIndexChange'], }, ], diff --git a/projects/kit/components/tabs/tabs-with-more.component.ts b/projects/kit/components/tabs/tabs-with-more.component.ts index cc155383cae3..d046433bd9df 100644 --- a/projects/kit/components/tabs/tabs-with-more.component.ts +++ b/projects/kit/components/tabs/tabs-with-more.component.ts @@ -25,6 +25,7 @@ import { tuiPx, tuiToInt, } from '@taiga-ui/cdk'; +import type {TuiSizeL} from '@taiga-ui/core'; import {TuiDropdownModule, TuiSvgModule} from '@taiga-ui/core'; import {TUI_ARROW_OPTIONS} from '@taiga-ui/kit/components/arrow'; import {TUI_MORE_WORD} from '@taiga-ui/kit/tokens'; @@ -32,7 +33,7 @@ import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; import {PolymorpheusModule} from '@tinkoff/ng-polymorpheus'; import {filter, map, tap} from 'rxjs'; -import {TUI_TAB_MARGIN, TuiTabDirective} from './tab.directive'; +import {TuiTabDirective} from './tab.directive'; import {TUI_TABS_OPTIONS} from './tabs.options'; import {TUI_TABS_PROVIDERS, TUI_TABS_REFRESH} from './tabs.providers'; import {TuiTabsHorizontalDirective} from './tabs-horizontal.directive'; @@ -62,12 +63,14 @@ export class TuiTabsWithMoreComponent implements AfterViewChecked, AfterViewInit private readonly dir?: ElementRef; private readonly options = inject(TUI_TABS_OPTIONS); - private readonly margin = inject(TUI_TAB_MARGIN); private readonly refresh$ = inject(TUI_TABS_REFRESH); private readonly el: HTMLElement = inject(ElementRef).nativeElement; private readonly cdr = inject(ChangeDetectorRef); private maxIndex = Infinity; + @Input() + public size: TuiSizeL = this.options.size; + @Input() public moreContent: PolymorpheusContent; @@ -214,6 +217,10 @@ export class TuiTabsWithMoreComponent implements AfterViewChecked, AfterViewInit return index > this.lastVisibleIndex && this.isOverflown(index); } + private get margin(): number { + return this.size === 'l' ? 24 : 16; + } + private focusMore(): void { if (this.moreButton) { this.moreButton.nativeElement.focus(); diff --git a/projects/kit/components/tabs/tabs-with-more.style.less b/projects/kit/components/tabs/tabs-with-more.style.less index 6dd5360eb27b..4bd69b427b08 100644 --- a/projects/kit/components/tabs/tabs-with-more.style.less +++ b/projects/kit/components/tabs/tabs-with-more.style.less @@ -4,7 +4,6 @@ position: relative; display: flex; font: var(--tui-font-text-m); - height: var(--tui-height-l); box-sizing: border-box; color: var(--tui-text-02); box-shadow: inset 0 -1px var(--tui-base-03); @@ -12,16 +11,17 @@ } .t-tabs { - height: inherit; - font-size: inherit; - font-weight: inherit; + font: inherit; overflow: visible; box-shadow: none; color: inherit; } -.t-overflown { +.t-flex { display: flex; +} + +.t-overflown { margin: 0; width: 0; max-width: 0; @@ -67,6 +67,11 @@ background: var(--tui-clear); } } + + &[data-size='m'] ::ng-deep *[tuiTab] { + height: 2.25rem; + font: var(--tui-font-text-s); + } /* stylelint-enable */ } diff --git a/projects/kit/components/tabs/tabs-with-more.template.html b/projects/kit/components/tabs/tabs-with-more.template.html index 1e6c85d7e307..69dcae085a3c 100644 --- a/projects/kit/components/tabs/tabs-with-more.template.html +++ b/projects/kit/components/tabs/tabs-with-more.template.html @@ -2,6 +2,7 @@ -
+
@@ -46,6 +50,7 @@
diff --git a/projects/kit/components/tabs/tabs.directive.ts b/projects/kit/components/tabs/tabs.directive.ts index f76dc539ef25..a3f18537e85a 100644 --- a/projects/kit/components/tabs/tabs.directive.ts +++ b/projects/kit/components/tabs/tabs.directive.ts @@ -9,17 +9,25 @@ import { Output, } from '@angular/core'; import {tuiMoveFocus, tuiWithStyles} from '@taiga-ui/cdk'; +import type {TuiSizeL} from '@taiga-ui/core'; import {TUI_TAB_ACTIVATE} from './tab.directive'; import {TuiTabsComponent} from './tabs.component'; +import {TUI_TABS_OPTIONS} from './tabs.options'; @Directive({ standalone: true, selector: 'tui-tabs:is(never)', + host: { + '[attr.data-size]': 'size', + }, }) export class TuiTabsDirective implements AfterViewChecked { private readonly el: HTMLElement = inject(ElementRef).nativeElement; + @Input() + public size: TuiSizeL = inject(TUI_TABS_OPTIONS).size; + @Input() public activeItemIndex = 0; diff --git a/projects/kit/components/tabs/tabs.options.ts b/projects/kit/components/tabs/tabs.options.ts index b174ab94f490..d6a9c3d8c409 100644 --- a/projects/kit/components/tabs/tabs.options.ts +++ b/projects/kit/components/tabs/tabs.options.ts @@ -1,11 +1,13 @@ import type {Provider} from '@angular/core'; import {tuiCreateToken, tuiProvideOptions} from '@taiga-ui/cdk'; +import type {TuiSizeL} from '@taiga-ui/core'; export interface TuiTabsOptions { readonly exposeActive: boolean; readonly itemsLimit: number; readonly minMoreWidth: number; readonly underline: boolean | string; + readonly size: TuiSizeL; } export const TUI_TABS_DEFAULT_OPTIONS: TuiTabsOptions = { @@ -13,6 +15,7 @@ export const TUI_TABS_DEFAULT_OPTIONS: TuiTabsOptions = { exposeActive: true, itemsLimit: Infinity, minMoreWidth: 0, + size: 'l', }; /** diff --git a/projects/kit/components/tabs/tabs.style.less b/projects/kit/components/tabs/tabs.style.less index 959a64542a67..5075b35d189a 100644 --- a/projects/kit/components/tabs/tabs.style.less +++ b/projects/kit/components/tabs/tabs.style.less @@ -1,5 +1,67 @@ @import '@taiga-ui/core/styles/taiga-ui-local'; +[tuiTab] { + .transition(~'color, box-shadow, opacity, background'); + .clearbtn(); + + position: relative; + display: flex; + flex-shrink: 0; + box-sizing: border-box; + justify-content: space-between; + line-height: 1.5rem; + align-items: center; + white-space: nowrap; + cursor: pointer; + outline: none; + color: inherit; + /* stylelint-disable-next-line */ + margin-left: 24px; + + tui-tabs[data-size='m'] + &, + tui-tabs[data-size='m'] &, + [tuiTabs][data-size='m'] & { + margin-left: 16px; + font: var(--tui-font-text-s); + } + + &:disabled { + opacity: var(--tui-disabled-opacity); + pointer-events: none; + } + + &._active { + color: var(--tui-text-01); + box-shadow: none; + } + + &:focus-visible { + outline: 2px solid var(--tui-focus); + outline-offset: -2px; + } + + tui-tabs._underline &:hover:not(._active), + [tuiTabs]._underline &:hover:not(._active) { + box-shadow: inset 0 -2px var(--tui-base-03); + } + + tui-tabs > &:first-child, + [tuiTabs] > &:first-child, + tui-tabs > :not(.t-overflown) > &:first-child { + margin-left: 0; + } + + tui-tabs > [tuiTab] ~ :not(.t-overflown) > &:first-child { + margin-left: var(--tui-tab-margin, 1.5rem); + } + + @media (hover: hover) { + &:hover { + color: var(--tui-text-01); + } + } +} + [tuiTabs], tui-tabs { .scrollbar-hidden(); @@ -12,11 +74,14 @@ tui-tabs { overflow: auto; isolation: isolate; - // TODO: Sizes - &:not([data-vertical]) { + &[data-size='l']:not([data-vertical]) { height: var(--tui-height-l); } + &[data-size='m']:not([data-vertical]) { + height: var(--tui-height-m); + } + &:before { .transition(~'width, left'); @@ -70,6 +135,11 @@ tui-tabs[data-vertical], } } + &[data-size='m'] [tuiTab] { + min-height: 2.25rem; + font: var(--tui-font-text-s); + } + &[data-vertical='right'] { box-shadow: inset 1px 0 var(--tui-base-03); @@ -89,58 +159,3 @@ tui-tabs[data-vertical], } } } - -[tuiTab] { - .transition(~'color, box-shadow, opacity, background'); - .clearbtn(); - - position: relative; - display: flex; - flex-shrink: 0; - height: 100%; - box-sizing: border-box; - justify-content: space-between; - line-height: 1.5rem; - align-items: center; - white-space: nowrap; - cursor: pointer; - outline: none; - color: inherit; - margin-left: var(--tui-tab-margin, 1.5rem); - - &:disabled { - opacity: var(--tui-disabled-opacity); - pointer-events: none; - } - - &._active { - color: var(--tui-text-01); - box-shadow: none; - } - - &:focus-visible { - outline: 2px solid var(--tui-focus); - outline-offset: -2px; - } - - tui-tabs._underline &:hover:not(._active), - [tuiTabs]._underline &:hover:not(._active) { - box-shadow: inset 0 -2px var(--tui-base-03); - } - - tui-tabs > &:first-child, - [tuiTabs] > &:first-child, - tui-tabs > :not(.t-overflown) > &:first-child { - margin-left: 0; - } - - tui-tabs > [tuiTab] ~ :not(.t-overflown) > &:first-child { - margin-left: var(--tui-tab-margin, 1.5rem); - } - - @media (hover: hover) { - &:hover { - color: var(--tui-text-01); - } - } -}