Added theme to local storage for saving/loading.
This commit is contained in:
parent
5489eb4df6
commit
1e6690ff4b
@ -105,6 +105,12 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}));
|
||||
|
||||
let currentTheme = localStorage.getItem('ui-theme') ?? this.themeService.theme;
|
||||
if (currentTheme == 'light' || currentTheme == 'dark') {
|
||||
this.themeService.theme = currentTheme;
|
||||
} else {
|
||||
this.themeService.theme = 'dark';
|
||||
}
|
||||
this.overlayContainer.getContainerElement().classList.add(this.themeService.theme + '-theme');
|
||||
|
||||
this.addSubscription(this.events.listen('theme_change', data => {
|
||||
|
@ -14,7 +14,12 @@ export class ThemeService {
|
||||
|
||||
set theme(value: 'light' | 'dark') {
|
||||
const previous = this._current();
|
||||
if (previous == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._current.set(value);
|
||||
localStorage.setItem('ui-theme', value);
|
||||
this.events.emit('theme_change', {
|
||||
previous_theme: previous,
|
||||
current_theme: value,
|
||||
|
Loading…
x
Reference in New Issue
Block a user