Spaces:
Running
Running
| class HeaderApp extends HTMLElement { | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| :host { | |
| display: block; | |
| } | |
| * { | |
| margin: 0; | |
| padding: 0; | |
| box-sizing: border-box; | |
| } | |
| header { | |
| background-color: white; | |
| box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); | |
| position: sticky; | |
| top: 0; | |
| z-index: 100; | |
| } | |
| .container { | |
| max-width: 1200px; | |
| margin: 0 auto; | |
| padding: 0 20px; | |
| } | |
| nav { | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| padding: 20px 0; | |
| } | |
| .logo { | |
| font-size: 1.8rem; | |
| font-weight: 700; | |
| color: #ef4444; | |
| text-decoration: none; | |
| display: flex; | |
| align-items: center; | |
| } | |
| .logo i { | |
| margin-right: 10px; | |
| } | |
| .nav-links { | |
| display: flex; | |
| list-style: none; | |
| } | |
| .nav-links li { | |
| margin-left: 30px; | |
| } | |
| .nav-links a { | |
| text-decoration: none; | |
| color: #333; | |
| font-weight: 500; | |
| transition: color 0.3s; | |
| } | |
| .nav-links a:hover { | |
| color: #ef4444; | |
| } | |
| .auth-buttons { | |
| display: flex; | |
| align-items: center; | |
| } | |
| .btn { | |
| padding: 10px 20px; | |
| border-radius: 30px; | |
| font-weight: 500; | |
| cursor: pointer; | |
| transition: all 0.3s; | |
| text-decoration: none; | |
| display: inline-block; | |
| text-align: center; | |
| } | |
| .btn-outline { | |
| border: 2px solid #ef4444; | |
| color: #ef4444; | |
| margin-right: 15px; | |
| } | |
| .btn-outline:hover { | |
| background-color: #ef4444; | |
| color: white; | |
| } | |
| .btn-primary { | |
| background-color: #ef4444; | |
| color: white; | |
| border: 2px solid #ef4444; | |
| } | |
| .btn-primary:hover { | |
| background-color: #dc2626; | |
| border-color: #dc2626; | |
| } | |
| .mobile-menu-btn { | |
| display: none; | |
| background: none; | |
| border: none; | |
| font-size: 1.5rem; | |
| cursor: pointer; | |
| color: #333; | |
| } | |
| @media (max-width: 768px) { | |
| .nav-links { | |
| display: none; | |
| position: absolute; | |
| top: 70px; | |
| left: 0; | |
| width: 100%; | |
| background: white; | |
| flex-direction: column; | |
| padding: 20px; | |
| box-shadow: 0 5px 10px rgba(0,0,0,0.1); | |
| } | |
| .nav-links.active { | |
| display: flex; | |
| } | |
| .nav-links li { | |
| margin: 10px 0; | |
| } | |
| .auth-buttons { | |
| display: none; | |
| } | |
| .mobile-menu-btn { | |
| display: block; | |
| } | |
| } | |
| </style> | |
| <header> | |
| <div class="container"> | |
| <nav> | |
| <a href="#" class="logo"> | |
| <i data-feather="gift"></i> | |
| <span>InviteCraft</span> | |
| </a> | |
| <ul class="nav-links"> | |
| <li><a href="#">Home</a></li> | |
| <li><a href="#templates">Templates</a></li> | |
| <li><a href="#">Features</a></li> | |
| <li><a href="#">Pricing</a></li> | |
| <li><a href="#">Contact</a></li> | |
| </ul> | |
| <div class="auth-buttons"> | |
| <a href="#" class="btn btn-outline">Log In</a> | |
| <a href="#" class="btn btn-primary">Sign Up Free</a> | |
| </div> | |
| <button class="mobile-menu-btn"> | |
| <i data-feather="menu"></i> | |
| </button> | |
| </nav> | |
| </div> | |
| </header> | |
| `; | |
| // Mobile menu toggle functionality | |
| setTimeout(() => { | |
| const mobileMenuBtn = this.shadowRoot.querySelector('.mobile-menu-btn'); | |
| const navLinks = this.shadowRoot.querySelector('.nav-links'); | |
| mobileMenuBtn.addEventListener('click', () => { | |
| navLinks.classList.toggle('active'); | |
| const menuIcon = mobileMenuBtn.querySelector('i'); | |
| if (navLinks.classList.contains('active')) { | |
| menuIcon.setAttribute('data-feather', 'x'); | |
| } else { | |
| menuIcon.setAttribute('data-feather', 'menu'); | |
| } | |
| feather.replace(); | |
| }); | |
| }, 0); | |
| } | |
| } | |
| customElements.define('header-app', HeaderApp); |