Spaces:
Running
Running
Download components/header.js from mopcdk/fyns-it-powerboost: direct link, hf CLI and curl.
- Browser
- Download file 4.17 kB
-
https://huggingface.co/spaces/mopcdk/fyns-it-powerboost/resolve/main/components/header.js
- Command line
-
hf download hf://spaces/mopcdk/fyns-it-powerboost/components/header.js
-
curl -L -o header.js https://huggingface.co/spaces/mopcdk/fyns-it-powerboost/resolve/main/components/header.js
4.17 kB
| class CustomHeader extends HTMLElement { | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| :host { | |
| display: block; | |
| width: 100%; | |
| position: sticky; | |
| top: 0; | |
| z-index: 50; | |
| background-color: white; | |
| box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1); | |
| transition: all 0.3s ease; | |
| } | |
| :host(.scrolled) { | |
| box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); | |
| } | |
| nav { | |
| max-width: 1280px; | |
| margin: 0 auto; | |
| padding: 1rem 2rem; | |
| } | |
| .nav-link { | |
| position: relative; | |
| transition: color 0.3s ease; | |
| } | |
| .nav-link:hover { | |
| color: #2563eb; | |
| } | |
| .nav-link::after { | |
| content: ''; | |
| position: absolute; | |
| bottom: -4px; | |
| left: 0; | |
| width: 0; | |
| height: 2px; | |
| background: linear-gradient(to right, #2563eb, #7c3aed); | |
| transition: width 0.3s ease; | |
| } | |
| .nav-link:hover::after { | |
| width: 100%; | |
| } | |
| .mobile-menu { | |
| display: none; | |
| transition: all 0.3s ease; | |
| } | |
| .mobile-menu.open { | |
| display: block; | |
| } | |
| .hamburger { | |
| transition: all 0.3s ease; | |
| } | |
| .hamburger.active { | |
| transform: rotate(90deg); | |
| } | |
| </style> | |
| <nav> | |
| <div class="flex justify-between items-center"> | |
| <a href="/" class="flex items-center"> | |
| <div class="bg-gradient-to-r from-primary to-secondary p-2 rounded-xl mr-3"> | |
| <i data-feather="cpu" class="text-white w-6 h-6"></i> | |
| </div> | |
| <span class="text-xl font-bold text-gray-900">Fyns IT</span> | |
| </a> | |
| <div class="hidden md:flex items-center space-x-8"> | |
| <a href="/" class="nav-link text-gray-700 hover:text-primary font-medium">Hjem</a> | |
| <a href="#ydelser" class="nav-link text-gray-700 hover:text-primary font-medium">Ydelser</a> | |
| <a href="#om-os" class="nav-link text-gray-700 hover:text-primary font-medium">Om os</a> | |
| <a href="#kontakt" class="nav-link text-gray-700 hover:text-primary font-medium">Kontakt</a> | |
| <a href="#kontakt" class="bg-primary hover:bg-blue-700 text-white font-medium py-2 px-6 rounded-lg transition duration-300 shadow hover:shadow-md">Få tilbud</a> | |
| </div> | |
| <button id="mobile-menu-button" class="md:hidden text-gray-700 hamburger"> | |
| <i data-feather="menu" class="w-6 h-6"></i> | |
| </button> | |
| </div> | |
| <div id="mobile-menu" class="mobile-menu mt-4 hidden"> | |
| <div class="flex flex-col space-y-4"> | |
| <a href="/" class="nav-link text-gray-700 hover:text-primary font-medium py-2">Hjem</a> | |
| <a href="#ydelser" class="nav-link text-gray-700 hover:text-primary font-medium py-2">Ydelser</a> | |
| <a href="#om-os" class="nav-link text-gray-700 hover:text-primary font-medium py-2">Om os</a> | |
| <a href="#kontakt" class="nav-link text-gray-700 hover:text-primary font-medium py-2">Kontakt</a> | |
| <a href="#kontakt" class="bg-primary hover:bg-blue-700 text-white font-medium py-3 px-6 rounded-lg transition duration-300 text-center mt-2">Få tilbud</a> | |
| </div> | |
| </div> | |
| </nav> | |
| `; | |
| const mobileMenuButton = this.shadowRoot.getElementById('mobile-menu-button'); | |
| const mobileMenu = this.shadowRoot.getElementById('mobile-menu'); | |
| mobileMenuButton.addEventListener('click', () => { | |
| mobileMenu.classList.toggle('open'); | |
| mobileMenuButton.classList.toggle('active'); | |
| feather.replace(); | |
| }); | |
| // Header scroll effect | |
| window.addEventListener('scroll', () => { | |
| if (window.scrollY > 10) { | |
| this.classList.add('scrolled'); | |
| } else { | |
| this.classList.remove('scrolled'); | |
| } | |
| }); | |
| } | |
| } | |
| } | |
| customElements.define('custom-header', CustomHeader); | |