parent
d51cb3957f
commit
b7aeed4321
@ -1,35 +1,59 @@
|
||||
import {Component, Input, OnInit} from '@angular/core';
|
||||
import {Component, ElementRef, HostListener, Input, OnInit, ViewChild} from '@angular/core';
|
||||
import { TranslationService } from '../../services/translation.service';
|
||||
import {ThemeService} from "../../services/theme.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-header',
|
||||
templateUrl: './header.component.html',
|
||||
styleUrls: ['./header.component.scss']
|
||||
selector: 'app-header',
|
||||
templateUrl: './header.component.html',
|
||||
styleUrls: ['./header.component.scss']
|
||||
})
|
||||
export class HeaderComponent implements OnInit {
|
||||
title!: string;
|
||||
version!: string;
|
||||
sandkasten_logo!: string;
|
||||
gitea_logo!: string;
|
||||
@Input() themeClass!: string;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.title = 'Sandkasten';
|
||||
this.version = '1.0';
|
||||
this.sandkasten_logo = 'assets/img/logo.png';
|
||||
this.gitea_logo = 'assets/img/gitea.png';
|
||||
}
|
||||
|
||||
// Instanciation du service pour les actions de traduction
|
||||
constructor(private translationService: TranslationService) {}
|
||||
|
||||
// Méthode pour changer la langue
|
||||
onLanguageChange(event: any) {
|
||||
this.translationService.onLanguageChange(event);
|
||||
}
|
||||
|
||||
// Méthode pour récupérer le drapeau de la langue courante
|
||||
getFlagImageUrl(): string {
|
||||
return this.translationService.getFlagImageUrl();
|
||||
}
|
||||
title!: string;
|
||||
version!: string;
|
||||
sandkasten_logo!: string;
|
||||
gitea_logo!: string;
|
||||
isMenuOpen!: boolean;
|
||||
isCheck!: boolean;
|
||||
@ViewChild('menuRef') menuRef!: ElementRef;
|
||||
@Input() themeClass!: string;
|
||||
@Input() themeService!: ThemeService;
|
||||
|
||||
|
||||
|
||||
|
||||
ngOnInit(): void {
|
||||
this.title = 'Sandkasten';
|
||||
this.version = '1.0';
|
||||
this.sandkasten_logo = 'assets/img/logo.png';
|
||||
this.gitea_logo = 'assets/img/gitea.png';
|
||||
this.isMenuOpen = false;
|
||||
this.isCheck = false;
|
||||
}
|
||||
|
||||
// Instanciation du service pour les actions de traduction
|
||||
constructor(private translationService: TranslationService) {}
|
||||
|
||||
// Méthode pour changer la langue
|
||||
onLanguageChange(event: any) {
|
||||
this.translationService.onLanguageChange(event);
|
||||
}
|
||||
|
||||
toggleTheme() {
|
||||
this.themeService.toggleDarkTheme();
|
||||
this.themeService.isDarkTheme.subscribe(value => {
|
||||
this.isCheck = value;
|
||||
})
|
||||
}
|
||||
|
||||
openCloseMenu() {
|
||||
this.isMenuOpen = !this.isMenuOpen;
|
||||
}
|
||||
|
||||
@HostListener('document:click', ['$event'])
|
||||
clickout(event: any) {
|
||||
// If the menu is open and click is outside the menu, we close it
|
||||
if (this.isMenuOpen && !this.menuRef.nativeElement.contains(event.target)) {
|
||||
this.isMenuOpen = false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue