Menu Architecture
The menu system consists of three main components:- Menu Configuration (
assets/scripts/mega-menu-spa.js) - Core menu logic - Menu HTML Structure (
shared/components/mega-menu/mega-menu.html) - Menu markup - Menu Styles (
shared/components/mega-menu/mega-menu.css) - Visual styling
Menu Configuration
The menu behavior is configured inassets/scripts/mega-menu-spa.js:
assets/scripts/mega-menu-spa.js:1-14
Configuration Options
| Property | Description | Default Value |
|---|---|---|
el.nav | Main navigation container | #main-nav |
el.barraTop | Top bar for mobile navigation | .mega-topbar |
el.btnVolver | Back button selector | .back-btn |
el.btnCerrar | Close button selector | .close-btn |
el.botones | Menu trigger buttons | a[data-name] |
el.submenus | Mega menu containers | .mega-menu |
viewport.movil | Mobile breakpoint in pixels | 768 |
Menu HTML Structure
The mega menu uses a two-part structure: menu buttons and menu panels.Menu Buttons
Menu trigger buttons usedata-name and data-mega attributes:
data-name: Used for hover detection on desktopdata-mega: CSS selector for the corresponding mega menu panel
Mega Menu Panels
Each mega menu panel contains a sidebar and main content area:shared/components/mega-menu/mega-menu.html:4-40
Adding a New Menu Section
Step 1: Add Menu Button
Add a new trigger button in your navigation:Step 2: Create Menu Panel
Add the corresponding mega menu panel:Menu Behavior
The menu system handles different behaviors for mobile and desktop:Desktop Behavior (Hover)
assets/scripts/mega-menu-spa.js:51-59
- Sets
data-megaattribute on navbar - Applies dynamic CSS to show the panel
- Panel remains visible while hovering menu or panel
Mobile Behavior (Click)
assets/scripts/mega-menu-spa.js:40-48
- Prevents default link behavior
- Opens the mega menu panel
- Shows back button and top bar
- Locks body scroll
Menu State Management
The menu system maintains state using JavaScript variables:assets/scripts/mega-menu-spa.js:17-18
Opening a Menu
assets/scripts/mega-menu-spa.js:110-119
Closing the Menu
assets/scripts/mega-menu-spa.js:88-98
Dynamic Styling
The menu uses runtime CSS injection for hover effects:assets/scripts/mega-menu-spa.js:122-136
<style> tag that shows the menu panel when hovering the button or panel itself.
Web Component Version
The system also includes a Web Component version with enhanced features:shared/components/mega-menu/mega-menu.js:5-41
shared/components/mega-menu/mega-menu.js:1-325 for the complete Web Component implementation.
Existing Menu Sections
The default menu includes three sections:1. Diseño y Media (#Diseno)
- Branding
- Studio Multimedia
- Publicidad
2. Tecnología (#Tecnologia)
- Desarrollo Web
- Apps Móviles
- E-commerce
3. Marketing (#Marketing)
- Social Media
- SEO/SEM
- Content Strategy
shared/components/mega-menu/mega-menu.html:1-119 for the complete markup.
Customization Tips
- Featured Images: Use emoji or gradient backgrounds for visual impact
- Consistent Structure: Keep the sidebar + main layout for familiarity
- Responsive Icons: Use SVG icons for crisp display at any size
- Hover States: CSS handles hover styling automatically via dynamic injection
- Mobile First: Test mobile navigation thoroughly as it uses different patterns
Scroll Lock Integration
The menu integrates with a scroll lock utility to prevent body scrolling:Related Files
- Menu Configuration:
assets/scripts/mega-menu-spa.js - Menu HTML:
shared/components/mega-menu/mega-menu.html - Menu Styles:
shared/components/mega-menu/mega-menu.css - Web Component:
shared/components/mega-menu/mega-menu.js - Scroll Lock:
assets/scripts/scroll-lock.js

