-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
53 lines (41 loc) · 1.76 KB
/
main.js
File metadata and controls
53 lines (41 loc) · 1.76 KB
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
const searchButton = document.querySelector("nav .desktop-nav .link-search");
const closeButton = document.querySelector(".search-container .link-close");
const desktopNav = document.querySelector(".desktop-nav");
const searchContainer = document.querySelector(".search-container");
const overlay = document.querySelector(".overlay");
searchButton.addEventListener("click", () => {
desktopNav.classList.add("hide");
searchContainer.classList.remove("hide");
overlay.classList.add("show");
})
closeButton.addEventListener("click", () => {
desktopNav.classList.remove("hide");
searchContainer.classList.add("hide");
overlay.classList.remove("show");
})
overlay.addEventListener("click", () => {
desktopNav.classList.remove("hide");
searchContainer.classList.add("hide");
overlay.classList.remove("show");
chevronListItem.classList.remove("inverted");
})
// Mobile Version
const menuIconContainer = document.querySelector("nav .menu-icon-container");
const navContainer = document.querySelector(".nav-container");
menuIconContainer.addEventListener("click", () => {
navContainer.classList.toggle("active");
})
const searchBar = document.querySelector(".mobile-search-container .search-bar");
const nav = document.querySelector(".nav-container nav");
const searchInput = document.querySelector(".mobile-search-container input");
const cancelBtn = document.querySelector(".mobile-search-container .cancel-btn");
searchInput.addEventListener("click", () => {
searchBar.classList.add("active");
nav.classList.add("move-up");
desktopNav.classList.add("move-down");
})
cancelBtn.addEventListener("click", () => {
searchBar.classList.remove("active");
nav.classList.remove("move-up");
desktopNav.classList.remove("move-down");
})