-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeme.js
33 lines (29 loc) · 1.03 KB
/
theme.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
32
33
const mode=document.getElementById("mode")
const icon=document.getElementById("icon")
let theam=document.querySelector('data-theme')
const html = document.querySelector('html');
const theme = localStorage.getItem('theme');
html.setAttribute('data-theme',theme);
if(theme=='luxury'){
icon.className='bx bxs-sun bx-sm';
mode.style.backgroundColor="white";
html.setAttribute('data-theme', 'luxury');
}else{
html.setAttribute('data-theme', 'bumblebee');
icon.className='bx bxs-moon bx-sm'
mode.style.backgroundColor="black";
}
function ChangeMode(){
if(icon.className=='bx bxs-moon bx-sm'){
icon.className='bx bxs-sun bx-sm';
mode.style.backgroundColor="white";
html.setAttribute('data-theme', 'luxury');
localStorage.setItem('theme', 'luxury');
}else{
icon.className='bx bxs-moon bx-sm'
mode.style.backgroundColor="black";
html.setAttribute('data-theme', 'bumblebee');
localStorage.setItem('theme', 'bumblebee');
}
}
mode.addEventListener('click',ChangeMode)