Summary Files Commits Branches @commit @diff @stats
path: root / src / scripts / theme-changer.js
blob: 5fd5f7ce0c0f5afd8b995fd506e96dd21e16f4a1 (plain) (blame)
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
const themeBtn = document.getElementById('changeThemeBtn');

if (darkThemeStyle.disabled)
	themeBtn.src = '/img/moon-tabler.svg';

themeBtn.style.display = 'initial';

function changeTheme(theme) {
	if (theme === 'light') {
		darkThemeStyle.disabled = true;
		themeBtn.src = '/img/moon-tabler.svg';
	}
	else {
		darkThemeStyle.disabled = false;
		themeBtn.src = '/img/sun-tabler.svg';
	}
}

themeBtn.onclick = function() {
	if (localStorage.getItem('theme') !== 'light') {
		changeTheme('light');
		localStorage.setItem('theme', 'light');
	}
	else {
		changeTheme('dark');
		localStorage.setItem('theme', 'dark');
	}
}