Download components/header.js from GD-Huggingfaces/power-design-clone-sparkles: direct link, hf CLI and curl.
- Browser
- Download file 4.73 kB
-
https://huggingface.co/spaces/GD-Huggingfaces/power-design-clone-sparkles/resolve/main/components/header.js
- Command line
-
hf download hf://spaces/GD-Huggingfaces/power-design-clone-sparkles/components/header.js
-
curl -L -o header.js https://huggingface.co/spaces/GD-Huggingfaces/power-design-clone-sparkles/resolve/main/components/header.js
4.73 kB
| class CustomHeader extends HTMLElement { | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| .nav-link { | |
| position: relative; | |
| } | |
| .nav-link:after { | |
| content: ''; | |
| position: absolute; | |
| width: 0; | |
| height: 2px; | |
| bottom: 0; | |
| left: 0; | |
| background-color: #FF6600; | |
| transition: width 0.3s ease; | |
| } | |
| .nav-link:hover:after { | |
| width: 100%; | |
| } | |
| .mobile-menu { | |
| transition: all 0.3s ease-in-out; | |
| } | |
| </style> | |
| <header class="bg-white shadow-md fixed w-full z-50"> | |
| <div class="container mx-auto px-6 py-4"> | |
| <div class="flex items-center justify-between"> | |
| <!-- Logo --> | |
| <a href="/" class="flex items-center"> | |
| <div class="w-10 h-10 bg-primary-500 rounded-full flex items-center justify-center mr-3"> | |
| <i data-feather="zap" class="text-white"></i> | |
| </div> | |
| <span class="text-xl font-bold text-gray-800">Power Design</span> | |
| </a> | |
| <!-- Desktop Navigation --> | |
| <nav class="hidden md:flex items-center space-x-8"> | |
| <a href="/" class="nav-link text-gray-800 hover:text-primary-500 font-medium">Home</a> | |
| <a href="/about" class="nav-link text-gray-800 hover:text-primary-500 font-medium">About</a> | |
| <a href="/services" class="nav-link text-gray-800 hover:text-primary-500 font-medium">Services</a> | |
| <a href="/projects" class="nav-link text-gray-800 hover:text-primary-500 font-medium">Projects</a> | |
| <a href="/contact" class="nav-link text-gray-800 hover:text-primary-500 font-medium">Contact</a> | |
| <a href="/contact" class="bg-primary-500 hover:bg-primary-600 text-white font-medium py-2 px-6 rounded-md transition duration-200">Get a Quote</a> | |
| </nav> | |
| <!-- Mobile Menu Button --> | |
| <button class="md:hidden focus:outline-none" id="mobile-menu-button"> | |
| <i data-feather="menu" class="w-6 h-6 text-gray-800"></i> | |
| </button> | |
| </div> | |
| <!-- Mobile Menu --> | |
| <div class="mobile-menu hidden md:hidden mt-4" id="mobile-menu"> | |
| <div class="flex flex-col space-y-4"> | |
| <a href="/" class="text-gray-800 hover:text-primary-500 font-medium">Home</a> | |
| <a href="/about" class="text-gray-800 hover:text-primary-500 font-medium">About</a> | |
| <a href="/services" class="text-gray-800 hover:text-primary-500 font-medium">Services</a> | |
| <a href="/projects" class="text-gray-800 hover:text-primary-500 font-medium">Projects</a> | |
| <a href="/contact" class="text-gray-800 hover:text-primary-500 font-medium">Contact</a> | |
| <a href="/contact" class="bg-primary-500 hover:bg-primary-600 text-white font-medium py-2 px-6 rounded-md text-center transition duration-200">Get a Quote</a> | |
| </div> | |
| </div> | |
| </div> | |
| </header> | |
| `; | |
| // Add mobile menu toggle functionality | |
| const mobileMenuButton = this.shadowRoot.getElementById('mobile-menu-button'); | |
| const mobileMenu = this.shadowRoot.getElementById('mobile-menu'); | |
| mobileMenuButton.addEventListener('click', () => { | |
| const isOpen = mobileMenu.classList.contains('hidden'); | |
| if (isOpen) { | |
| mobileMenu.classList.remove('hidden'); | |
| feather.replace(); | |
| this.shadowRoot.querySelector('#mobile-menu-button i').setAttribute('data-feather', 'x'); | |
| } else { | |
| mobileMenu.classList.add('hidden'); | |
| feather.replace(); | |
| this.shadowRoot.querySelector('#mobile-menu-button i').setAttribute('data-feather', 'menu'); | |
| } | |
| feather.replace(); | |
| }); | |
| } | |
| } | |
| customElements.define('custom-header', CustomHeader); |