-
Notifications
You must be signed in to change notification settings - Fork 2
/
theme.js
30 lines (26 loc) · 1.08 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
const changeTheme = () => {
const theme = document.getElementById('theme');
const buttons = document.querySelectorAll('.theme-button');
const icons = document.querySelectorAll('.theme-icon')
buttons.forEach((button) => {
button.addEventListener('click', () => {
if (button.textContent === "Light") {
button.textContent = "Dark";
icons.forEach((icon) => {
icon.classList.remove('fa-sun');
icon.classList.add('fa-moon');
})
theme.attributes.href.value = "./styles/light.css"
} else {
button.textContent = "Light";
icons.forEach((icon) => {
icon.classList.remove('fa-moon');
icon.classList.add('fa-sun');
})
theme.attributes.href.value = "./styles/dark.css"
console.log(theme.attributes.href.textContent)
}
})
})
}
export default changeTheme;