-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
26 lines (23 loc) · 1.02 KB
/
main.js
File metadata and controls
26 lines (23 loc) · 1.02 KB
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
const prefersColorScheme = window.matchMedia('(prefers-color-scheme: dark)');
const darkmode = document.querySelector('#setting');
const settingClick = document.querySelector('.setting-div');
const buttonShow = document.querySelector('.buttonShow');
const darkmodeswitch = document.querySelector('.dark-mode-buttons');
if (prefersColorScheme.matches) {
document.body.classList.toggle('dark-theme-colors');
darkmode.querySelector('button:nth-child(1)').classList.toggle('active');
darkmode.querySelector('button:nth-child(2)').classList.toggle('active');
}
darkmodeswitch.addEventListener('click', () => {
document.body.classList.toggle('dark-theme-colors');
darkmode.querySelector('button:nth-child(1)').classList.toggle('active');
darkmode.querySelector('button:nth-child(2)').classList.toggle('active');
});
settingClick.addEventListener('click', () => {
if (buttonShow.style.display === "none") {
buttonShow.style.display = "block";
}
else {
buttonShow.style.display = "none";
}
});