|
|
class CustomNavbar extends HTMLElement { |
|
|
connectedCallback() { |
|
|
this.attachShadow({ mode: 'open' }); |
|
|
this.shadowRoot.innerHTML = ` |
|
|
<style> |
|
|
nav { |
|
|
background-color: rgba(17, 24, 39, 0.8); |
|
|
backdrop-filter: blur(8px); |
|
|
-webkit-backdrop-filter: blur(8px); |
|
|
} |
|
|
.nav-link { |
|
|
position: relative; |
|
|
} |
|
|
.nav-link::after { |
|
|
content: ''; |
|
|
position: absolute; |
|
|
bottom: -2px; |
|
|
left: 0; |
|
|
width: 0; |
|
|
height: 2px; |
|
|
background: linear-gradient(to right, #ef4444, #d946ef); |
|
|
transition: width 0.3s ease; |
|
|
} |
|
|
.nav-link:hover::after { |
|
|
width: 100%; |
|
|
} |
|
|
.theme-toggle { |
|
|
transition: all 0.3s ease; |
|
|
} |
|
|
.theme-toggle:hover { |
|
|
transform: rotate(30deg); |
|
|
} |
|
|
</style> |
|
|
<nav class="fixed w-full z-50 border-b border-gray-800"> |
|
|
<div class="container mx-auto px-4"> |
|
|
<div class="flex items-center justify-between h-16"> |
|
|
<a href="#" class="flex items-center"> |
|
|
<span class="text-xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-primary to-secondary"> |
|
|
NoirScape |
|
|
</span> |
|
|
</a> |
|
|
|
|
|
<div class="hidden md:flex items-center space-x-8"> |
|
|
<a href="/" class="nav-link text-gray-300 hover:text-white">Home</a> |
|
|
<a href="#" class="nav-link text-gray-300 hover:text-white">Features</a> |
|
|
<a href="#" class="nav-link text-gray-300 hover:text-white">Pricing</a> |
|
|
<a href="#" class="nav-link text-gray-300 hover:text-white">About</a> |
|
|
<a href="/swimming.html" class="nav-link text-gray-300 hover:text-white">Swimming</a> |
|
|
</div> |
|
|
|
|
|
<div class="flex items-center space-x-4"> |
|
|
<button class="theme-toggle p-2 rounded-full bg-gray-800 text-gray-300 hover:bg-gray-700"> |
|
|
<i data-feather="moon"></i> |
|
|
</button> |
|
|
<a href="#" class="px-4 py-2 rounded-full bg-gradient-to-r from-primary to-secondary text-white font-medium hover:opacity-90 transition"> |
|
|
Get Started |
|
|
</a> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</nav> |
|
|
`; |
|
|
|
|
|
|
|
|
const themeToggle = this.shadowRoot.querySelector('.theme-toggle'); |
|
|
themeToggle.addEventListener('click', () => { |
|
|
const isDark = document.documentElement.classList.contains('dark'); |
|
|
if (isDark) { |
|
|
document.documentElement.classList.remove('dark'); |
|
|
localStorage.setItem('theme', 'light'); |
|
|
this.shadowRoot.querySelector('i[data-feather="moon"]').setAttribute('data-feather', 'sun'); |
|
|
} else { |
|
|
document.documentElement.classList.add('dark'); |
|
|
localStorage.setItem('theme', 'dark'); |
|
|
this.shadowRoot.querySelector('i[data-feather="sun"]').setAttribute('data-feather', 'moon'); |
|
|
} |
|
|
feather.replace(); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
customElements.define('custom-navbar', CustomNavbar); |