diff --git a/src/layout/Navbar.svelte b/src/layout/Navbar.svelte index 78481dc..62b354e 100644 --- a/src/layout/Navbar.svelte +++ b/src/layout/Navbar.svelte @@ -6,6 +6,7 @@ Section, } from "$components"; import { navigate, getPath, currentLang, text, switchLang } from "$lib"; + import { onDestroy } from "svelte"; // Icon imports (Lucide) import Coffee from "lucide-svelte/icons/coffee"; @@ -16,11 +17,54 @@ import Bot from "lucide-svelte/icons/bot"; import HandHeart from "lucide-svelte/icons/hand-heart"; import Trophy from "lucide-svelte/icons/trophy"; + import Menu from "lucide-svelte/icons/menu"; + import X from "lucide-svelte/icons/x"; + + let mobileMenuOpen = false; + + // Reactively control body scroll + $: if (typeof document !== 'undefined') { + if (mobileMenuOpen) { + document.body.style.overflow = 'hidden'; + document.body.style.position = 'fixed'; + document.body.style.width = '100%'; + document.documentElement.style.overflow = 'hidden'; + } else { + document.body.style.overflow = ''; + document.body.style.position = ''; + document.body.style.width = ''; + document.documentElement.style.overflow = ''; + } + } + + // Cleanup on component destroy + onDestroy(() => { + if (typeof document !== 'undefined') { + document.body.style.overflow = ''; + document.body.style.position = ''; + document.body.style.width = ''; + document.documentElement.style.overflow = ''; + } + }); + + function toggleMobileMenu() { + mobileMenuOpen = !mobileMenuOpen; + } + + function closeMobileMenu() { + mobileMenuOpen = false; + } + + function handleNavigation(path, options = {}) { + navigate(path, options); + closeMobileMenu(); + }
-
+ + +{#if mobileMenuOpen} +
+ +
+ +
+ + + +
+{/if}