Skip to content

Commit c75ffb2

Browse files
committed
feat: update topbar with correct page title
1 parent 67fb5de commit c75ffb2

5 files changed

Lines changed: 22 additions & 14 deletions

File tree

eventz-ui/src/components/admin/side-nav/side-nav.component.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
22
import { ISideNav } from '../../../interfaces/interface';
33
import { sideNavLinks } from '../data/side-nav-links';
44
import { FaIconComponent } from "@fortawesome/angular-fontawesome";
@@ -15,16 +15,17 @@ import { Router } from '@angular/router';
1515
export class SideNavComponent implements OnInit {
1616
links: ISideNav[] = sideNavLinks;
1717
activeLink: ISideNav | undefined;
18+
@Output() selectedLinkEmitter = new EventEmitter<string>();
1819

1920
constructor ( private router:Router) {}
2021
ngOnInit(): void {
21-
console.log(this.router.url.split('/')[2]);
2222
this.activeLink = this.links.find(link => link.name.toLowerCase() === (this.router.url.split('/')[2] || 'dashboard'));
2323
if (this.activeLink) {
2424
this.links = this.links.map((l) => ({
2525
...l,
2626
isActive: l.name === this.activeLink?.name ? true : false
2727
}));
28+
this.selectedLinkEmitter.emit(this.activeLink.name);
2829
}
2930
}
3031

@@ -33,6 +34,7 @@ export class SideNavComponent implements OnInit {
3334
...l,
3435
isActive: l.name === link.name ? true : false
3536
}));
36-
link.name.toLowerCase() === 'dashboard' ? this.router.navigate(['admin']) : this.router.navigate([`admin/${link.name.toLowerCase()}`])
37+
link.name.toLowerCase() === 'dashboard' ? this.router.navigate(['admin']) : this.router.navigate([`admin/${link.name.toLowerCase()}`]);
38+
this.selectedLinkEmitter.emit(link.name);
3739
}
3840
}

eventz-ui/src/components/admin/top-bar/top-bar.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<button class="lg:hidden ml-4" (click)="menuClick.emit()">
33
<fa-icon [icon]="faBars"></fa-icon>
44
</button>
5-
<div class="text-lg font-semibold">
6-
Dashboard
5+
<div class="text-lg font-semibold my-3">
6+
{{activeLink}}
77
</div>
88
<div class="flex items-center justify-end w-1/6 pe-6">
99
<div class="flex items-center justify-center w-10 h-10 rounded-full bg-adminBackground">

eventz-ui/src/components/admin/top-bar/top-bar.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, EventEmitter, Output } from '@angular/core';
1+
import { Component, EventEmitter, Input, Output } from '@angular/core';
22
import { faBell, faDotCircle, faBars } from '@fortawesome/free-solid-svg-icons';
33
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
44
import { CommonModule } from '@angular/common';
@@ -14,4 +14,5 @@ export class TopBarComponent {
1414
faDotCircle = faDotCircle;
1515
faBars = faBars;
1616
@Output() menuClick = new EventEmitter<void>();
17+
@Input() activeLink: string = '';
1718
}

eventz-ui/src/layouts/admin-layout/admin-layout.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!-- Desktop sidenav -->
44
<div class="hidden lg:block w-[15%]">
5-
<app-side-nav></app-side-nav>
5+
<app-side-nav (selectedLinkEmitter)="handleEmittedLink($event)"></app-side-nav>
66
</div>
77

88
<!-- Mobile backdrop -->
@@ -17,13 +17,13 @@
1717
class="fixed top-0 left-0 h-full w-64 bg-white z-50 transform transition-transform duration-300 lg:hidden"
1818
[ngClass]="showSideNav ? 'translate-x-0' : '-translate-x-full'"
1919
>
20-
<app-side-nav></app-side-nav>
20+
<app-side-nav (selectedLinkEmitter)="handleEmittedLink($event)"></app-side-nav>
2121
</div>
2222

2323
<!-- Main content -->
2424
<div class="flex flex-col w-full lg:w-[85%] max-h-screen overflow-y-auto">
2525
<div class="h-14 bg-white flex items-center">
26-
<app-top-bar (menuClick)="toggleSideNav()"></app-top-bar>
26+
<app-top-bar (menuClick)="toggleSideNav()" [activeLink]="activeLink"></app-top-bar>
2727
</div>
2828

2929
<div>

eventz-ui/src/layouts/admin-layout/admin-layout.component.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component } from '@angular/core';
1+
import { Component, EventEmitter, Output } from '@angular/core';
22
import { SideNavComponent } from "../../components/admin/side-nav/side-nav.component";
33
import { RouterOutlet } from '@angular/router';
44
import { TopBarComponent } from "../../components/admin/top-bar/top-bar.component";
@@ -12,10 +12,15 @@ import { CommonModule } from '@angular/common';
1212
styleUrl: './admin-layout.component.scss'
1313
})
1414
export class AdminLayoutComponent {
15-
showSideNav = false;
15+
showSideNav = false;
16+
activeLink: string = '';
1617

17-
toggleSideNav() {
18-
this.showSideNav = !this.showSideNav;
19-
}
2018

19+
toggleSideNav() {
20+
this.showSideNav = !this.showSideNav;
21+
}
22+
handleEmittedLink(linkName: string) {
23+
this.activeLink = linkName;
24+
console.log('Active Link in Layout:', this.activeLink);
25+
}
2126
}

0 commit comments

Comments
 (0)