From 656465be3fcab6bcfcaaea91d95f3fa696b56b8d Mon Sep 17 00:00:00 2001 From: Keep Creating Online <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Fri, 7 Feb 2025 13:02:02 -0500 Subject: [PATCH] updated mobile sidebar --- js/sidebar.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/js/sidebar.js b/js/sidebar.js index 8069dd3..adb6f5c 100644 --- a/js/sidebar.js +++ b/js/sidebar.js @@ -1,5 +1,5 @@ -// js/sidebar.js -import { setHashView } from "./index.js"; // <--- or wherever you put it +// sidebar.js +import { setHashView } from "./index.js"; export function setupSidebarNavigation() { const sidebarLinks = document.querySelectorAll('#sidebar a[href^="#view="]'); @@ -13,9 +13,17 @@ export function setupSidebarNavigation() { if (!match) return; const viewName = match[1]; // "about", "ipns", etc. - setHashView(viewName); - // That removes ?modal=, ?v=, sets #view=viewName, - // and triggers handleHashChange() automatically + setHashView(viewName); // This changes the hash and loads the view. + + // --- NEW: if on mobile, close the sidebar automatically. --- + if (window.innerWidth < 768) { + const sidebar = document.getElementById("sidebar"); + const app = document.getElementById("app"); + if (sidebar && app) { + sidebar.classList.remove("sidebar-open"); + app.classList.remove("sidebar-open"); + } + } }); }); }