alicagri commited on
Commit
13817ee
·
verified ·
1 Parent(s): cce6c6f

no i want a ggoood topbar not just text

Browse files
Files changed (1) hide show
  1. components/navbar.js +141 -48
components/navbar.js CHANGED
@@ -1,33 +1,31 @@
 
1
  class CustomNavbar extends HTMLElement {
2
  connectedCallback() {
3
  this.attachShadow({ mode: 'open' });
4
  this.shadowRoot.innerHTML = `
5
  <style>
6
  .navbar {
7
- background: linear-gradient(90deg, rgba(17,24,39,0.95) 0%, rgba(37,99,235,0.15) 100%);
8
  backdrop-filter: blur(12px);
9
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
10
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
11
  }
12
  .nav-link {
13
- position: relative;
 
 
 
 
14
  transition: all 0.3s ease;
 
15
  }
16
  .nav-link:hover {
 
17
  color: #5865F2;
18
  }
19
- .nav-link::after {
20
- content: '';
21
- position: absolute;
22
- bottom: -8px;
23
- left: 0;
24
- width: 0;
25
- height: 2px;
26
- background: #5865F2;
27
- transition: width 0.3s ease;
28
- }
29
- .nav-link:hover::after {
30
- width: 100%;
31
  }
32
  .mobile-menu {
33
  transition: all 0.3s ease;
@@ -42,64 +40,124 @@ class CustomNavbar extends HTMLElement {
42
  font-weight: 700;
43
  }
44
  .theme-toggle {
45
- transition: transform 0.3s ease;
 
46
  }
47
  .theme-toggle:hover {
48
- transform: rotate(30deg);
49
  }
50
  .sign-in-btn {
51
  background: linear-gradient(90deg, #5865F2 0%, #8A2BE2 100%);
52
  transition: all 0.3s ease;
 
53
  }
54
  .sign-in-btn:hover {
55
  transform: translateY(-2px);
56
- box-shadow: 0 4px 12px rgba(88, 101, 242, 0.3);
 
 
 
 
 
 
 
 
 
 
57
  }
58
  </style>
59
- <nav class="navbar border-b border-gray-800 fixed w-full z-10">
60
  <div class="container mx-auto px-4">
61
- <div class="flex justify-between items-center py-4">
62
- <a href="index.html" class="flex items-center gap-2">
63
- <div class="w-10 h-10 bg-gradient-to-br from-primary-500 to-indigo-600 rounded-lg flex items-center justify-center shadow-lg">
64
- <i data-feather="code" class="text-white w-5 h-5"></i>
65
- </div>
66
- <span class="text-xl font-bold logo-text">Code Wizardry</span>
67
- </a>
68
-
69
- <div class="hidden md:flex items-center gap-8">
70
- <a href="index.html" class="nav-link text-gray-300">Home</a>
71
- <a href="#" class="nav-link text-gray-300">Categories</a>
72
- <a href="#" class="nav-link text-gray-300">Top Scripts</a>
73
- <a href="submit.html" class="nav-link text-gray-300">Submit</a>
74
 
75
- <div class="flex items-center gap-4 ml-4">
76
- <button id="theme-toggle" class="text-gray-400 hover:text-primary-500 p-2 rounded-full theme-toggle">
77
- <i data-feather="moon" class="w-5 h-5"></i>
78
- </button>
79
- <a href="#" class="sign-in-btn text-white px-5 py-2.5 rounded-lg text-sm font-medium">
80
- Sign In
 
 
 
 
 
 
 
 
 
 
81
  </a>
82
  </div>
83
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  <button id="mobile-menu-button" class="md:hidden text-gray-400 hover:text-primary-500 focus:outline-none transition-colors">
85
  <i data-feather="menu" class="w-6 h-6"></i>
86
  </button>
87
- </div>
88
  </div>
 
89
  <!-- Mobile menu -->
90
  <div id="mobile-menu" class="mobile-menu hidden md:hidden border-t border-gray-700">
91
- <div class="container mx-auto px-4 py-3">
92
  <div class="flex flex-col space-y-3">
93
- <a href="index.html" class="nav-link text-gray-300 py-3 px-4">Home</a>
94
- <a href="#" class="nav-link text-gray-300 py-3 px-4">Categories</a>
95
- <a href="#" class="nav-link text-gray-300 py-3 px-4">Top Scripts</a>
96
- <a href="submit.html" class="nav-link text-gray-300 py-3 px-4">Submit</a>
97
- <div class="pt-2 border-t border-gray-700 px-4 pb-4">
98
- <a href="#" class="block text-center sign-in-btn text-white px-4 py-3 rounded-lg font-medium">
99
- Sign In
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  </a>
101
  </div>
102
- </div>
103
  </div>
104
  </div>
105
  </nav>
@@ -114,13 +172,48 @@ class CustomNavbar extends HTMLElement {
114
  feather.replace();
115
  });
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  // Close mobile menu when clicking outside
118
  document.addEventListener('click', (event) => {
119
  if (!this.shadowRoot.contains(event.target) && !mobileMenu.classList.contains('hidden')) {
120
  mobileMenu.classList.add('hidden');
121
  }
122
  });
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
124
  }
125
 
126
- customElements.define('custom-navbar', CustomNavbar);
 
1
+
2
  class CustomNavbar extends HTMLElement {
3
  connectedCallback() {
4
  this.attachShadow({ mode: 'open' });
5
  this.shadowRoot.innerHTML = `
6
  <style>
7
  .navbar {
8
+ background: rgba(17, 24, 39, 0.95);
9
  backdrop-filter: blur(12px);
10
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
11
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
12
  }
13
  .nav-link {
14
+ display: flex;
15
+ align-items: center;
16
+ gap: 6px;
17
+ padding: 8px 12px;
18
+ border-radius: 8px;
19
  transition: all 0.3s ease;
20
+ color: #9CA3AF;
21
  }
22
  .nav-link:hover {
23
+ background: rgba(88, 101, 242, 0.15);
24
  color: #5865F2;
25
  }
26
+ .nav-link.active {
27
+ background: rgba(88, 101, 242, 0.2);
28
+ color: #5865F2;
 
 
 
 
 
 
 
 
 
29
  }
30
  .mobile-menu {
31
  transition: all 0.3s ease;
 
40
  font-weight: 700;
41
  }
42
  .theme-toggle {
43
+ transition: all 0.3s ease;
44
+ background: rgba(88, 101, 242, 0.1);
45
  }
46
  .theme-toggle:hover {
47
+ background: rgba(88, 101, 242, 0.2);
48
  }
49
  .sign-in-btn {
50
  background: linear-gradient(90deg, #5865F2 0%, #8A2BE2 100%);
51
  transition: all 0.3s ease;
52
+ box-shadow: 0 4px 6px rgba(88, 101, 242, 0.2);
53
  }
54
  .sign-in-btn:hover {
55
  transform: translateY(-2px);
56
+ box-shadow: 0 6px 12px rgba(88, 101, 242, 0.3);
57
+ }
58
+ .search-bar {
59
+ background: rgba(31, 41, 55, 0.5);
60
+ border: 1px solid rgba(75, 85, 99, 0.5);
61
+ }
62
+ .search-bar:focus {
63
+ border-color: #5865F2;
64
+ }
65
+ .user-avatar {
66
+ background: linear-gradient(135deg, #5865F2 0%, #8A2BE2 100%);
67
  }
68
  </style>
69
+ <nav class="navbar border-b border-gray-800 fixed w-full z-10">
70
  <div class="container mx-auto px-4">
71
+ <div class="flex justify-between items-center py-3">
72
+ <div class="flex items-center gap-6">
73
+ <a href="index.html" class="flex items-center gap-2">
74
+ <div class="w-9 h-9 bg-gradient-to-br from-primary-500 to-indigo-600 rounded-lg flex items-center justify-center shadow-lg">
75
+ <i data-feather="code" class="text-white w-4 h-4"></i>
76
+ </div>
77
+ <span class="text-xl font-bold logo-text">Script Haven</span>
78
+ </a>
 
 
 
 
 
79
 
80
+ <div class="hidden md:flex items-center gap-2">
81
+ <a href="index.html" class="nav-link active">
82
+ <i data-feather="home" class="w-4 h-4"></i>
83
+ <span>Home</span>
84
+ </a>
85
+ <a href="#" class="nav-link">
86
+ <i data-feather="grid" class="w-4 h-4"></i>
87
+ <span>Categories</span>
88
+ </a>
89
+ <a href="#" class="nav-link">
90
+ <i data-feather="trending-up" class="w-4 h-4"></i>
91
+ <span>Top Scripts</span>
92
+ </a>
93
+ <a href="submit.html" class="nav-link">
94
+ <i data-feather="upload" class="w-4 h-4"></i>
95
+ <span>Submit</span>
96
  </a>
97
  </div>
98
  </div>
99
+
100
+ <div class="hidden md:flex items-center gap-4">
101
+ <div class="relative">
102
+ <input type="text" placeholder="Search scripts..." class="search-bar text-sm px-4 py-2 rounded-lg w-64 focus:outline-none focus:ring-2 focus:ring-primary-500/30">
103
+ <i data-feather="search" class="absolute right-3 top-2.5 text-gray-400 w-4 h-4"></i>
104
+ </div>
105
+
106
+ <button id="theme-toggle" class="theme-toggle text-gray-400 hover:text-primary-500 p-2 rounded-lg">
107
+ <i data-feather="moon" class="w-5 h-5"></i>
108
+ </button>
109
+
110
+ <div class="flex items-center gap-3">
111
+ <a href="#" class="sign-in-btn text-white px-4 py-2 rounded-lg text-sm font-medium flex items-center gap-2">
112
+ <i data-feather="log-in" class="w-4 h-4"></i>
113
+ <span>Sign In</span>
114
+ </a>
115
+ <div class="w-8 h-8 rounded-full user-avatar flex items-center justify-center text-white text-sm font-medium cursor-pointer">
116
+ <i data-feather="user" class="w-4 h-4"></i>
117
+ </div>
118
+ </div>
119
+ </div>
120
  <button id="mobile-menu-button" class="md:hidden text-gray-400 hover:text-primary-500 focus:outline-none transition-colors">
121
  <i data-feather="menu" class="w-6 h-6"></i>
122
  </button>
123
+ </div>
124
  </div>
125
+
126
  <!-- Mobile menu -->
127
  <div id="mobile-menu" class="mobile-menu hidden md:hidden border-t border-gray-700">
128
+ <div class="container mx-auto px-4 py-3">
129
  <div class="flex flex-col space-y-3">
130
+ <div class="mb-3">
131
+ <input type="text" placeholder="Search scripts..." class="search-bar w-full text-sm px-4 py-2 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500/30">
132
+ </div>
133
+
134
+ <a href="index.html" class="nav-link active text-gray-300 py-2 px-4 flex items-center gap-2">
135
+ <i data-feather="home" class="w-4 h-4"></i>
136
+ <span>Home</span>
137
+ </a>
138
+ <a href="#" class="nav-link text-gray-300 py-2 px-4 flex items-center gap-2">
139
+ <i data-feather="grid" class="w-4 h-4"></i>
140
+ <span>Categories</span>
141
+ </a>
142
+ <a href="#" class="nav-link text-gray-300 py-2 px-4 flex items-center gap-2">
143
+ <i data-feather="trending-up" class="w-4 h-4"></i>
144
+ <span>Top Scripts</span>
145
+ </a>
146
+ <a href="submit.html" class="nav-link text-gray-300 py-2 px-4 flex items-center gap-2">
147
+ <i data-feather="upload" class="w-4 h-4"></i>
148
+ <span>Submit</span>
149
+ </a>
150
+
151
+ <div class="pt-2 border-t border-gray-700 px-4 pb-4 flex gap-3">
152
+ <button id="mobile-theme-toggle" class="theme-toggle text-gray-400 hover:text-primary-500 p-2 rounded-lg">
153
+ <i data-feather="moon" class="w-5 h-5"></i>
154
+ </button>
155
+ <a href="#" class="flex-1 text-center sign-in-btn text-white px-4 py-2 rounded-lg font-medium flex items-center justify-center gap-2">
156
+ <i data-feather="log-in" class="w-4 h-4"></i>
157
+ <span>Sign In</span>
158
  </a>
159
  </div>
160
+ </div>
161
  </div>
162
  </div>
163
  </nav>
 
172
  feather.replace();
173
  });
174
 
175
+ // Theme toggle for both desktop and mobile
176
+ const themeToggle = this.shadowRoot.getElementById('theme-toggle');
177
+ const mobileThemeToggle = this.shadowRoot.getElementById('mobile-theme-toggle');
178
+
179
+ const toggleTheme = () => {
180
+ const html = document.documentElement;
181
+ if (html.classList.contains('dark')) {
182
+ html.classList.remove('dark');
183
+ localStorage.setItem('theme', 'light');
184
+ } else {
185
+ html.classList.add('dark');
186
+ localStorage.setItem('theme', 'dark');
187
+ }
188
+ };
189
+
190
+ if (themeToggle) {
191
+ themeToggle.addEventListener('click', toggleTheme);
192
+ }
193
+
194
+ if (mobileThemeToggle) {
195
+ mobileThemeToggle.addEventListener('click', toggleTheme);
196
+ }
197
+
198
  // Close mobile menu when clicking outside
199
  document.addEventListener('click', (event) => {
200
  if (!this.shadowRoot.contains(event.target) && !mobileMenu.classList.contains('hidden')) {
201
  mobileMenu.classList.add('hidden');
202
  }
203
  });
204
+
205
+ // Highlight active nav link based on current page
206
+ const currentPath = window.location.pathname.split('/').pop() || 'index.html';
207
+ const navLinks = this.shadowRoot.querySelectorAll('.nav-link');
208
+
209
+ navLinks.forEach(link => {
210
+ if (link.getAttribute('href') === currentPath) {
211
+ link.classList.add('active');
212
+ } else {
213
+ link.classList.remove('active');
214
+ }
215
+ });
216
  }
217
  }
218
 
219
+ customElements.define('custom-navbar', CustomNavbar);