Spaces:
Running

numerolobot / components /header.js
daigamir's picture
напиши бот для telegram по нумерологии по сюцай для русскоязычной аудитории на python
9566890 verified
Raw History Blame Contribute Delete
3.6 kB
class CustomHeader extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
nav {
transition: all 0.3s ease;
}
.nav-scrolled {
background-color: white;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.nav-link {
position: relative;
}
.nav-link:after {
content: '';
position: absolute;
width: 0;
height: 2px;
bottom: -2px;
left: 0;
background-color: #6D28D9;
transition: width 0.3s ease;
}
.nav-link:hover:after {
width: 100%;
}
@media (max-width: 768px) {
.mobile-menu {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease-out;
}
.mobile-menu.open {
max-height: 500px;
}
}
</style>
<nav class="fixed w-full z-50 bg-transparent text-white">
<div class="container mx-auto px-4 py-4">
<div class="flex justify-between items-center">
<a href="/" class="flex items-center space-x-2">
<div class="w-10 h-10 bg-white rounded-full flex items-center justify-center">
<i data-feather="star" class="text-primary-600"></i>
</div>
<span class="text-xl font-bold">NumeroloBot</span>
</a>
<div class="hidden md:flex items-center space-x-8">
<a href="#start" class="nav-link">Начать</a>
<a href="#about" class="nav-link">О системе</a>
<a href="https://t.me/NumeroloBot" target="_blank" class="bg-white text-primary-600 hover:bg-gray-100 font-medium py-2 px-4 rounded-full transition duration-300">
Открыть в Telegram
</a>
</div>
<button class="md:hidden focus:outline-none mobile-menu-button">
<i data-feather="menu"></i>
</button>
</div>
<div class="mobile-menu md:hidden mt-2 bg-white rounded-lg shadow-lg text-gray-800">
<div class="px-4 py-3 space-y-3">
<a href="#start" class="block px-3 py-2 hover:bg-gray-100 rounded">Начать</a>
<a href="#about" class="block px-3 py-2 hover:bg-gray-100 rounded">О системе</a>
<a href="https://t.me/NumeroloBot" target="_blank" class="block px-3 py-2 bg-primary-100 text-primary-700 rounded font-medium">
Открыть в Telegram
</a>
</div>
</div>
</div>
</nav>
`;
// Mobile menu toggle
const mobileMenuButton = this.shadowRoot.querySelector('.mobile-menu-button');
const mobileMenu = this.shadowRoot.querySelector('.mobile-menu');
mobileMenuButton.addEventListener('click', () => {
mobileMenu.classList.toggle('open');
feather.replace();
});
// Change navbar style on scroll
window.addEventListener('scroll', () => {
const nav = this.shadowRoot.querySelector('nav');
if (window.scrollY > 50) {
nav.classList.add('nav-scrolled', 'text-gray-800');
nav.classList.remove('text-white');
} else {
nav.classList.remove('nav-scrolled', 'text-gray-800');
nav.classList.add('text-white');
}
});
// Replace feather icons
feather.replace();
}
}
customElements.define('custom-header', CustomHeader);