-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
31 lines (23 loc) · 1.19 KB
/
app.js
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
document.addEventListener('DOMContentLoaded', () => {
const navBtn = document.querySelector('.nav__burger div');
navBtn.addEventListener('click', function () {
this.parentNode.classList.toggle('active');
});
const themeLightBtn = document.querySelector('.theme-switch__item--light');
const themeDarkBtn = document.querySelector('.theme-switch__item--dark');
const themeRedBtn = document.querySelector('.theme-switch__item--red');
const themeBlueBtn = document.querySelector('.theme-switch__item--blue');
const themeGrayBtn = document.querySelector('.theme-switch__item--gray');
const themeLightblueBtn = document.querySelector('.theme-switch__item--lightblue');
themeLightBtn.addEventListener('click', changeTheme());
themeDarkBtn.addEventListener('click', changeTheme('dark'));
themeRedBtn.addEventListener('click', changeTheme('red'));
themeBlueBtn.addEventListener('click', changeTheme('blue'));
themeGrayBtn.addEventListener('click', changeTheme('gray'));
themeLightblueBtn.addEventListener('click', changeTheme('lightblue'));
function changeTheme(themeName) {
return function () {
document.body.className = themeName ? `theme-${themeName}` : '';
};
}
});