Spaces:
Running

File size: 3,595 Bytes
9566890
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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);