-
Notifications
You must be signed in to change notification settings - Fork 0
/
style-switcher.js
49 lines (44 loc) · 1.54 KB
/
style-switcher.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
34
35
36
37
38
39
40
41
42
43
44
45
/*=======================toggle style switcher============================ */
const styleSwitcherToggle = document.querySelector(".style-switcher-toggler");
styleSwitcherToggle.addEventListener("click", () => {
document.querySelector(".aa").classList.toggle("open");
})
// hide style - SWITCHER ON SCROLL
window.addEventListener("scroll", () => {
if(document.querySelector(".style-switcher").classList.contains("open"))
{
document.querySelector(".style-switcher").classList.remove("open");
}
})
/* ======================================theme colors =============================================== */
const alternateStyles = document.querySelectorAll(".alternate-style");
function setActiveStyle(color)
{
alternateStyles.forEach(style => {
if (color === style.getAttribute("title"))
{
style.removeAttribute("disabled");
}
else
{
style.setAttribute("disabled","true");
}
});
}
/*====================================theme light anD ark mo=====*/
const dayNight = document.querySelector(".day-night");
dayNight.addEventListener("click" , () => {
dayNight.querySelector("i").classList.toggle("fa-sun");
dayNight.querySelector("i").classList.toggle("fa-moon");
document.body.classList.toggle("dark");
})
window.addEventListener("load" , () => {
if(document.body.classList.contains("dark"))
{
dayNight.querySelector("i").classList.add("fa-sun");
}
else
{
dayNight.querySelector("i").classList.add("fa-moon");
}
})