-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
178 lines (164 loc) · 5.94 KB
/
app.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
//SIDEBAR
const menuItems=document.querySelectorAll('.menu-item ');
//messages
const messagesNotification=document.querySelector('#message-notifications');
const messages=document.querySelector('.messages');
const messageSearch=document.querySelector('#message-search');
//Theme
const theme=document.querySelector('#theme');
const themeModal=document.querySelector('.customize-theme');
const fontSizes=document.querySelectorAll('.choose-size span');
var root= document.querySelector(':root');
const colorPalette=document.querySelectorAll('.choose-color span');
const Bg1=document.querySelector('.bg-1');
const Bg2=document.querySelector('.bg-2');
const Bg3=document.querySelector('.bg-3');
//==============sidebar==============================
//remove class from all menu items
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('.notifications-popup').style.display = 'none';
}else{
document.querySelector('.notifications-popup').style.display = 'block';
document.querySelector("#notifications .notification-count").style.display='none';
}
})
})
//=======================MESSAGES==================================
//searches chat
const searchMessage=()=>{
const val= messageSearch.value.toLowerCase();
console.log(val);
message.forEach(chat=>{
let name=chat.querySelector('h5').textContent.toLowerCase();
if(name.indexOf(val)!=-1){
chat.style.display='flex';
}else{
chat.style.display='none';
}
})
}
//search chat
messageSearch.addEventListener('keyup' , searchMessage)
// hightlight message column when message is clicked
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);
});
// theme /display customization
const openThemeModal=()=>{
themeModal.style.display='grid';
}
const closeThemeModal=(e)=>{
if(e.target.classList.contains('customize-theme')){
themeModal.style.display='none';
}
}
//close modal
themeModal.addEventListener('click',closeThemeModal);
theme.addEventListener('click',openThemeModal);
//==================FONTS==========================
//fonts
// ================== FONTS ==========================
fontSizes.forEach(size => {
let fontSize;
size.addEventListener('click', () => {
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', '-10rem');
root.style.setProperty('--sticky-top-right', '-33rem');
}
// change font size of root html element
document.querySelector('html').style.fontSize = fontSize;
});
});
//remove active class from colors
const changeActivecolorclass =()=>{
colorPalette.forEach(colorPicker=>{
colorPicker.classList.remove('active');
})
}
colorPalette.forEach(color=>{
color.addEventListener('click',()=>{
let primary;
changeActivecolorclass();
if( color.classList.contains('color-1')){
primaryhue=0 ;
}else if( color.classList.contains('color-2')){
primaryhue=120;
}else if( color.classList.contains('color-3')){
primaryhue=57;
}else if( color.classList.contains('color-4')){
primaryhue=287;
}else if( color.classList.contains('color-5')){
primaryhue=202;
}
color.classList.add('active');
root.style.setProperty('--primary-color-hue', primaryhue);
});
});
let lightColorLightness;
let whiteColorLightness;
let darkColorLightness;
//change background color
const changeBG=()=>{
root.style.setProperty('--light-color-lightness',lightColorLightness);
root.style.setProperty('--white-color-lightness',whiteColorLightness);
root.style.setProperty('--dark-color-lightness',darkColorLightness);
}
Bg1.addEventListener('click',()=>{
Bg1.classList.add('active');
Bg2.classList.remove('active');
Bg3.classList.remove('active');
//remove customize changes from local storage
window.location.reload();
})
Bg2.addEventListener('click',()=>{
lightColorLightness='15%';
whiteColorLightness='20%';
darkColorLightness='95%';
//addactiveclass
Bg2.classList.add('active');
//removeactiveclass-
Bg1.classList.remove('active');
Bg3.classList.remove('active');
changeBG();
});
Bg3.addEventListener('click',()=>{
lightColorLightness='0%';
whiteColorLightness='10%';
darkColorLightness='95%';
//addactiveclass
Bg3.classList.add('active');
//removeactiveclass-
Bg1.classList.remove('active');
Bg2.classList.remove('active');
changeBG();
});