-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
32 lines (27 loc) · 943 Bytes
/
main.ts
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
import ThemeController from './ThemeController'
const themes = {
'dark': {
'main-color': 'black',
'text-color': 'white',
},
'light': {
'main-color': 'white',
'text-color': 'black',
},
}
// Capitalize first letter of string
const capitalize = (string,) => {
return string.charAt(0,).toUpperCase() + string.slice(1,)
}
// For demo purposes
// eslint-disable-next-line @typescript-eslint/no-explicit-any
document.addEventListener('themeChange', (eve: any,) => {
const newTheme = eve.detail.theme
document.getElementById('currentTheme',).innerHTML = capitalize(newTheme,)
},)
const testThemeController = new ThemeController(themes,)
document.getElementById('currentTheme',).innerHTML = capitalize(testThemeController.theme,)
const switchTheme = () => {
testThemeController.theme = testThemeController.theme === 'light' ? 'dark' : 'light'
}
document.getElementById('ChangeThemeButton',).addEventListener('click', switchTheme,)