| class CustomNavbar extends HTMLElement { |
| connectedCallback() { |
| this.attachShadow({ mode: 'open' }); |
| this.shadowRoot.innerHTML = ` |
| <style> |
| * { |
| margin: 0; |
| padding: 0; |
| box-sizing: border-box; |
| } |
| |
| nav { |
| background: rgba(17, 24, 39, 0.8); |
| backdrop-filter: blur(10px); |
| border-bottom: 1px solid rgba(75, 85, 99, 0.3); |
| position: sticky; |
| top: 0; |
| z-index: 50; |
| } |
| |
| .nav-container { |
| max-width: 1280px; |
| margin: 0 auto; |
| padding: 1rem 2rem; |
| display: flex; |
| justify-content: space-between; |
| align-items: center; |
| } |
| |
| .logo { |
| display: flex; |
| align-items: center; |
| gap: 0.75rem; |
| font-size: 1.5rem; |
| font-weight: bold; |
| text-decoration: none; |
| color: white; |
| } |
| |
| .logo-icon { |
| width: 40px; |
| height: 40px; |
| background: linear-gradient(135deg, #0ea5e9, #d946ef); |
| border-radius: 0.5rem; |
| display: flex; |
| align-items: center; |
| justify-content: center; |
| animation: float 6s ease-in-out infinite; |
| } |
| |
| @keyframes float { |
| 0%, 100% { transform: translateY(0px); } |
| 50% { transform: translateY(-5px); } |
| } |
| |
| .nav-links { |
| display: flex; |
| gap: 2rem; |
| align-items: center; |
| } |
| |
| .nav-link { |
| color: #d1d5db; |
| text-decoration: none; |
| font-weight: 500; |
| transition: color 0.2s ease; |
| position: relative; |
| } |
| |
| .nav-link:hover { |
| color: #0ea5e9; |
| } |
| |
| .nav-link::after { |
| content: ''; |
| position: absolute; |
| bottom: -4px; |
| left: 0; |
| width: 0; |
| height: 2px; |
| background: linear-gradient(90deg, #0ea5e9, #d946ef); |
| transition: width 0.3s ease; |
| } |
| |
| .nav-link:hover::after { |
| width: 100%; |
| } |
| |
| .nav-link.active { |
| color: white; |
| } |
| |
| .nav-link.active::after { |
| width: 100%; |
| } |
| |
| .mobile-menu-btn { |
| display: none; |
| background: none; |
| border: none; |
| color: white; |
| cursor: pointer; |
| } |
| |
| @media (max-width: 768px) { |
| .nav-links { |
| position: fixed; |
| top: 0; |
| right: -100%; |
| width: 70%; |
| height: 100vh; |
| background: rgba(17, 24, 39, 0.98); |
| flex-direction: column; |
| justify-content: center; |
| align-items: center; |
| gap: 2rem; |
| transition: right 0.3s ease; |
| } |
| |
| .nav-links.open { |
| right: 0; |
| } |
| |
| .mobile-menu-btn { |
| display: block; |
| z-index: 51; |
| } |
| } |
| </style> |
| |
| <nav> |
| <div class="nav-container"> |
| <a href="index.html" class="logo"> |
| <div class="logo-icon"> |
| <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"> |
| <path d="M12 2L2 7L12 12L22 7L12 2Z"></path> |
| <path d="M2 17L12 22L22 17"></path> |
| <path d="M2 12L12 17L22 12"></path> |
| </svg> |
| </div> |
| TextTo3D Studio |
| </a> |
| |
| <div class="nav-links" id="navLinks"> |
| <a href="index.html" class="nav-link active">Create</a> |
| <a href="gallery.html" class="nav-link">Gallery</a> |
| <a href="#" class="nav-link">Pricing</a> |
| <a href="#" class="nav-link">About</a> |
| <button class="px-4 py-2 bg-gradient-to-r from-primary-500 to-secondary-500 text-white rounded-lg font-medium hover:from-primary-600 hover:to-secondary-600 transition-all duration-200"> |
| Sign Up |
| </button> |
| </div> |
| |
| <button class="mobile-menu-btn" id="mobileMenuBtn"> |
| <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> |
| <line x1="3" y1="12" x2="21" y2="12"></line> |
| <line x1="3" y1="6" x2="21" y2="6"></line> |
| <line x1="3" y1="18" x2="21" y2="18"></line> |
| </svg> |
| </button> |
| </div> |
| </nav> |
| `; |
| |
| |
| const mobileMenuBtn = this.shadowRoot.getElementById('mobileMenuBtn'); |
| const navLinks = this.shadowRoot.getElementById('navLinks'); |
| |
| mobileMenuBtn.addEventListener('click', () => { |
| navLinks.classList.toggle('open'); |
| }); |
| |
| |
| this.shadowRoot.querySelectorAll('.nav-link').forEach(link => { |
| link.addEventListener('click', () => { |
| navLinks.classList.remove('open'); |
| }); |
| }); |
| } |
| } |
|
|
| customElements.define('custom-navbar', CustomNavbar); |