..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 | import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
title = 'mpecws';
ngOnInit() {
const visibilityPreferences = localStorage.getItem('visibilityPreferences');
if (!visibilityPreferences) {
localStorage.setItem('visibilityPreferences', 'light');
this.setTheme();
} else {
this.setTheme();
}
}
setTheme() {
const visibilityPreferences = localStorage.getItem('visibilityPreferences');
if (visibilityPreferences === 'dark') {
$('.themeableComponent').addClass('inverted');
$('.themedComponent').addClass('dark');
} else {
$('.themeableComponent').removeClass('inverted');
$('.themedComponent').removeClass('dark');
}
}
toggleDarkTheme() {
const visibilityPreferences = localStorage.getItem('visibilityPreferences');
if (visibilityPreferences === 'dark') {
localStorage.setItem('visibilityPreferences', 'light');
this.setTheme();
} else {
localStorage.setItem('visibilityPreferences', 'dark');
this.setTheme();
}
}
toggleSidebar() {
$('.mobileMenu').toggle();
$('body, html').toggleClass('noscroll');
}
}
|
|