From 8f3ed303b9e3604e968393b8cfb8318eaf878388 Mon Sep 17 00:00:00 2001 From: MishaZhem Date: Fri, 16 Aug 2024 13:26:10 +0300 Subject: [PATCH] chore: add tabs --- .../src/components/app/app.routes.ts | 42 +++++++------------ .../dashboards/dashboards.component.html | 16 ++++++- .../dashboards/dashboards.component.ts | 9 ++++ 3 files changed, 38 insertions(+), 29 deletions(-) diff --git a/apps/taiga-lumbermill/src/components/app/app.routes.ts b/apps/taiga-lumbermill/src/components/app/app.routes.ts index 614985c4b..a409f823d 100644 --- a/apps/taiga-lumbermill/src/components/app/app.routes.ts +++ b/apps/taiga-lumbermill/src/components/app/app.routes.ts @@ -38,7 +38,19 @@ export const appRoutes: Route[] = [ import('../../dashboards/space-zoo/space-zoo.component').then( (mod) => mod.SpaceZooComponent, ), - data: {title: 'Space zoo'}, + data: { + title: 'Space zoo', + links: [ + { + name: 'Main', + to: 'space-zoo', + }, + { + name: 'Table', + to: 'space-zoo/table', + }, + ], + }, children: [ { path: '', @@ -46,39 +58,13 @@ export const appRoutes: Route[] = [ import( '../../dashboards/space-zoo/components/administrator/administrator.component' ).then((mod) => mod.AdministratorComponent), - data: { - title: 'Space zoo', - links: [ - { - name: 'Main', - to: 'dashboards/space-zoo/', - }, - { - name: 'Table', - to: 'dashboards/table/', - }, - ], - }, }, { - path: '/table', + path: 'table', loadComponent: async () => import( '../../dashboards/space-zoo/components/table/table.component' ).then((mod) => mod.TableComponent), - data: { - title: 'Space zoo', - links: [ - { - name: 'Main', - to: 'dashboards/space-zoo/', - }, - { - name: 'Table', - to: 'dashboards/table/', - }, - ], - }, }, ], }, diff --git a/apps/taiga-lumbermill/src/dashboards/dashboards/dashboards.component.html b/apps/taiga-lumbermill/src/dashboards/dashboards/dashboards.component.html index a81d5ab30..705d630ee 100644 --- a/apps/taiga-lumbermill/src/dashboards/dashboards/dashboards.component.html +++ b/apps/taiga-lumbermill/src/dashboards/dashboards/dashboards.component.html @@ -3,6 +3,7 @@ [style.position]="'sticky'" > @let title = (data$ | async) ?? ''; + @let links = (links$ | async) ?? []; Back @@ -11,6 +12,19 @@ {{ title }} dashboard -
+ + @for (link of links; track $index) { + + } + diff --git a/apps/taiga-lumbermill/src/dashboards/dashboards/dashboards.component.ts b/apps/taiga-lumbermill/src/dashboards/dashboards/dashboards.component.ts index 74e189582..f8fcec3f8 100644 --- a/apps/taiga-lumbermill/src/dashboards/dashboards/dashboards.component.ts +++ b/apps/taiga-lumbermill/src/dashboards/dashboards/dashboards.component.ts @@ -8,6 +8,7 @@ import { RouterOutlet, } from '@angular/router'; import {TuiIcon, TuiSurface, TuiTitle} from '@taiga-ui/core'; +import {TuiFade, TuiTabs} from '@taiga-ui/kit'; import {TuiCardLarge, TuiHeader, TuiNavigation} from '@taiga-ui/layout'; import {filter, map, startWith} from 'rxjs'; @@ -20,11 +21,13 @@ import {filter, map, startWith} from 'rxjs'; RouterLink, RouterOutlet, TuiCardLarge, + TuiFade, TuiHeader, TuiIcon, TuiIcon, TuiNavigation, TuiSurface, + TuiTabs, TuiTitle, ], templateUrl: './dashboards.component.html', @@ -37,4 +40,10 @@ export class DashboardsComponent { map((event) => event.snapshot.firstChild?.data['title']), startWith(this.activatedRoute.snapshot.firstChild?.data['title']), ); + + protected links$ = inject(Router).events.pipe( + filter((e): e is ActivationEnd => e instanceof ActivationEnd), + map((event) => event.snapshot.firstChild?.data['links']), + startWith(this.activatedRoute.snapshot.firstChild?.data['links']), + ); }