-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathnavbar.html
429 lines (361 loc) · 13.9 KB
/
navbar.html
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Beautiful Navbar Generator</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
colors: {
dark: {
bg: '#1a1a1a',
text: '#ffffff'
}
}
}
}
}
</script>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f9f9f9;
color: #333;
}
#generator {
max-width: 600px;
margin: 20px auto;
padding: 20px;
background: #ffffff;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
#generator h1 {
font-weight: 800;
display: flex;
justify-content: center;
padding: 10px;
}
#generator label {
font-weight: bold;
margin-top: 10px;
display: block;
}
#generator input {
width: 100%;
padding: 10px;
margin-top: 5px;
border: 1px solid #ccc;
border-radius: 4px;
}
#generator button {
margin-top: 15px;
padding: 10px;
width: 100%;
background-color: #049b9f;
color: white;
font-size: 16px;
font-weight: bold;
border: none;
border-radius: 4px;
cursor: pointer;
transition: all 0.3s ease;
}
#generator button:hover {
background-color: #037a7b;
transform: scale(1.02);
}
#navbarPreview {
width: 100%;
margin-top: 20px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: transparent; /* Make the preview container background transparent */
color: inherit;
}
#navbarPreview a {
text-decoration: none;
margin-right: 10px;
color: inherit;
padding: 8px 12px;
border-radius: 4px;
transition: all 0.3s ease;
}
#navbarPreview a:hover {
background-color: rgba(87, 87, 87, 0.1);
transform: translateY(-1px);
}
.popup {
margin-top: 20px;
padding: 20px;
background-color: white;
border: 1px solid #ccc;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.popup textarea {
width: 100%;
height: 120px;
margin: 10px 0;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}
.popup button {
display: block;
margin-top: 10px;
padding: 10px;
width: 100%;
background-color: #049b9f;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
transition: all 0.3s ease;
}
.popup button:hover {
background-color: #037a7b;
transform: scale(1.02);
}
.close-btn {
background-color: #dc2626 !important;
margin-top: 5px;
}
.close-btn:hover {
background-color: #b91c1c !important;
}
/* Dark mode styles */
.dark body {
background-color: #1a1a1a;
color: #ffffff;
}
.dark #generator {
background: #2d2d2d;
color: #ffffff;
}
.dark #generator input {
background-color: #1a1a1a;
border-color: #404040;
color: #ffffff;
}
.dark .popup {
background-color: #2d2d2d;
border-color: #404040;
}
.dark .popup textarea {
background-color: #1a1a1a;
border-color: #404040;
color: #ffffff;
}
.dark header {
background-color: #2d2d2d;
}
.dark header span {
color: #ffffff;
}
.dark #menu {
background-color: #2d2d2d;
}
.dark #menu a {
color: #ffffff;
}
.dark #navbarPreview {
border-color: #404040;
}
.dark .popup button {
background-color: #049b9f;
}
.dark .popup button:hover {
background-color: #037a7b;
}
.dark #generator button {
background-color: #049b9f;
}
.dark #generator button:hover {
background-color: #037a7b;
}
.dark .close-btn {
background-color: #dc2626 !important;
}
.dark .close-btn:hover {
background-color: #b91c1c !important;
}
</style>
</head>
<body>
<!-- Add Navbar -->
<header class="flex items-center justify-between p-4 px-6 bg-white shadow md:px-10">
<div class="flex items-center space-x-2">
<div class="w-10 h-10 rounded">
<img src="/Logo.png" alt="Tailwind Generator Logo" />
</div>
<span class="text-lg font-bold text-gray-800 md:text-xl">TailorWind</span>
<!-- Dark Mode Toggle Button -->
<button id="darkModeToggle" class="ml-4 relative w-8 h-8 flex items-center justify-center">
<i class="fas fa-sun text-xl text-[#ffbc00] absolute" id="lightIcon"></i>
<i class="fas fa-moon text-xl text-[#ffbc00] absolute hidden" id="darkIcon"></i>
</button>
</div>
<!-- Hamburger Button -->
<button
id="menu-toggle"
class="block text-gray-800 md:hidden focus:outline-none"
>
<svg
class="w-6 h-6"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 6h16M4 12h16M4 18h16"
/>
</svg>
</button>
<!-- Navigation Menu -->
<nav
id="menu"
class="absolute left-0 flex flex-col hidden w-full py-4 bg-white shadow md:flex md:flex-row md:static top-16 md:w-auto md:shadow-none md:bg-transparent md:p-0"
>
<a href="/" class="text-black hover:text-[#049b9f] px-6 py-2 text-justify transition-colors duration-200">Home</a>
<a href="tools-and-generator" class="text-black hover:text-[#049b9f] px-6 py-2 text-justify transition-colors duration-200">Tools & Generator</a>
<a href="/#faq" class="text-black hover:text-[#049b9f] px-6 py-2 text-justify transition-colors duration-200">FAQ</a>
<a href="/#contact" class="text-black hover:text-[#049b9f] px-6 py-2 text-justify transition-colors duration-200">Contact</a>
<button class="bg-[#049b9f] text-white px-4 py-2 rounded mx-6 my-2 md:mx-0 md:my-0 hover:bg-[#037a7b] transition-colors duration-200" onclick="window.location.href='get-started.html'">
Get started
</button>
</nav>
</header>
<div id="generator">
<h1>Beautiful Navbar Generator</h1>
<label for="navTitle">Navbar Title:</label>
<input type="text" id="navTitle" placeholder="Enter Navbar Title" />
<label for="navItems">Menu Items (comma separated):</label>
<input type="text" id="navItems" placeholder="Home, About, Services, Contact" />
<label for="navBgColor">Navbar Background Color:</label>
<input type="color" id="navBgColor" value="#333333" />
<label for="navTextColor">Navbar Text Color:</label>
<input type="color" id="navTextColor" value="#ffffff" />
<button id="generateNavbar">Generate Navbar</button>
</div>
<h2 style="font:bold">Navbar Preview</h2>
<div id="navbarPreview"></div>
<div id="codeOutput"></div>
<script>
function generateNavbar() {
const navTitle = document.getElementById("navTitle").value;
const navItems = document.getElementById("navItems").value.split(",");
const navBgColor = document.getElementById("navBgColor").value;
const navTextColor = document.getElementById("navTextColor").value;
// Generate Navbar Preview
const linksHtml = navItems
.map(item => `<a href="#" style="color: ${navTextColor};">${item.trim()}</a>`)
.join("");
const navbarHtml = `
<div style="display: flex; justify-content: space-between; align-items: center; background-color: ${navBgColor}; color: ${navTextColor}; padding: 10px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); transition: all 0.3s ease;">
<div style="transition: all 0.3s ease;">${navTitle}</div>
<div style="display: flex; gap: 10px;">${linksHtml}</div>
</div>
`;
document.getElementById("navbarPreview").innerHTML = navbarHtml;
// Generate HTML and CSS Code
const generatedCode = `
<div class="w-full flex justify-between items-center p-4 rounded-lg shadow-md transition-all duration-300 ease-in-out hover:shadow-lg" style="background-color: ${navBgColor}; color: ${navTextColor};">
<div class="text-lg font-bold transition-all duration-300">${navTitle}</div>
<div class="flex space-x-4">
${navItems.map(item => `<a href="#" class="transition-all duration-300 ease-in-out hover:bg-opacity-10 hover:-translate-y-0.5 hover:bg-gray-700 px-3 py-2 rounded">${item.trim()}</a>`).join("\n ")}
</div>
</div>
`;
// Show code output below the preview
showCodeOutput(generatedCode);
}
function showCodeOutput(code) {
const codeOutput = document.getElementById("codeOutput");
// Clear previous code output
codeOutput.innerHTML = "";
// Create code container
const popup = document.createElement("div");
popup.className = "popup";
const textarea = document.createElement("textarea");
textarea.readOnly = true;
textarea.value = code;
const copyButton = document.createElement("button");
copyButton.textContent = "Copy Code";
copyButton.onclick = () => {
navigator.clipboard.writeText(code);
alert("Code copied to clipboard!");
};
const closeButton = document.createElement("button");
closeButton.textContent = "Close";
closeButton.className = "close-btn";
closeButton.onclick = () => popup.remove();
popup.appendChild(textarea);
popup.appendChild(copyButton);
popup.appendChild(closeButton);
codeOutput.appendChild(popup);
}
document.getElementById("generateNavbar").addEventListener("click", generateNavbar);
// Toggle the menu on mobile
const menuToggle = document.getElementById('menu-toggle');
const menu = document.getElementById('menu');
menuToggle.addEventListener('click', () => {
menu.classList.toggle('hidden');
});
// Dark mode implementation
document.addEventListener('DOMContentLoaded', () => {
const darkModeToggle = document.getElementById('darkModeToggle');
const lightIcon = document.getElementById('lightIcon');
const darkIcon = document.getElementById('darkIcon');
const htmlElement = document.documentElement;
// Check initial theme
if (localStorage.getItem('darkMode') === 'enabled' ||
(localStorage.getItem('darkMode') === null &&
window.matchMedia('(prefers-color-scheme: dark)').matches)) {
htmlElement.classList.add('dark');
lightIcon.classList.add('hidden');
darkIcon.classList.remove('hidden');
}
darkModeToggle.addEventListener('click', () => {
// Animate icons
lightIcon.style.transform = 'rotate(180deg) scale(0.5)';
darkIcon.style.transform = 'rotate(180deg) scale(0.5)';
setTimeout(() => {
htmlElement.classList.toggle('dark');
lightIcon.classList.toggle('hidden');
darkIcon.classList.toggle('hidden');
lightIcon.style.transform = 'rotate(0) scale(1)';
darkIcon.style.transform = 'rotate(0) scale(1)';
localStorage.setItem('darkMode',
htmlElement.classList.contains('dark') ? 'enabled' : 'disabled'
);
}, 150);
});
// Listen for system theme changes
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
if (localStorage.getItem('darkMode') === null) {
if (e.matches) {
htmlElement.classList.add('dark');
lightIcon.classList.add('hidden');
darkIcon.classList.remove('hidden');
} else {
htmlElement.classList.remove('dark');
lightIcon.classList.remove('hidden');
darkIcon.classList.add('hidden');
}
}
});
});
</script>
</body>
</html>