Spaces:
Running
Running
Download components/header.js from x1232/applander-pro: direct link, hf CLI and curl.
- Browser
- Download file 4.21 kB
-
https://huggingface.co/spaces/x1232/applander-pro/resolve/main/components/header.js
- Command line
-
hf download hf://spaces/x1232/applander-pro/components/header.js
-
curl -L -o header.js https://huggingface.co/spaces/x1232/applander-pro/resolve/main/components/header.js
4.21 kB
| class CustomHeader extends HTMLElement { | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| :host { | |
| display: block; | |
| } | |
| .header { | |
| background-color: white; | |
| box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); | |
| position: sticky; | |
| top: 0; | |
| z-index: 50; | |
| } | |
| .nav-link { | |
| color: #4b5563; | |
| font-weight: 500; | |
| transition: color 0.3s; | |
| position: relative; | |
| } | |
| .nav-link:hover { | |
| color: #6366f1; | |
| } | |
| .nav-link::after { | |
| content: ''; | |
| position: absolute; | |
| bottom: -5px; | |
| left: 0; | |
| width: 0; | |
| height: 2px; | |
| background-color: #6366f1; | |
| transition: width 0.3s; | |
| } | |
| .nav-link:hover::after { | |
| width: 100%; | |
| } | |
| .mobile-menu { | |
| display: none; | |
| } | |
| @media (max-width: 768px) { | |
| .desktop-menu { | |
| display: none; | |
| } | |
| .mobile-menu { | |
| display: block; | |
| } | |
| } | |
| </style> | |
| <header class="header"> | |
| <div class="container mx-auto px-4"> | |
| <div class="flex items-center justify-between h-20"> | |
| <div class="flex items-center"> | |
| <a href="/" class="text-2xl font-bold text-indigo-600">AppLander<span class="text-gray-900">Pro</span></a> | |
| </div> | |
| <div class="desktop-menu"> | |
| <nav class="flex space-x-8"> | |
| <a href="#" class="nav-link">Features</a> | |
| <a href="#" class="nav-link">How It Works</a> | |
| <a href="#" class="nav-link">Pricing</a> | |
| <a href="#" class="nav-link">Testimonials</a> | |
| </nav> | |
| </div> | |
| <div class="flex items-center space-x-4"> | |
| <a href="#" class="text-gray-600 hover:text-gray-900 font-medium">Sign In</a> | |
| <a href="#" class="bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-2 px-6 rounded-lg transition duration-300">Get Started</a> | |
| <div class="mobile-menu"> | |
| <button id="mobile-menu-button" class="text-gray-500 hover:text-gray-900"> | |
| <i data-feather="menu" class="w-6 h-6"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Mobile menu --> | |
| <div id="mobile-menu" class="hidden md:hidden"> | |
| <div class="px-2 pt-2 pb-3 space-y-1 sm:px-3"> | |
| <a href="#" class="block px-3 py-2 rounded-md text-base font-medium text-gray-700 hover:text-gray-900 hover:bg-gray-50">Features</a> | |
| <a href="#" class="block px-3 py-2 rounded-md text-base font-medium text-gray-700 hover:text-gray-900 hover:bg-gray-50">How It Works</a> | |
| <a href="#" class="block px-3 py-2 rounded-md text-base font-medium text-gray-700 hover:text-gray-900 hover:bg-gray-50">Pricing</a> | |
| <a href="#" class="block px-3 py-2 rounded-md text-base font-medium text-gray-700 hover:text-gray-900 hover:bg-gray-50">Testimonials</a> | |
| </div> | |
| </div> | |
| </header> | |
| `; | |
| // Add mobile menu toggle functionality | |
| setTimeout(() => { | |
| const menuButton = this.shadowRoot.getElementById('mobile-menu-button'); | |
| const mobileMenu = this.shadowRoot.getElementById('mobile-menu'); | |
| if (menuButton && mobileMenu) { | |
| menuButton.addEventListener('click', () => { | |
| const isExpanded = menuButton.getAttribute('aria-expanded') === 'true'; | |
| menuButton.setAttribute('aria-expanded', !isExpanded); | |
| mobileMenu.classList.toggle('hidden'); | |
| // Toggle feather icons | |
| const menuIcon = menuButton.querySelector('i'); | |
| if (menuIcon) { | |
| menuIcon.setAttribute('data-feather', isExpanded ? 'menu' : 'x'); | |
| feather.replace(); | |
| } | |
| }); | |
| } | |
| }, 0); | |
| } | |
| } | |
| customElements.define('custom-header', CustomHeader); |