|
|
class CustomNavbar extends HTMLElement { |
|
|
connectedCallback() { |
|
|
this.attachShadow({ mode: 'open' }); |
|
|
this.shadowRoot.innerHTML = ` |
|
|
<style> |
|
|
:host { |
|
|
display: block; |
|
|
position: fixed; |
|
|
top: 0; |
|
|
left: 0; |
|
|
right: 0; |
|
|
z-index: 1000; |
|
|
transition: transform 0.3s ease; |
|
|
} |
|
|
|
|
|
nav { |
|
|
background: rgba(17, 24, 39, 0.95); |
|
|
backdrop-filter: blur(10px); |
|
|
border-bottom: 1px solid rgba(75, 85, 99, 0.3); |
|
|
} |
|
|
|
|
|
.nav-link { |
|
|
position: relative; |
|
|
transition: color 0.3s ease; |
|
|
} |
|
|
|
|
|
.nav-link:hover { |
|
|
color: #fca5a5; |
|
|
} |
|
|
|
|
|
.nav-link::after { |
|
|
content: ''; |
|
|
position: absolute; |
|
|
bottom: -2px; |
|
|
left: 0; |
|
|
width: 0; |
|
|
height: 2px; |
|
|
background: #dc2626; |
|
|
transition: width 0.3s ease; |
|
|
} |
|
|
|
|
|
.nav-link:hover::after { |
|
|
width: 100%; |
|
|
} |
|
|
|
|
|
.mobile-menu { |
|
|
transition: all 0.3s ease; |
|
|
} |
|
|
|
|
|
@media (max-width: 768px) { |
|
|
.nav-menu { |
|
|
transform: translateX(-100%); |
|
|
} |
|
|
|
|
|
.nav-menu.open { |
|
|
transform: translateX(0); |
|
|
} |
|
|
} |
|
|
</style> |
|
|
<nav class="py-4"> |
|
|
<div class="container mx-auto px-6"> |
|
|
<div class="flex items-center justify-between"> |
|
|
<!-- Logo --> |
|
|
<a href="/" class="flex items-center space-x-2"> |
|
|
<i data-feather="search" class="text-red-500 w-6 h-6"></i> |
|
|
<span class="text-xl font-bold text-white">SearchExperts<span class="text-red-500">.ca</span></span> |
|
|
</a> |
|
|
|
|
|
<!-- Desktop Menu --> |
|
|
<div class="hidden md:flex items-center space-x-8"> |
|
|
<a href="#services" class="nav-link text-gray-300 hover:text-white">Services</a> |
|
|
<a href="#about" class="nav-link text-gray-300 hover:text-white">About</a> |
|
|
<a href="#application" class="nav-link text-gray-300 hover:text-white">Apply</a> |
|
|
<a href="#application" class="bg-red-600 hover:bg-red-700 text-white px-6 py-2 rounded-lg font-semibold transition-colors"> |
|
|
Apply Now |
|
|
</a> |
|
|
</div> |
|
|
|
|
|
<!-- Mobile Menu Button --> |
|
|
<button class="md:hidden text-gray-300 hover:text-white focus:outline-none"> |
|
|
<i data-feather="menu" class="w-6 h-6"></i> |
|
|
</button> |
|
|
</div> |
|
|
|
|
|
<!-- Mobile Menu --> |
|
|
<div class="mobile-menu nav-menu md:hidden fixed inset-y-0 left-0 w-64 bg-gray-900 shadow-xl z-50"> |
|
|
<div class="p-6"> |
|
|
<div class="flex items-center justify-between mb-8"> |
|
|
<a href="/" class="flex items-center space-x-2"> |
|
|
<i data-feather="search" class="text-red-500 w-6 h-6"></i> |
|
|
<span class="text-xl font-bold text-white">SearchExperts<span class="text-red-500">.ca</span></span> |
|
|
</a> |
|
|
<button class="close-menu text-gray-300 hover:text-white"> |
|
|
<i data-feather="x" class="w-6 h-6"></i> |
|
|
</button> |
|
|
</div> |
|
|
<div class="space-y-6"> |
|
|
<a href="#services" class="block nav-link text-gray-300 hover:text-white text-lg">Services</a> |
|
|
<a href="#about" class="block nav-link text-gray-300 hover:text-white text-lg">About</a> |
|
|
<a href="#contact" class="block nav-link text-gray-300 hover:text-white text-lg">Contact</a> |
|
|
<a href="#contact" class="block bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg font-semibold transition-colors text-center"> |
|
|
Get Started |
|
|
</a> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</nav> |
|
|
`; |
|
|
|
|
|
this.initMobileMenu(); |
|
|
this.initScrollEffects(); |
|
|
} |
|
|
|
|
|
initMobileMenu() { |
|
|
const menuButton = this.shadowRoot.querySelector('button'); |
|
|
const closeButton = this.shadowRoot.querySelector('.close-menu'); |
|
|
const mobileMenu = this.shadowRoot.querySelector('.mobile-menu'); |
|
|
|
|
|
menuButton.addEventListener('click', () => { |
|
|
mobileMenu.classList.add('open'); |
|
|
document.body.style.overflow = 'hidden'; |
|
|
}); |
|
|
|
|
|
closeButton.addEventListener('click', () => { |
|
|
mobileMenu.classList.remove('open'); |
|
|
document.body.style.overflow = ''; |
|
|
}); |
|
|
|
|
|
|
|
|
this.shadowRoot.querySelectorAll('.mobile-menu a').forEach(link => { |
|
|
link.addEventListener('click', () => { |
|
|
mobileMenu.classList.remove('open'); |
|
|
document.body.style.overflow = ''; |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
initScrollEffects() { |
|
|
let lastScrollTop = 0; |
|
|
|
|
|
window.addEventListener('scroll', () => { |
|
|
const scrollTop = window.pageYOffset || document.documentElement.scrollTop; |
|
|
|
|
|
if (scrollTop > lastScrollTop && scrollTop > 100) { |
|
|
this.style.transform = 'translateY(-100%)'; |
|
|
} else { |
|
|
this.style.transform = 'translateY(0)'; |
|
|
} |
|
|
lastScrollTop = scrollTop; |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
customElements.define('custom-navbar', CustomNavbar); |