File size: 6,766 Bytes
29e58e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
class CustomNavbar extends HTMLElement {
    constructor() {
        super();
    }

    connectedCallback() {
        this.attachShadow({ mode: 'open' });
        this.render();
        this.setupEventListeners();
    }

    render() {
        this.shadowRoot.innerHTML = `
            <style>
                :host {
                    display: block;
                    width: 100%;
                }
                
                .navbar {
                    background: rgba(10, 10, 15, 0.95);
                    backdrop-filter: blur(10px);
                    border-bottom: 1px solid #00ff88;
                    padding: 1rem 0;
                    position: sticky;
                    top: 0;
                    z-index: 100;
                }
                
                .nav-container {
                    max-width: 1200px;
                    margin: 0 auto;
                    padding: 0 1rem;
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                }
                
                .nav-brand {
                    display: flex;
                    align-items: center;
                    gap: 0.5rem;
                    text-decoration: none;
                    font-family: Orbitron, monospace;
                    font-weight: 700;
                    font-size: 1.25rem;
                    background: linear-gradient(45deg, #00ff88, #00a2ff);
                    background-clip: text;
                    -webkit-background-clip: text;
                    -webkit-text-fill-color: transparent;
                }
                
                .nav-menu {
                    display: flex;
                    gap: 2rem;
                    align-items: center;
                }
                
                .nav-link {
                    color: #e2e8f0;
                    text-decoration: none;
                    font-weight: 500;
                    transition: all 0.3s ease;
                    position: relative;
                }
                
                .nav-link:hover {
                    color: #00ff88;
                }
                
                .nav-link.active {
                    color: #00ff88;
                }
                
                .nav-link.active::after {
                    content: '';
                    position: absolute;
                    bottom: -8px;
                    left: 0;
                    width: 100%;
                    height: 2px;
                    background: #00ff88;
                    box-shadow: 0 0 8px #00ff88;
                }
                
                .mobile-menu-button {
                    display: none;
                    background: none;
                    border: none;
                    color: #00ff88;
                    cursor: pointer;
                }
                
                @media (max-width: 768px) {
                    .nav-menu {
                        position: absolute;
                        top: 100%;
                        left: 0;
                        right: 0;
                        background: rgba(10, 10, 15, 0.95);
                        flex-direction: column;
                        padding: 1rem;
                        gap: 1rem;
                        display: none;
                    }
                    
                    .nav-menu.active {
                        display: flex;
                    }
                    
                    .mobile-menu-button {
                        display: block;
                    }
                }
            </style>
            
            <nav class="navbar">
                <div class="nav-container">
                    <a href="/" class="nav-brand">
                        <i data-feather="cpu"></i>
                        SINGULARITY
                    </a>
                    
                    <button class="mobile-menu-button">
                        <i data-feather="menu"></i>
                    </button>
                    
                    <div class="nav-menu">
                        <a href="/news" class="nav-link">
                            <i data-feather="zap" class="inline mr-1"></i>
                            Новости
                        </a>
                        <a href="/learning" class="nav-link">
                            <i data-feather="book-open" class="inline mr-1"></i>
                            Обучение
                        </a>
                        <a href="/resources" class="nav-link">
                            <i data-feather="link" class="inline mr-1"></i>
                            Ресурсы
                        </a>
                        <a href="/talks" class="nav-link">
                            <i data-feather="video" class="inline mr-1"></i>
                            Доклады
                        </a>
                        <a href="/demos" class="nav-link">
                            <i data-feather="code" class="inline mr-1"></i>
                            Демо
                        </a>
                        <a href="/admin" class="nav-link" data-auth="admin">
                            <i data-feather="settings" class="inline mr-1"></i>
                            Управление
                        </a>
                    </div>
                </div>
            </nav>
        `;
        
        // Replace feather icons after rendering
        setTimeout(() => {
            if (typeof feather !== 'undefined') {
                feather.replace();
            }
        }, 100);
    }

    setupEventListeners() {
        const mobileButton = this.shadowRoot.querySelector('.mobile-menu-button');
        const navMenu = this.shadowRoot.querySelector('.nav-menu');
        
        if (mobileButton) {
            mobileButton.addEventListener('click', () => {
                navMenu.classList.toggle('active');
                mobileButton.innerHTML = navMenu.classList.contains('active') ? 
                    '<i data-feather="x"></i>' : 
                    '<i data-feather="menu"></i>';
                feather.replace();
            });
        }

        // Close mobile menu when clicking outside
        document.addEventListener('click', (event) => {
            if (!this.contains(event.target) && navMenu.classList.contains('active')) {
                    navMenu.classList.remove('active');
                    mobileButton.innerHTML = '<i data-feather="menu"></i>';
                    feather.replace();
                }
            });
        }
    }
}

customElements.define('custom-navbar', CustomNavbar);