-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.component.ts
More file actions
92 lines (81 loc) · 2.76 KB
/
header.component.ts
File metadata and controls
92 lines (81 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright The Linux Foundation and each contributor to LFX.
// SPDX-License-Identifier: MIT
import { CommonModule } from '@angular/common';
import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, inject, signal, viewChild, WritableSignal } from '@angular/core';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { Router, RouterModule } from '@angular/router';
import { AvatarComponent } from '@components/avatar/avatar.component';
import { MenubarComponent } from '@components/menubar/menubar.component';
import { environment } from '@environments/environment';
import { UserService } from '@services/user.service';
import { MenuItem } from 'primeng/api';
import { InputTextModule } from 'primeng/inputtext';
import { RippleModule } from 'primeng/ripple';
import { MenuComponent } from '../menu/menu.component';
@Component({
selector: 'lfx-header',
standalone: true,
imports: [CommonModule, ReactiveFormsModule, MenubarComponent, InputTextModule, RippleModule, RouterModule, AvatarComponent, MenuComponent],
templateUrl: './header.component.html',
styleUrl: './header.component.scss',
schemas: [CUSTOM_ELEMENTS_SCHEMA],
host: { ngSkipHydration: 'true' },
})
export class HeaderComponent {
private readonly router = inject(Router);
public readonly userService = inject(UserService);
// Mobile search state
public showMobileSearch: WritableSignal<boolean> = signal(false);
private readonly mobileSearchInput = viewChild<ElementRef>('mobileSearchInput');
// User menu items for the dropdown
protected readonly userMenuItems: MenuItem[] = [
{
label: 'Profile',
icon: 'fa-light fa-user',
url: environment.urls.profile,
target: '_blank',
},
{
label: 'Developer Settings',
icon: 'fa-light fa-cog',
url: environment.urls.profile + 'developer-settings',
target: '_blank',
},
{
separator: true,
},
{
label: 'Logout',
icon: 'fa-light fa-sign-out',
url: '/logout',
target: '_self',
},
];
protected readonly searchControl = new FormControl('');
protected onSearch(): void {
const query = this.searchControl.value?.trim();
if (query) {
// TODO: Implement search functionality
}
}
protected onLogoClick(): void {
this.router.navigate(['/']);
}
protected onUserClick(): void {
// TODO: Show user menu/dropdown or navigate to profile
console.info('User avatar clicked');
}
protected toggleMobileSearch(): void {
this.showMobileSearch.set(true);
// Focus on input after opening
setTimeout(() => {
const input = this.mobileSearchInput();
if (input) {
input.nativeElement.focus();
}
}, 100);
}
protected closeMobileSearch(): void {
this.showMobileSearch.set(false);
}
}