| class CustomHeader extends HTMLElement { |
| connectedCallback() { |
| this.attachShadow({ mode: 'open' }); |
| this.shadowRoot.innerHTML = ` |
| <style> |
| :host { |
| display: block; |
| width: 100%; |
| } |
| |
| header { |
| background: rgba(17, 24, 39, 0.8); |
| backdrop-filter: blur(10px); |
| border-bottom: 1px solid rgba(255, 255, 255, 0.1); |
| } |
| |
| .nav-link { |
| position: relative; |
| transition: all 0.3s ease; |
| } |
| |
| .nav-link:hover { |
| color: #0ea5e9; |
| } |
| |
| .nav-link::after { |
| content: ''; |
| position: absolute; |
| bottom: -2px; |
| left: 0; |
| width: 0; |
| height: 2px; |
| background: #0ea5e9; |
| transition: width 0.3s ease; |
| } |
| |
| .nav-link:hover::after { |
| width: 100%; |
| } |
| |
| .mobile-menu { |
| transform: translateX(-100%); |
| transition: transform 0.3s ease; |
| } |
| |
| .mobile-menu.open { |
| transform: translateX(0); |
| } |
| |
| @media (max-width: 768px) { |
| .desktop-nav { |
| display: none; |
| } |
| } |
| </style> |
| |
| <header class="sticky top-0 z-50"> |
| <nav class="container mx-auto px-4 py-4"> |
| <div class="flex items-center justify-between"> |
| <!-- Logo --> |
| <div class="flex items-center space-x-2"> |
| <i data-feather="moon" class="w-8 h-8 text-primary-400"></i> |
| <span class="text-xl font-bold bg-gradient-to-r from-primary-400 to-secondary-500 bg-clip-text text-transparent"> |
| Celestial Symphony |
| </span> |
| </div> |
| |
| <!-- Desktop Navigation --> |
| <div class="desktop-nav hidden md:flex items-center space-x-8"> |
| <a href="#demo" class="nav-link text-gray-300 hover:text-primary-300"> |
| <i data-feather="play" class="w-4 h-4 inline mr-2"></i> |
| Demo |
| </a> |
| <a href="#documentation" class="nav-link text-gray-300 hover:text-primary-300"> |
| <i data-feather="book" class="w-4 h-4 inline mr-2"></i> |
| Docs |
| </a> |
| <a href="#" class="nav-link text-gray-300 hover:text-primary-300"> |
| <i data-feather="download" class="w-4 h-4 inline mr-2"></i> |
| Download |
| </a> |
| </div> |
| |
| <!-- Mobile Menu Button --> |
| <button id="mobileMenuBtn" class="md:hidden text-gray-300 hover:text-primary-300"> |
| <i data-feather="menu" class="w-6 h-6"></i> |
| </button> |
| </div> |
| |
| <!-- Mobile Navigation --> |
| <div id="mobileMenu" class="mobile-menu fixed inset-y-0 left-0 w-64 bg-gray-900 p-6 md:hidden"> |
| <div class="flex justify-between items-center mb-8"> |
| <span class="text-lg font-bold text-primary-300">Menu</span> |
| <button id="closeMobileMenu" class="text-gray-400 hover:text-white"> |
| <i data-feather="x" class="w-6 h-6"></i> |
| </div> |
| |
| <div class="space-y-6"> |
| <a href="#demo" class="block nav-link text-gray-300 hover:text-primary-300"> |
| <i data-feather="play" class="w-4 h-4 inline mr-3"></i> |
| Live Demo |
| </a> |
| <a href="#documentation" class="block nav-link text-gray-300 hover:text-primary-300"> |
| <i data-feather="book" class="w-4 h-4 inline mr-3"></i> |
| Documentation |
| </a> |
| <a href="#" class="block nav-link text-gray-300 hover:text-primary-300"> |
| <i data-feather="download" class="w-4 h-4 inline mr-3"></i> |
| Download Package |
| </a> |
| </div> |
| |
| <div class="absolute bottom-6 left-6 right-6"> |
| <div class="flex items-center space-x-4 text-sm text-gray-400"> |
| <i data-feather="github" class="w-4 h-4"></i> |
| <span>View on GitHub</span> |
| </div> |
| </div> |
| </div> |
| </nav> |
| </header> |
| |
| <script> |
| // Initialize mobile menu functionality |
| document.addEventListener('DOMContentLoaded', () => { |
| const mobileMenuBtn = this.shadowRoot.getElementById('mobileMenuBtn'); |
| const closeMobileMenu = this.shadowRoot.getElementById('closeMobileMenu'); |
| const mobileMenu = this.shadowRoot.getElementById('mobileMenu'); |
| |
| mobileMenuBtn?.addEventListener('click', () => { |
| mobileMenu?.classList.add('open'); |
| }); |
| |
| closeMobileMenu?.addEventListener('click', () => { |
| mobileMenu?.classList.remove('open'); |
| }); |
| |
| // Close mobile menu when clicking outside |
| document.addEventListener('click', (e) => { |
| if (!mobileMenu?.contains(e.target) && !mobileMenuBtn?.contains(e.target)) { |
| mobileMenu?.classList.remove('open'); |
| } |
| }); |
| }); |
| </script> |
| `; |
| |
| |
| setTimeout(() => { |
| if (window.feather) { |
| window.feather.replace({ scope: this.shadowRoot }); |
| }, 100); |
| } |
| } |
|
|
| customElements.define('custom-header', CustomHeader); |