AltitudeWeb/frontend/src/app/header/header.component.ts

42 lines
1.0 KiB
TypeScript
Raw Normal View History

import {Component, Input, OnInit} from '@angular/core';
import {ALTITUDE_VERSION} from '../constant';
@Component({
standalone: false,
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.scss']
})
export class HeaderComponent implements OnInit {
@Input() title: string = '';
@Input() sub_title: string = '';
@Input() current_page: string = ''
public ngOnInit(): void {
this.toggleTheme()//TODO fix theme
}
public getCurrentPageId(options: string[]) {
if (options.includes(this.current_page)) {
return 'current_page'
}
return null;
}
public setTheme(themeName: string) {
localStorage.setItem('theme', themeName);
document.body.className = themeName;
}
// function to toggle between light and dark theme
public toggleTheme() {
if (localStorage.getItem('theme') === 'theme-light') {
this.setTheme('theme-dark');
} else {
this.setTheme('theme-light');
}
}
protected readonly ALTITUDE_VERSION = ALTITUDE_VERSION;
}