jonesfernandes's picture
Deixe o site moderno, bonito e responsivo
27d3502 verified
class CustomNavbar extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
.navbar {
backdrop-filter: blur(10px);
background-color: rgba(255, 255, 255, 0.8);
}
.dark .navbar {
background-color: rgba(17, 24, 39, 0.8);
}
.nav-link:hover {
color: #6366f1;
}
.mobile-menu {
transition: all 0.3s ease;
}
</style>
<nav class="navbar fixed w-full z-50 border-b border-gray-200 dark:border-gray-700">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex items-center">
<a href="/" class="flex-shrink-0 flex items-center">
<span class="text-xl font-bold text-primary-500">PixelPulse</span>
<span class="text-xl font-bold text-secondary-500">Pro</span>
</a>
</div>
<div class="hidden md:ml-6 md:flex md:items-center md:space-x-8">
<a href="#features" class="nav-link text-gray-700 dark:text-gray-300 hover:text-primary-500 px-3 py-2 rounded-md text-sm font-medium">Features</a>
<a href="#pricing" class="nav-link text-gray-700 dark:text-gray-300 hover:text-primary-500 px-3 py-2 rounded-md text-sm font-medium">Pricing</a>
<a href="#contact" class="nav-link text-gray-700 dark:text-gray-300 hover:text-primary-500 px-3 py-2 rounded-md text-sm font-medium">Contact</a>
<button id="theme-toggle" class="text-gray-700 dark:text-gray-300 hover:text-primary-500 p-2 rounded-full">
<i data-feather="moon"></i>
</button>
</div>
<div class="-mr-2 flex items-center md:hidden">
<button id="mobile-menu-button" class="text-gray-700 dark:text-gray-300 hover:text-primary-500 inline-flex items-center justify-center p-2 rounded-md">
<i data-feather="menu"></i>
</button>
</div>
</div>
</div>
<div id="mobile-menu" class="mobile-menu hidden md:hidden absolute w-full bg-white dark:bg-gray-800 shadow-lg">
<div class="px-2 pt-2 pb-3 space-y-1 sm:px-3">
<a href="#features" class="block px-3 py-2 rounded-md text-base font-medium text-gray-700 dark:text-gray-300 hover:text-primary-500">Features</a>
<a href="#pricing" class="block px-3 py-2 rounded-md text-base font-medium text-gray-700 dark:text-gray-300 hover:text-primary-500">Pricing</a>
<a href="#contact" class="block px-3 py-2 rounded-md text-base font-medium text-gray-700 dark:text-gray-300 hover:text-primary-500">Contact</a>
<button id="mobile-theme-toggle" class="block px-3 py-2 rounded-md text-base font-medium text-gray-700 dark:text-gray-300 hover:text-primary-500">
Toggle Theme
</button>
</div>
</div>
</nav>
`;
// Mobile menu toggle
const mobileMenuButton = this.shadowRoot.getElementById('mobile-menu-button');
const mobileMenu = this.shadowRoot.getElementById('mobile-menu');
mobileMenuButton.addEventListener('click', () => {
mobileMenu.classList.toggle('hidden');
feather.replace();
});
// Theme toggle for mobile
const mobileThemeToggle = this.shadowRoot.getElementById('mobile-theme-toggle');
if (mobileThemeToggle) {
mobileThemeToggle.addEventListener('click', () => {
const isDark = document.documentElement.classList.toggle('dark');
localStorage.setItem('theme', isDark ? 'dark' : 'light');
});
}
}
}
customElements.define('custom-navbar', CustomNavbar);