first commit
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
import { ChangeDetectionStrategy, Component, input, output, computed, inject } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { CdkMenuModule } from '@angular/cdk/menu';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { ThemeService } from '../../../services/theme/theme.service';
|
||||
|
||||
export interface NavItem {
|
||||
icon: string;
|
||||
label: string;
|
||||
route?: string;
|
||||
}
|
||||
|
||||
export interface ChatHistoryItem {
|
||||
id: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-sidebar',
|
||||
standalone: true,
|
||||
imports: [CommonModule, RouterModule, CdkMenuModule],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
templateUrl: './sidebar.component.html',
|
||||
styleUrl: './sidebar.component.css'
|
||||
})
|
||||
export class SidebarComponent {
|
||||
private readonly themeService = inject(ThemeService);
|
||||
|
||||
readonly isOpen = input<boolean>(false);
|
||||
readonly userName = input<string>('Peyman Honarjoo');
|
||||
readonly navItems = input<NavItem[]>([
|
||||
{
|
||||
icon: 'M12 5v14M5 12h14',
|
||||
label: 'چت جدید',
|
||||
},
|
||||
{
|
||||
icon: 'M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.573-1.066zM15 12a3 3 0 11-6 0 3 3 0 016 0z',
|
||||
label: 'تنظیمات',
|
||||
route: '/settings',
|
||||
},
|
||||
]);
|
||||
readonly chatHistory = input<ChatHistoryItem[]>([]);
|
||||
readonly close = output<void>();
|
||||
readonly navClick = output<void>();
|
||||
readonly open = output<void>();
|
||||
readonly profileClick = output<void>();
|
||||
readonly logoutClick = output<void>();
|
||||
|
||||
readonly userInitials = computed(() => {
|
||||
const name = this.userName();
|
||||
return name
|
||||
.split(' ')
|
||||
.map((n) => n[0])
|
||||
.join('')
|
||||
.slice(0, 2)
|
||||
.toUpperCase();
|
||||
});
|
||||
|
||||
readonly isDarkMode = this.themeService.isDarkMode;
|
||||
|
||||
toggleTheme(): void {
|
||||
this.themeService.toggleDarkMode();
|
||||
}
|
||||
|
||||
onNavClick(): void {
|
||||
this.navClick.emit();
|
||||
}
|
||||
|
||||
onLogoClick(): void {
|
||||
if (!this.isOpen()) {
|
||||
this.open.emit();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user