-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
56 lines (48 loc) · 1.34 KB
/
main.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
const hamburger = document.querySelector('.hamburger');
const menu = document.querySelector('.menu');
const speakerList = document.querySelector('.speaker-list');
hamburger.addEventListener('click', (e) => {
e.preventDefault();
hamburger.classList.toggle('active');
menu.classList.toggle('active');
});
document.querySelectorAll('.nav-link').forEach((nav) => nav.addEventListener('click', () => {
hamburger.classList.remove('active');
menu.classList.remove('active');
}));
const displaySpeakers = ({
name, qualifications, biography, image,
}) => {
const div = document.createElement('div');
div.className = 'speaker-details';
div.innerHTML = `
<div class="speaker-img">
<img src="${image}" alt="${name}" class="speaker-image">
</div>
<div class="speaker-info">
<h3 class="speaker-name">
${name}
</h3>
<h4 class="speaker-qualifications">
${qualifications}
</h4>
<hr>
<p class="speaker-brief">
${biography}
</p>
</div>
`;
return div;
};
const getSpeakers = async () => {
const response = await fetch('./speakers.json');
try {
const data = await response.json();
data.forEach((speaker) => {
speakerList.append(displaySpeakers(speaker));
});
} catch (error) {
// console.log(error);
}
};
getSpeakers();