-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
52 lines (43 loc) · 1.82 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
const toggleNavbar = () => {
const navbar = document.querySelector("#nav-bar");
const navbarContent = document.querySelector("#navbar-content");
navbarContent.classList.toggle("grid-rows-0fr");
navbarContent.classList.toggle("grid-rows-1fr");
navbar.classList.toggle("bg-background");
};
const navbarToggle = document.querySelector("#navbar-toggle");
navbarToggle.addEventListener("click", toggleNavbar);
const toggleDropdown = () => {
const dropdownContent = document.querySelector("#dropdown-content");
dropdownContent.classList.toggle("hidden");
};
const dropdownToggle = document.querySelector("#dropdown-toggle");
dropdownToggle.addEventListener("click", toggleDropdown);
const toggleDateCard = () => {
const dateCard = document.querySelector("#date-card");
const dateCardContainer = document.querySelector("#date-card-container");
dateCard.classList.toggle("grid-rows-0fr");
dateCard.classList.toggle("grid-rows-1fr");
dateCard.classList.toggle("mt-4");
dateCardContainer.classList.toggle("md:p-4");
dateCardContainer.classList.toggle("md:p-8");
};
const checkboxDateCard = document.querySelector("#checkbox-date-card");
checkboxDateCard.addEventListener("click", toggleDateCard);
const navBarSrolled = () => {
const navBar = document.querySelector("#nav-bar");
const navBrand = document.querySelector("#nav-brand");
const scrollY = window.scrollY;
if (scrollY > 0) {
navBar.classList.add("shadow", "bg-background");
navBar.classList.remove("bg-grid");
navBrand.classList.remove("pointer-events-none");
navBrand.classList.add("opacity-100");
} else {
navBar.classList.remove("shadow", "bg-background");
navBar.classList.add("bg-grid");
navBrand.classList.add("pointer-events-none");
navBrand.classList.remove("opacity-100");
}
};
window.addEventListener("scroll", navBarSrolled);