Update main.js

This commit is contained in:
Nithin A 2024-03-28 17:40:30 +05:30 committed by GitHub
parent e8f4881356
commit e9bf79f65c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,42 +1,44 @@
const navItem =document.querySelector(".nav__items");
const openNavBtn =document.querySelector("#open__nav-btn");
const closeNavBtn =document.querySelector("#close__nav-btn");
const openNav =()=>{
navItem.style.display="flex";
openNavBtn.style.display="none";
closeNavBtn.style.display="inline-block";
try {
const navItem = document.querySelector(".nav__items");
const openNavBtn = document.querySelector("#open__nav-btn");
const closeNavBtn = document.querySelector("#close__nav-btn");
const openNav = () => {
navItem.style.display = "flex";
openNavBtn.style.display = "none";
closeNavBtn.style.display = "inline-block";
};
const closeNav = () => {
navItem.style.display = "none";
openNavBtn.style.display = "inline-block";
closeNavBtn.style.display = "none";
};
openNavBtn.addEventListener("click", openNav);
closeNavBtn.addEventListener("click", closeNav);
} catch (error) {
// console.error("Error occurred in toggle functionality:", error);
}
const closeNav=()=>{
navItem.style.display="none";
openNavBtn.style.display="inline-block";
closeNavBtn.style.display="none";
}
openNavBtn.addEventListener("click", openNav)
closeNavBtn.addEventListener("click", closeNav)
if (window.innerWidth <= 600)
try {
const sidebar = document.querySelector("aside");
const showSidebarBtn = document.querySelector("#show__sidebar-btn");
const hideSidebarBtn = document.querySelector("#hide__sidebar-btn");
const showSidebar = () => {
sidebar.style.left = "0";
showSidebarBtn.style.display = "none";
hideSidebarBtn.style.display = "inline-block";
};
const sidebar = document.querySelector("aside");
const showSidebarBtn = document.querySelector("#show__sidebar-btn");
const hideSidebarBtn = document.querySelector("#hide__sidebar-btn");
const hideSidebar = () => {
sidebar.style.left = "-100%";
showSidebarBtn.style.display = "inline-block";
hideSidebarBtn.style.display = "none";
};
showSidebarBtn.addEventListener("click", showSidebar);
hideSidebarBtn.addEventListener("click", hideSidebar);
const showSidebar = () => {
sidebar.style.left = "0";
showSidebarBtn.style.display="none";
hideSidebarBtn.style.display='inline-block';
}
const hideSidebar = () => {
sidebar.style.left = "-100%";
showSidebarBtn.style.display="inline-block";
hideSidebarBtn.style.display="none";
}
showSidebarBtn.addEventListener("click", showSidebar);
hideSidebarBtn.addEventListener("click", hideSidebar);
window.onload = showSidebar;
} catch (error) {
// console.error("Error occurred in sidebar functionality:", error);
}