-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
60 lines (46 loc) · 1.52 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
const sections = document.querySelectorAll('[data-id="section-for-toggle"]')
const navBarLinks = document.querySelectorAll('.navBarLink');
const projectTabBtns = document.querySelectorAll('[data-id="tab-btn"]');
const projects = [...document.querySelectorAll('.projectItem')];
const profileSidebar = document.querySelector('[data-id="profile-sidebar"]');
const showContantsBtn = document.querySelector('.show-contants-btn')
const projectsNum = [
[0, 1, 2, 3, 4, 5, 6],
[3, 4, 5],
[0, 1, 2],
[6],
]
navBarLinks.forEach((navBarLink, index) => {
navBarLink.addEventListener('click', (e) => {
e.preventDefault();
navBarLinks.forEach(navBarLink => {
navBarLink.classList.remove('active')
});
sections.forEach((section, sectionIndex) => {
section.classList.remove('visible');
if (sectionIndex === index) {
section.classList.add('visible')
}
})
navBarLink.classList.add('active');
})
})
projectTabBtns.forEach((projectBtn, projectBtnIndex) => {
projectBtn.addEventListener('click', (e) => {
e.preventDefault();
projectTabBtns.forEach((projectBtn) => {
projectBtn.classList.remove('active')
})
projectBtn.classList.add('active')
projects.forEach(project => {
project.classList.remove('active')
});
projectsNum[projectBtnIndex].forEach(projectIndex => {
projects[projectIndex].classList.add('active')
});
})
})
showContantsBtn.addEventListener('click', (e) => {
e.preventDefault();
profileSidebar.classList.toggle('collapsed')
})