diff --git a/webapp/src/app/modules/person/person.component.html b/webapp/src/app/modules/person/person.component.html index 362af283..1fd0a34b 100644 --- a/webapp/src/app/modules/person/person.component.html +++ b/webapp/src/app/modules/person/person.component.html @@ -132,20 +132,12 @@ [loading]="isTopicsLoading()" (tagClick)="onInterestingTagClick($event)"> - - @for (link of links(); track link.path) { - - {{ link.label }} - - } - + @if (this.links()) { + + } } @else { ; - disabled: boolean; -}; +import { + LinkTabNavBarComponent, + LinkTabNavBarItem, +} from '../../shared/ui/link-tab-nav-bar/link-tab-nav-bar.component'; +import { + COMPANY_CONNECTION_ICON, + FUNDING_ICON, + NETWORK_ICON, + NEWS_ICON, + OVERVIEW_ICON, + PATENT_ICON, + PROJECT_ICON, + PUBLICATION_ICON, +} from '../../shared/ui/icons'; @Component({ selector: 'app-person', @@ -55,6 +62,7 @@ type PersonLink = { LoadingComponent, CountryFlagComponent, CareerStageChipComponent, + LinkTabNavBarComponent, ], templateUrl: './person.component.html', styleUrl: './person.component.scss', @@ -69,6 +77,11 @@ export class PersonComponent { canFetchGdprRelevantData = input.required(); + protected readonly navBar = viewChild('navBar'); + protected readonly activeLink = computed( + () => this.navBar()?.activeLink() ?? null, + ); + constructor() { this.bookmarkService .load() @@ -236,11 +249,12 @@ export class PersonComponent { { initialValue: [] }, ); - readonly links = computed(() => { + readonly links = computed(() => { const links = [ { label: 'Übersicht', description: 'Übersicht über die Person', + icon: OVERVIEW_ICON, path: 'overview', disabled: false, }, @@ -249,6 +263,7 @@ export class PersonComponent { { label: 'Projekte', description: 'Übersicht der durchgeführten Projekte der Person', + icon: PROJECT_ICON, path: 'projects', queryParams: { page: 0, @@ -264,12 +279,13 @@ export class PersonComponent { { label: 'Publikationen', description: 'Übersicht der Publikationen der Person', + icon: PUBLICATION_ICON, path: 'publications', - disabled: false, }, { label: 'Netzwerk', description: 'Kooperationsnetzwerk der Person', + icon: NETWORK_ICON, path: 'network', disabled: false, queryParams: { @@ -284,6 +300,7 @@ export class PersonComponent { { label: 'Unternehmen', description: 'Unternehmen, mit denen die Person verbunden ist', + icon: COMPANY_CONNECTION_ICON, path: 'company-connections', disabled: false, }, @@ -292,18 +309,21 @@ export class PersonComponent { { label: 'Förderungen', description: 'Übersicht der Förderungen der Person', + icon: FUNDING_ICON, path: 'funding', disabled: false, }, { label: 'Nachrichten', description: 'Nachrichten über die Person', + icon: NEWS_ICON, path: 'news', disabled: false, }, { label: 'Patente', description: 'Patente der Person', + icon: PATENT_ICON, path: 'patents', disabled: false, }, @@ -311,25 +331,25 @@ export class PersonComponent { return links; }); - readonly activeLink = computed(() => { - const currentUrl = this.currentUrl(); - if (!currentUrl) { - return null; - } + // readonly activeLink = computed(() => { + // const currentUrl = this.currentUrl(); + // if (!currentUrl) { + // return null; + // } - for (const link of this.links()) { - const linkUrl = this.router - .createUrlTree([link.path], { - relativeTo: this.activatedRoute, - }) - .toString(); + // for (const link of this.links()) { + // const linkUrl = this.router + // .createUrlTree([link.path], { + // relativeTo: this.activatedRoute, + // }) + // .toString(); - if (linkUrl.startsWith(currentUrl) || currentUrl.startsWith(linkUrl)) { - return link; - } - } - return null; - }); + // if (linkUrl.startsWith(currentUrl) || currentUrl.startsWith(linkUrl)) { + // return link; + // } + // } + // return null; + // }); onInterestingTagClick(selection: { id: string; diff --git a/webapp/src/app/shared/ui/app-menu/app-menu.component.ts b/webapp/src/app/shared/ui/app-menu/app-menu.component.ts index fa0072f3..52d86a73 100644 --- a/webapp/src/app/shared/ui/app-menu/app-menu.component.ts +++ b/webapp/src/app/shared/ui/app-menu/app-menu.component.ts @@ -17,6 +17,21 @@ import { topicQueryParamKeys } from '../../../resolvers/topic-page.resolver'; import { SortDirection, TopicSortBy, WorkSortBy } from '../../../api'; import { workQueryParamKeys } from '../../../resolvers/work-page.resolver'; import { MatMenuModule } from '@angular/material/menu'; +import { + BOOKMARKS_ICON, + DASHBOARD_ICON, + INSTITUTION_ICON, + JOBS_ICON, + KEYWORDS_ICON, + MANAGE_ACCOUNTS_ICON, + NEWS_ICON, + ORGANIZATIONS_ICON, + PATENT_ICON, + PERSONS_ICON, + PROJECT_ICON, + PUBLICATION_ICON, + TOPIC_ICON, +} from '../icons'; type NavItem = { label: string; @@ -71,13 +86,13 @@ export class AppMenuComponent { const items: NavItem[] = [ { label: 'Dashboard', - icon: 'dashboard', + icon: DASHBOARD_ICON, route: '/dashboard', disabled: false, }, { label: 'Personen', - icon: 'groups', + icon: PERSONS_ICON, route: '/persons', queryParams: activeInstitutionPersonListQueryParams( this.credentialService.effectiveInstitutionId(), @@ -87,19 +102,19 @@ export class AppMenuComponent { }, { label: 'Bookmarks', - icon: 'bookmarks', + icon: BOOKMARKS_ICON, route: '/bookmarks', disabled: false, }, { label: 'News', - icon: 'newspaper', + icon: NEWS_ICON, route: '/news', disabled: false, }, { label: 'Institutionen', - icon: 'apartment', + icon: INSTITUTION_ICON, route: '/institutions', disabled: false, queryParams: { @@ -112,7 +127,7 @@ export class AppMenuComponent { }, { label: 'Publikationen', - icon: 'menu_book', + icon: PUBLICATION_ICON, route: '/publications', disabled: false, queryParams: { @@ -125,7 +140,7 @@ export class AppMenuComponent { }, { label: 'Themen', - icon: 'topic', + icon: TOPIC_ICON, route: '/topics', disabled: false, queryParams: { @@ -138,7 +153,7 @@ export class AppMenuComponent { }, { label: 'Projekte', - icon: 'work', + icon: PROJECT_ICON, route: '/projects', disabled: false, queryParams: { @@ -152,13 +167,13 @@ export class AppMenuComponent { }, { label: 'Patente', - icon: 'workspace_premium', + icon: PATENT_ICON, route: '/patents', disabled: false, }, { label: 'Keywords', - icon: 'join_left', + icon: KEYWORDS_ICON, route: '/keywords', disabled: false, queryParams: { @@ -167,21 +182,21 @@ export class AppMenuComponent { }, { label: 'Accounts', - icon: 'manage_accounts', + icon: MANAGE_ACCOUNTS_ICON, route: '/accounts', disabled: false, managerOrAdminOnly: true, }, { label: 'Organisationen', - icon: 'domain', + icon: ORGANIZATIONS_ICON, route: '/organizations', disabled: false, superAdminOnly: true, }, { label: 'Jobs', - icon: 'sync', + icon: JOBS_ICON, route: '/jobs', disabled: false, superAdminOnly: true, diff --git a/webapp/src/app/shared/ui/icons.ts b/webapp/src/app/shared/ui/icons.ts new file mode 100644 index 00000000..ed81f570 --- /dev/null +++ b/webapp/src/app/shared/ui/icons.ts @@ -0,0 +1,18 @@ +export const BOOKMARKS_ICON = "bookmarks" as const; +export const COMPANY_CONNECTION_ICON = 'business' as const; +export const DASHBOARD_ICON = 'dashboard' as const; +export const FUNDING_ICON = 'account_balance' as const; +export const INSTITUTION_ICON = 'school' as const; +export const JOBS_ICON = "sync" as const; +export const KEYWORDS_ICON = 'join_left' as const; +export const MANAGE_ACCOUNTS_ICON = 'manage_accounts' as const; +export const NETWORK_ICON = 'share' as const; +export const NEWS_ICON = 'newspaper' as const; +export const ORGANIZATIONS_ICON = 'domain' as const; +export const OVERVIEW_ICON = 'visibility' as const; +export const PATENT_ICON = 'workspace_premium' as const; +export const PERSONS_ICON = 'groups' as const; +export const PERSON_ICON = 'person' as const; +export const PROJECT_ICON = 'work' as const; +export const PUBLICATION_ICON = 'menu_book' as const; +export const TOPIC_ICON = 'topic' as const; \ No newline at end of file diff --git a/webapp/src/app/shared/ui/link-tab-nav-bar/link-tab-nav-bar.component.html b/webapp/src/app/shared/ui/link-tab-nav-bar/link-tab-nav-bar.component.html new file mode 100644 index 00000000..fa54da5b --- /dev/null +++ b/webapp/src/app/shared/ui/link-tab-nav-bar/link-tab-nav-bar.component.html @@ -0,0 +1,19 @@ + + @for (link of links(); track link.path) { + + + @if (link.icon) { + {{ link.icon }} + } + {{ link.label }} + + + } + diff --git a/webapp/src/app/shared/ui/link-tab-nav-bar/link-tab-nav-bar.component.scss b/webapp/src/app/shared/ui/link-tab-nav-bar/link-tab-nav-bar.component.scss new file mode 100644 index 00000000..aaa131c5 --- /dev/null +++ b/webapp/src/app/shared/ui/link-tab-nav-bar/link-tab-nav-bar.component.scss @@ -0,0 +1,5 @@ +.link-tab-nav-bar-item { + display: flex; + align-items: center; + gap: 0.25rem; +} \ No newline at end of file diff --git a/webapp/src/app/shared/ui/link-tab-nav-bar/link-tab-nav-bar.component.ts b/webapp/src/app/shared/ui/link-tab-nav-bar/link-tab-nav-bar.component.ts new file mode 100644 index 00000000..3f87669d --- /dev/null +++ b/webapp/src/app/shared/ui/link-tab-nav-bar/link-tab-nav-bar.component.ts @@ -0,0 +1,50 @@ +import { Component, computed, inject, input } from '@angular/core'; +import { MatTabNavPanel, MatTabsModule } from '@angular/material/tabs'; +import { + ActivatedRoute, + isActive, + Router, + RouterModule, +} from '@angular/router'; +import { MatIconModule } from '@angular/material/icon'; + +export type LinkTabNavBarItem = { + label: string; + path: string; + icon?: string; + description?: string; + queryParams?: Record; + disabled?: boolean; +}; + +@Component({ + selector: 'app-link-tab-nav-bar', + imports: [MatTabsModule, RouterModule, MatIconModule], + templateUrl: './link-tab-nav-bar.component.html', + styleUrl: './link-tab-nav-bar.component.scss', +}) +export class LinkTabNavBarComponent { + private readonly router = inject(Router); + private readonly activatedRoute = inject(ActivatedRoute); + + links = input.required(); + tabPanel = input(); + + activeLink = computed(() => { + for (const link of this.links()) { + const linkUrlTree = this.router.createUrlTree([link.path], { + relativeTo: this.activatedRoute, + }); + + if ( + isActive(linkUrlTree, this.router, { + paths: 'subset', + queryParams: 'ignored', + })() + ) { + return link; + } + } + return null; + }); +} diff --git a/webapp/src/styles.scss b/webapp/src/styles.scss index fdcaec2f..95a45697 100644 --- a/webapp/src/styles.scss +++ b/webapp/src/styles.scss @@ -2,12 +2,11 @@ // For more information: https://material.angular.io/guide/theming @use '@angular/material' as mat; @use 'm3-theme' as m3; +@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,200..700,0..1,-50..200'); @include mat.elevation-classes(); @include mat.app-background(); -@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,200..700,0..1,-50..200'); - @font-face { font-display: swap; font-family: 'Montserrat';