| class CustomNavbar extends HTMLElement { | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| .navbar { | |
| transition: all 0.3s ease; | |
| } | |
| .navbar.scrolled { | |
| @apply shadow-md bg-white; | |
| } | |
| .nav-link { | |
| position: relative; | |
| } | |
| .nav-link::after { | |
| content: ''; | |
| position: absolute; | |
| width: 0; | |
| height: 2px; | |
| bottom: -2px; | |
| left: 0; | |
| background-color: #6366f1; | |
| transition: width 0.3s ease; | |
| } | |
| .nav-link:hover::after { | |
| width: 100%; | |
| } | |
| .mobile-menu { | |
| max-height: 0; | |
| overflow: hidden; | |
| transition: max-height 0.3s ease-out; | |
| } | |
| .mobile-menu.open { | |
| max-height: 500px; | |
| } | |
| </style> | |
| <nav class="navbar fixed w-full z-50 bg-white/80 backdrop-blur-sm"> | |
| <div class="container mx-auto px-4 py-4"> | |
| <div class="flex justify-between items-center"> | |
| <a href="/" class="flex items-center"> | |
| <i data-feather="shield" class="text-indigo-600 mr-2"></i> | |
| <span class="text-xl font-bold text-gray-800">TrackMeNot</span> | |
| </a> | |
| <div class="hidden md:flex items-center space-x-8"> | |
| <a href="#features" class="nav-link text-gray-600 hover:text-gray-900">Features</a> | |
| <a href="#how-it-works" class="nav-link text-gray-600 hover:text-gray-900">How It Works</a> | |
| <a href="#download" class="nav-link text-gray-600 hover:text-gray-900">Download</a> | |
| <a href="#" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg font-medium transition duration-300">Get Started</a> | |
| </div> | |
| <button id="mobile-menu-button" class="md:hidden text-gray-600 focus:outline-none"> | |
| <i data-feather="menu"></i> | |
| </button> | |
| </div> | |
| <div id="mobile-menu" class="mobile-menu md:hidden"> | |
| <div class="pt-4 pb-2 space-y-2"> | |
| <a href="#features" class="block px-3 py-2 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100">Features</a> | |
| <a href="#how-it-works" class="block px-3 py-2 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100">How It Works</a> | |
| <a href="#download" class="block px-3 py-2 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100">Download</a> | |
| <a href="#" class="block mt-2 bg-indigo-600 text-white px-4 py-2 rounded-lg font-medium text-center">Get Started</a> | |
| </div> | |
| </div> | |
| </div> | |
| </nav> | |
| <script> | |
| feather.replace(); | |
| document.addEventListener('DOMContentLoaded', function() { | |
| const mobileMenuButton = this.shadowRoot.getElementById('mobile-menu-button'); | |
| const mobileMenu = this.shadowRoot.getElementById('mobile-menu'); | |
| mobileMenuButton.addEventListener('click', function() { | |
| mobileMenu.classList.toggle('open'); | |
| const icon = mobileMenuButton.querySelector('i'); | |
| if (mobileMenu.classList.contains('open')) { | |
| icon.setAttribute('data-feather', 'x'); | |
| } else { | |
| icon.setAttribute('data-feather', 'menu'); | |
| } | |
| feather.replace(); | |
| }); | |
| // Change navbar style on scroll | |
| window.addEventListener('scroll', function() { | |
| const navbar = this.shadowRoot.querySelector('.navbar'); | |
| if (window.scrollY > 10) { | |
| navbar.classList.add('scrolled'); | |
| } else { | |
| navbar.classList.remove('scrolled'); | |
| } | |
| }); | |
| }); | |
| </script> | |
| `; | |
| } | |
| } | |
| customElements.define('custom-navbar', CustomNavbar); |