Spaces:
Running
Running
| class CustomNavbar extends HTMLElement { | |
| constructor() { | |
| super(); | |
| this.attachShadow({ mode: 'open' }); | |
| } | |
| connectedCallback() { | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| :host { | |
| display: block; | |
| position: fixed; | |
| top: 0; | |
| left: 0; | |
| right: 0; | |
| z-index: 1000; | |
| } | |
| .navbar { | |
| background: linear-gradient(135deg, rgba(31, 41, 55, 0.95) 0%, rgba(17, 24, 39, 0.95) 100%); | |
| backdrop-filter: blur(10px); | |
| border-bottom: 1px solid rgba(255, 255, 255, 0.1); | |
| transition: all 0.3s ease; | |
| } | |
| .container { | |
| max-width: 1280px; | |
| margin: 0 auto; | |
| padding: 0 1rem; | |
| } | |
| .nav-content { | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| height: 5rem; | |
| } | |
| .logo { | |
| display: flex; | |
| align-items: center; | |
| gap: 0.75rem; | |
| text-decoration: none; | |
| color: white; | |
| font-size: 1.5rem; | |
| font-weight: bold; | |
| } | |
| .logo-icon { | |
| width: 2.5rem; | |
| height: 2.5rem; | |
| background: linear-gradient(135deg, #22c55e 0%, #0ea5e9 100%); | |
| border-radius: 50%; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| } | |
| .nav-links { | |
| display: flex; | |
| gap: 2rem; | |
| list-style: none; | |
| margin: 0; | |
| padding: 0; | |
| } | |
| .nav-link { | |
| color: #d1d5db; | |
| text-decoration: none; | |
| transition: all 0.3s ease; | |
| position: relative; | |
| padding: 0.5rem 0; | |
| } | |
| .nav-link:hover { | |
| color: #22c55e; | |
| } | |
| .nav-link::after { | |
| content: ''; | |
| position: absolute; | |
| bottom: 0; | |
| left: 0; | |
| width: 0; | |
| height: 2px; | |
| background: linear-gradient(90deg, #22c55e 0%, #0ea5e9 100%); | |
| transition: width 0.3s ease; | |
| } | |
| .nav-link:hover::after { | |
| width: 100%; | |
| } | |
| .mobile-menu-btn { | |
| display: none; | |
| background: none; | |
| border: none; | |
| color: white; | |
| cursor: pointer; | |
| padding: 0.5rem; | |
| } | |
| .mobile-menu { | |
| display: none; | |
| position: absolute; | |
| top: 100%; | |
| left: 0; | |
| right: 0; | |
| background: linear-gradient(135deg, rgba(31, 41, 55, 0.98) 0%, rgba(17, 24, 39, 0.98) 100%); | |
| backdrop-filter: blur(10px); | |
| border-bottom: 1px solid rgba(255, 255, 255, 0.1); | |
| padding: 1rem 0; | |
| } | |
| .mobile-menu.active { | |
| display: block; | |
| } | |
| .mobile-nav-links { | |
| list-style: none; | |
| margin: 0; | |
| padding: 0; | |
| } | |
| .mobile-nav-link { | |
| display: block; | |
| padding: 0.75rem 1rem; | |
| color: #d1d5db; | |
| text-decoration: none; | |
| transition: all 0.3s ease; | |
| } | |
| .mobile-nav-link:hover { | |
| color: #22c55e; | |
| background: rgba(34, 197, 94, 0.1); | |
| } | |
| .cta-button { | |
| background: linear-gradient(135deg, #22c55e 0%, #0ea5e9 100%); | |
| color: white; | |
| padding: 0.75rem 1.5rem; | |
| border-radius: 9999px; | |
| text-decoration: none; | |
| transition: all 0.3s ease; | |
| font-weight: 600; | |
| } | |
| .cta-button:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 10px 20px rgba(34, 197, 94, 0.3); | |
| } | |
| @media (max-width: 768px) { | |
| .nav-links { | |
| display: none; | |
| } | |
| .mobile-menu-btn { | |
| display: block; | |
| } | |
| } | |
| </style> | |
| <nav class="navbar"> | |
| <div class="container"> | |
| <div class="nav-content"> | |
| <a href="/" class="logo"> | |
| <div class="logo-icon"> | |
| <i data-feather="smile" width="24" height="24"></i> | |
| </div> | |
| <span>SmileCraft</span> | |
| </a> | |
| <ul class="nav-links"> | |
| <li><a href="#services" class="nav-link">Services</a></li> | |
| <li><a href="#about" class="nav-link">About</a></li> | |
| <li><a href="#testimonials" class="nav-link">Testimonials</a></li> | |
| <li><a href="#gallery" class="nav-link">Gallery</a></li> | |
| <li><a href="#blog" class="nav-link">Blog</a></li> | |
| <li><a href="#contact" class="cta-button">Book Now</a></li> | |
| </ul> | |
| <button class="mobile-menu-btn" onclick="this.parentElement.parentElement.querySelector('.mobile-menu').classList.toggle('active')"> | |
| <i data-feather="menu" width="24" height="24"></i> | |
| </button> | |
| </div> | |
| <div class="mobile-menu"> | |
| <ul class="mobile-nav-links"> | |
| <li><a href="#services" class="mobile-nav-link">Services</a></li> | |
| <li><a href="#about" class="mobile-nav-link">About</a></li> | |
| <li><a href="#testimonials" class="mobile-nav-link">Testimonials</a></li> | |
| <li><a href="#gallery" class="mobile-nav-link">Gallery</a></li> | |
| <li><a href="#blog" class="mobile-nav-link">Blog</a></li> | |
| <li><a href="#contact" class="mobile-nav-link">Book Now</a></li> | |
| </ul> | |
| </div> | |
| </div> | |
| </nav> | |
| `; | |
| // Close mobile menu when clicking outside | |
| this.shadowRoot.addEventListener('click', (e) => { | |
| const mobileMenu = this.shadowRoot.querySelector('.mobile-menu'); | |
| if (mobileMenu && !mobileMenu.contains(e.target)) { | |
| mobileMenu.classList.remove('active'); | |
| } | |
| }); | |
| } | |
| disconnectedCallback() { | |
| // Cleanup | |
| } | |
| } | |
| customElements.define('custom-navbar', CustomNavbar); |