-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
66 lines (58 loc) · 2.04 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
60
61
62
63
64
65
66
const mobileBurger = document.querySelector('.burger');
const mobileNav = document.querySelector('.mobile-nav');
const vegetarianButton = document.getElementById('vegetarian-button');
const veganButton = document.getElementById('vegan-button');
const meatButton = document.getElementById('meat-button');
const vegetarianSection = document.getElementById('vegetarian');
const veganSection = document.getElementById('vegan');
const meatSection = document.getElementById('meat');
const shareButton = document.getElementById('share-button');
const shareModal = document.querySelector('.share-modal');
const modalOverlay = document.querySelector('.modal-overlay');
const modalCloseButton = document.getElementById('close-share');
mobileBurger.addEventListener('click', () => {
mobileNav.classList.toggle('hide');
})
function transformBurgerToX(el) {
el.classList.toggle('transform');
}
if (vegetarianButton) {
vegetarianButton.addEventListener('click', () => {
vegetarianSection.classList.remove('hide');
veganSection.classList.add('hide');
meatSection.classList.add('hide');
})
}
if (veganButton) {
veganButton.addEventListener('click', () => {
veganSection.classList.remove('hide');
vegetarianSection.classList.add('hide');
meatSection.classList.add('hide');
})
}
if (meatButton) {
meatButton.addEventListener('click', () => {
meatSection.classList.remove('hide');
veganSection.classList.add('hide');
vegetarianSection.classList.add('hide');
})
}
if (shareButton) {
shareButton.addEventListener('click', () => {
modalOverlay.classList.toggle('hide');
shareModal.classList.toggle('hide');
shareButton.classList.add('hide');
})
modalCloseButton.addEventListener('click', () => {
modalOverlay.classList.toggle('hide');
shareModal.classList.toggle('hide');
shareButton.classList.remove('hide');
})
}
if (modalOverlay) {
modalOverlay.addEventListener('click', () => {
modalOverlay.classList.toggle('hide');
shareModal.classList.toggle('hide');
shareButton.classList.remove('hide');
})
}