generated from ab-noori/Project-Template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscripts.js
98 lines (91 loc) · 2.87 KB
/
scripts.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
const devCarts = document.getElementById('dev-carts');
const cartsData = [
{
id: '1',
name: 'Abdul Ali Noori',
title: 'Full-Stack Developer',
bio: 'Lorem, ipsum dolor sit amet consectetur adipisicing elit. Voluptas alias omnis non consequuntur.',
img: 'images/dev-abdulali.jpg',
},
{
id: '2',
name: 'Ali Akbar Sazish',
title: 'Backed Developer',
bio: 'Lorem, ipsum dolor sit amet consectetur adipisicing elit. Voluptas alias omnis non consequuntur.',
img: 'images/dev-sazish.jpg',
},
{
id: '3',
name: 'Ali Jan Rahimi',
title: 'Frontend Developer',
bio: 'Lorem, ipsum dolor sit amet consectetur adipisicing elit. Voluptas alias omnis non consequuntur.',
img: 'images/dev-abdulali.jpg',
},
{
id: '4',
name: 'Abdul Ali Noori',
title: 'Full-Stack Developer',
bio: 'Lorem, ipsum dolor sit amet consectetur adipisicing elit. Voluptas alias omnis non consequuntur.',
img: 'images/dev-abdulali.jpg',
},
{
id: '5',
name: 'Ali Akbar Sazish',
title: 'Backed Developer',
bio: 'Lorem, ipsum dolor sit amet consectetur adipisicing elit. Voluptas alias omnis non consequuntur.',
img: 'images/dev-sazish.jpg',
},
{
id: '6',
name: 'Ali Jan Rahimi',
title: 'Frontend Developer',
bio: 'Lorem, ipsum dolor sit amet consectetur adipisicing elit. Voluptas alias omnis non consequuntur.',
img: 'images/dev-abdulali.jpg',
},
];
function generatProjectCarts() {
devCarts.innerHTML = cartsData.map((x) => {
const {
id, name, title, bio, img,
} = x;
if (id > 2) {
return `
<div class="dev-cart hidden" id="${id}">
<span>
<img src="${img}" width="100" alt="Developer image" class="dev-imge">
</span>
<div class="dev-details">
<h3 class="dev-name">${name}</h3>
<span class="dev-title">${title}</span>
<p class="dev-bio">${bio}</p>
</div>
</div>
`;
}
return `
<div class="dev-cart" id="${id}">
<span>
<img src="${img}" width="100" alt="Developer image" class="dev-imge">
</span>
<div class="dev-details">
<h3 class="dev-name">${name}</h3>
<span class="dev-title">${title}</span>
<p class="dev-bio">${bio}</p>
</div>
</div>
`;
}).join('');
}
generatProjectCarts();
// --------------------------------toggle menu-------------------------------------------
const hamburger = document.querySelector('.hamburger');
const navMenu = document.querySelector('.nav-menu');
hamburger.addEventListener('click', () => {
hamburger.classList.toggle('active');
navMenu.classList.toggle('active');
});
document.querySelectorAll('.nav-link')
.forEach((links) => links.addEventListener('click', () => {
hamburger.classList.remove('active');
navMenu.classList.remove('active');
}));