Overview
The Navigation System is the central controller for all navigation interactions in the Klef Sonatta Website. It manages both mobile hamburger menus and desktop hover-based mega menus, providing a seamless navigation experience across devices. Source:~/workspace/source/shared/components/navigation/navigation-system.js
Key Features
Responsive Navigation
Automatically adapts between mobile drawer and desktop hover menus
iOS Scroll Lock
Prevents background scrolling on mobile using compatible scroll lock
Mega Menu Integration
Coordinates with mega menu system for rich dropdown content
Keyboard Support
ESC key closes menus and navigation overlays
Architecture
The navigation system uses a self-contained IIFE pattern with global exports for compatibility:Core Functions
toggleMenu()
Toggles the mobile navigation drawer open/closed with iOS-compatible scroll locking.- Toggles
.mobile-openclass on navbar - Integrates with ScrollLock utility for iOS compatibility
- Automatically hides Dynamic Island when menu opens
- Fallback to basic
overflow: hiddenif ScrollLock unavailable
openMegaMenu(selector)
Opens a specific mega menu panel by CSS selector.selector(string): CSS selector for the mega menu (e.g.,"#mega-brands")
- Closes all other mega menus
- Shows the mega menus container
- Activates the target menu
- Mobile: Shows topbar with back button
- Desktop: Menu appears below navbar on hover
goBack()
Navigates back from a mega menu to the main menu (mobile only).closeMenu()
Closes all navigation panels and unlocks scroll.Dynamic Styling
The navigation system injects runtime CSS for desktop hover interactions:- Enables CSS-only hover mega menus on desktop
- Injects styles at runtime based on menu configuration
- Automatically cleaned up when menu closes
Event Listeners
HTML Data Attributes
The system uses data attributes for declarative event binding:Initialization
Integration with Other Components
ScrollLock Integration
Dynamic Island Integration
Sheet System Integration
Responsive Behavior
- Mobile (≤768px)
- Desktop (>768px)
- Click hamburger → Full-screen drawer slides in
- Click mega menu item → Submenu slides over
- Back button → Return to main menu
- Close button → Exit navigation
- Scroll locked while open
Usage Example
Best Practices
Use data-action attributes for navigation controls
Use data-action attributes for navigation controls
Test across devices
Test across devices
Mobile and desktop navigation behave differently. Test hover interactions on desktop and touch/click on mobile.
Ensure ScrollLock is loaded
Ensure ScrollLock is loaded
The system falls back gracefully, but ScrollLock provides the best mobile experience, especially on iOS.
Respect the 768px breakpoint
Respect the 768px breakpoint
The system uses 768px as the mobile/desktop threshold. Ensure your CSS matches this breakpoint.
Related Components
Mega Menu
Rich dropdown menus with sections and links
Dynamic Island
Floating action bar that integrates with navigation

