-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
186 lines (163 loc) · 5.61 KB
/
script.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// SIDEBAR
const menuItems = document.querySelectorAll(".menu-item");
//Messages
const messagesNotification = document.querySelector("#message-notification");
const messages = document.querySelector(".messages");
const message = messages.querySelectorAll(".message");
const messageSearch = document.querySelector("#message-search");
// Theme
const theme = document.querySelector("#theme");
const themeModel = document.querySelector(".customize-theme");
const fontSize = document.querySelectorAll(".choose-size span");
var root = document.querySelector(":root");
const colorPalatte = document.querySelectorAll(".choose-color span");
const Bg1 = document.querySelector(".bg-1");
const Bg2 = document.querySelector(".bg-2");
const Bg3 = document.querySelector(".bg-3");
//Sidebar
const changeActiveItem = () => {
menuItems.forEach((item) => {
item.classList.remove("active");
});
};
menuItems.forEach((item) => {
item.addEventListener("click", () => {
changeActiveItem();
item.classList.add("active");
if (item.id != "notifications") {
document.querySelector(".notification-popup");
style.display = "none";
} else {
document.querySelector(".notification-popup").style.display = "block";
document.querySelector(
"#notifications .notification-count"
).style.display = "none";
}
});
});
const searchMessage = () => {
const val = messageSearch.value.toLowerCase();
message.forEach((chat) => {
let name = chat.querySelectorAll("h5").textContent.toLowerCase();
if (name.indexOf(val) != -1) {
chat.style.display = "flex";
} else {
chat.style.display = "none";
}
});
};
messageSearch.addEventListener("keyup", searchMessage);
messagesNotification.addEventListener("click", () => {
messages.style.boxShadow = "0 0 1rem var(--color-primary)";
messagesNotification.querySelector(".notification-count").style.display =
"none";
setTimeout(() => {
messages.style.boxShadow = "none";
}, 2000);
});
const openThemeModel = () => {
themeModel.style.display = "grid";
};
const closeThemeModel = (e) => {
if (e.target.classList.contains("customize-theme")) {
themeModel.style.display = "none";
}
};
themeModel.addEventListener("click", closeThemeModel);
theme.addEventListener("click", openThemeModel);
const removeSizeSelector = () => {
fontSize.forEach((size) => {
size.classList.remove("active");
});
};
//Font Size
fontSize.forEach((size) => {
size.addEventListener("click", () => {
removeSizeSelector();
let fontSize;
size.classList.toggle("active");
if (size.classList.contains("font-size-1")) {
fontSize = "10px";
root.style.setProperty("-----sticky-top-left", "5.4rem");
root.style.setProperty("-----sticky-top-right", "5.4rem");
} else if (size.classList.contains("font-size-2")) {
fontSize = "13px";
root.style.setProperty("-----sticky-top-left", "5.4rem");
root.style.setProperty("-----sticky-top-right", "-7rem");
} else if (size.classList.contains("font-size-3")) {
fontSize = "16px";
root.style.setProperty("-----sticky-top-left", "-2rem");
root.style.setProperty("-----sticky-top-right", "-17rem");
} else if (size.classList.contains("font-size-4")) {
fontSize = "19px";
root.style.setProperty("-----sticky-top-left", "-5rem");
root.style.setProperty("-----sticky-top-right", "-25rem");
} else if (size.classList.contains("font-size-5")) {
fontSize = "22px";
root.style.setProperty("-----sticky-top-left", "-12rem");
root.style.setProperty("-----sticky-top-right", "-35rem");
}
//change font Size
document.querySelector("html").style.fontSize = fontSize;
});
});
//remove active color
const changeActiveColorClass = () => {
colorPalatte.forEach((colorPicker) => {
colorPicker.classList.remove("active");
});
};
//color
colorPalatte.forEach((color) => {
color.addEventListener("click", () => {
let primary;
changeActiveColorClass();
if (color.classList.contains("color-1")) {
primaryHue = 252;
} else if (color.classList.contains("color-2")) {
primaryHue = 52;
} else if (color.classList.contains("color-3")) {
primaryHue = 352;
} else if (color.classList.contains("color-4")) {
primaryHue = 152;
} else if (color.classList.contains("color-5")) {
primaryHue = 202;
}
color.classList.add("active");
root.style.setProperty("--color-primary-hue", primaryHue);
});
});
// theme Background values
let lightColorLightness;
let whiteColorlightness;
let darkColorLightness;
const changeBG = () => {
root.style.setProperty("--light-color-lightness", lightColorLightness);
root.style.setProperty("--white-color-lightness", whiteColorLightness);
root.style.setProperty("--dark-color-lightness", darkColorLightness);
};
Bg2.addEventListener("click", () => {
darkColorLightness = "95%";
whiteColorlightness = "20%";
lightColorLightness = "15%";
Bg2.classList.add("active");
Bg1.classList.remove("active");
Bg3.classList.remove("active");
changeBG();
});
Bg3.addEventListener("click", () => {
darkColorLightness = "95%";
whiteColorlightness = "10%";
lightColorLightness = "0%";
Bg2.classList.remove("active");
Bg1.classList.remove("active");
Bg3.classList.add("active");
changeBG();
});
Bg1.addEventListener("click", () => {
Bg2.classList.add("active");
Bg1.classList.remove("active");
Bg3.classList.remove("active");
window.location.reload();
});
//End