-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.js
46 lines (35 loc) · 1.13 KB
/
contact.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
const header = document.querySelector('header');
const links = document.querySelectorAll('.link')
window.addEventListener('scroll', ()=>{
header.classList.toggle('change',window.scrollY > 1);
for(let i=0; i<links.length; i++){
links[i].classList.toggle('diff', window.scrollY>1);
}
});
const dark = document.querySelector('.darkMode');
let darkMode = localStorage.getItem('darkMode');
const enableDarkMode = () => {
document.body.classList.add('dark');
localStorage.setItem('darkMode', 'enabled');
}
const disableDarkMode = () => {
document.body.classList.remove('dark');
localStorage.setItem('darkMode', null);
}
if (darkMode === 'enabled') {
enableDarkMode();
}
dark.addEventListener('click', ()=>{
darkMode = localStorage.getItem('darkMode');
if (darkMode !== 'enabled') {
enableDarkMode();
} else {
disableDarkMode();
}
});
const menu = document.querySelector('.menu');
const nav = document.querySelector('nav');
menu.addEventListener('click', ()=>{
header.classList.toggle('act');
nav.classList.toggle('active');
})