docs: add JSDoc comments to HeaderComponent

This commit is contained in:
Chneemann 2024-11-12 04:46:36 +01:00
parent e8d6c99089
commit e49f6bd9ff
2 changed files with 31 additions and 5 deletions

View file

@ -18,16 +18,29 @@ export class HeaderComponent {
constructor(public firebaseService: FirebaseService) {} constructor(public firebaseService: FirebaseService) {}
toggleNavbar() { /**
* Toggles the visibility of the navbar.
* @returns {void}
*/
toggleNavbar(): void {
this.navbarVisible = !this.navbarVisible; this.navbarVisible = !this.navbarVisible;
} }
toggleLanguage() { /**
* Toggles the visibility of the language selection navbar.
* @returns {void}
*/
toggleLanguage(): void {
this.navbarLanguageVisible = !this.navbarLanguageVisible; this.navbarLanguageVisible = !this.navbarLanguageVisible;
} }
@HostListener('document:click', ['$event']) @HostListener('document:click', ['$event'])
checkOpenNavbar(event: MouseEvent) { /**
* Closes the navbar if the user clicks outside of it
* @param event a MouseEvent
* @returns {void}
*/
checkOpenNavbar(event: MouseEvent): void {
const targetElement = event.target as HTMLElement; const targetElement = event.target as HTMLElement;
if ( if (
!targetElement.closest('app-navbar') && !targetElement.closest('app-navbar') &&

View file

@ -1,6 +1,5 @@
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { Router, RouterModule } from '@angular/router'; import { Router, RouterModule } from '@angular/router';
import { HeaderComponent } from '../header.component';
import { LanguageService } from '../../../../services/language.service'; import { LanguageService } from '../../../../services/language.service';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
@ -10,7 +9,7 @@ import { FirebaseService } from '../../../../services/firebase.service';
@Component({ @Component({
selector: 'app-navbar', selector: 'app-navbar',
standalone: true, standalone: true,
imports: [RouterModule, HeaderComponent, CommonModule, TranslateModule], imports: [RouterModule, CommonModule, TranslateModule],
templateUrl: './navbar.component.html', templateUrl: './navbar.component.html',
styleUrl: './navbar.component.scss', styleUrl: './navbar.component.scss',
}) })
@ -27,10 +26,24 @@ export class NavbarComponent {
private firebaseService: FirebaseService private firebaseService: FirebaseService
) {} ) {}
/**
* OnInit lifecycle hook.
*
* Sets the currentRoute property to the current route's url.
*/
ngOnInit() { ngOnInit() {
this.currentRoute = this.router.url; this.currentRoute = this.router.url;
} }
/**
* Logs out the current user and navigates to the login page.
*
* The logout method of the LoginService is called with the current user ID as
* its argument. This will remove the user ID from the local storage and
* perform any other necessary cleanup operations.
*
* The user is then navigated to the login page.
*/
logout() { logout() {
this.loginService.logout(this.firebaseService.getCurrentUserId()); this.loginService.logout(this.firebaseService.getCurrentUserId());
} }