Spaces:
Running
Running
Now create the css and js
Browse files- index.html +153 -11
- login.html +17 -3
- script.js +120 -107
- style.css +133 -18
index.html
CHANGED
|
@@ -5,13 +5,11 @@
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>ByteBazaar - Digital Marketplace</title>
|
| 7 |
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
| 8 |
-
<link rel="stylesheet" href="styles.css">
|
| 9 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 10 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 11 |
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 12 |
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.net.min.js"></script>
|
| 13 |
-
<script
|
| 14 |
-
<script>
|
| 15 |
tailwind.config = {
|
| 16 |
theme: {
|
| 17 |
extend: {
|
|
@@ -61,8 +59,8 @@
|
|
| 61 |
<input type="text" class="border border-gray-300 rounded-full py-2 px-4 pl-10 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent" placeholder="Search products...">
|
| 62 |
<i data-feather="search" class="absolute left-3 top-2.5 text-gray-400"></i>
|
| 63 |
</div>
|
| 64 |
-
<
|
| 65 |
-
<
|
| 66 |
</div>
|
| 67 |
<div class="-mr-2 flex items-center sm:hidden">
|
| 68 |
<button type="button" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-primary">
|
|
@@ -186,12 +184,12 @@
|
|
| 186 |
<div class="mt-4 flex justify-between">
|
| 187 |
<div>
|
| 188 |
<h3 class="text-sm font-medium text-gray-900">Premium UI Kit</h3>
|
| 189 |
-
|
| 190 |
-
</div>
|
| 191 |
-
|
| 192 |
-
</div>
|
| 193 |
-
|
| 194 |
-
Add to cart
|
| 195 |
</button>
|
| 196 |
</div>
|
| 197 |
|
|
@@ -384,5 +382,149 @@ Add to cart
|
|
| 384 |
</div>
|
| 385 |
</div>
|
| 386 |
</footer>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 387 |
</body>
|
| 388 |
</html>
|
|
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>ByteBazaar - Digital Marketplace</title>
|
| 7 |
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
|
|
|
| 8 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 10 |
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 11 |
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.net.min.js"></script>
|
| 12 |
+
<script>
|
|
|
|
| 13 |
tailwind.config = {
|
| 14 |
theme: {
|
| 15 |
extend: {
|
|
|
|
| 59 |
<input type="text" class="border border-gray-300 rounded-full py-2 px-4 pl-10 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent" placeholder="Search products...">
|
| 60 |
<i data-feather="search" class="absolute left-3 top-2.5 text-gray-400"></i>
|
| 61 |
</div>
|
| 62 |
+
<button onclick="window.location.href='login.html'" class="ml-4 bg-primary text-white px-4 py-2 rounded-md text-sm font-medium hover:bg-primary-600 transition duration-150 ease-in-out">Sign In</button>
|
| 63 |
+
<button onclick="window.location.href='register.html'" class="ml-4 bg-secondary text-white px-4 py-2 rounded-md text-sm font-medium hover:bg-secondary-600 transition duration-150 ease-in-out">Sign Up</button>
|
| 64 |
</div>
|
| 65 |
<div class="-mr-2 flex items-center sm:hidden">
|
| 66 |
<button type="button" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-primary">
|
|
|
|
| 184 |
<div class="mt-4 flex justify-between">
|
| 185 |
<div>
|
| 186 |
<h3 class="text-sm font-medium text-gray-900">Premium UI Kit</h3>
|
| 187 |
+
<p class="mt-1 text-sm text-gray-500">Design Templates</p>
|
| 188 |
+
</div>
|
| 189 |
+
<p class="text-sm font-medium text-primary">$29.99</p>
|
| 190 |
+
</div>
|
| 191 |
+
<button class="mt-4 w-full bg-primary text-white py-2 rounded-md text-sm font-medium hover:bg-primary-600 transition duration-150 ease-in-out">
|
| 192 |
+
Add to cart
|
| 193 |
</button>
|
| 194 |
</div>
|
| 195 |
|
|
|
|
| 382 |
</div>
|
| 383 |
</div>
|
| 384 |
</footer>
|
| 385 |
+
<script>
|
| 386 |
+
// Vanta.js background animation
|
| 387 |
+
VANTA.NET({
|
| 388 |
+
el: "#vanta-background",
|
| 389 |
+
mouseControls: true,
|
| 390 |
+
touchControls: true,
|
| 391 |
+
gyroControls: false,
|
| 392 |
+
minHeight: 200.00,
|
| 393 |
+
minWidth: 200.00,
|
| 394 |
+
scale: 1.00,
|
| 395 |
+
scaleMobile: 1.00,
|
| 396 |
+
color: 0x6366f1,
|
| 397 |
+
backgroundColor: 0xf8fafc,
|
| 398 |
+
points: 10.00,
|
| 399 |
+
maxDistance: 22.00,
|
| 400 |
+
spacing: 18.00
|
| 401 |
+
});
|
| 402 |
+
|
| 403 |
+
// Initialize Feather Icons
|
| 404 |
+
feather.replace();
|
| 405 |
+
|
| 406 |
+
// Cart functionality
|
| 407 |
+
let cart = [];
|
| 408 |
+
const cartCount = document.createElement('span');
|
| 409 |
+
cartCount.className = 'absolute -top-1 -right-1 bg-red-500 text-white text-xs rounded-full h-5 w-5 flex items-center justify-center hidden';
|
| 410 |
+
|
| 411 |
+
function updateCartCount() {
|
| 412 |
+
const count = cart.reduce((total, item) => total + item.quantity, 0);
|
| 413 |
+
cartCount.textContent = count;
|
| 414 |
+
count > 0 ? cartCount.classList.remove('hidden') : cartCount.classList.add('hidden');
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
document.querySelectorAll('button:contains("Add to cart")').forEach(button => {
|
| 418 |
+
button.addEventListener('click', function() {
|
| 419 |
+
const productCard = this.closest('.product-card');
|
| 420 |
+
const productName = productCard.querySelector('h3').textContent;
|
| 421 |
+
const productPrice = parseFloat(productCard.querySelector('p.text-primary').textContent.replace('</body>
|
| 422 |
+
</html>
|
| 423 |
+
, ''));
|
| 424 |
+
|
| 425 |
+
const existingItem = cart.find(item => item.name === productName);
|
| 426 |
+
if(existingItem) {
|
| 427 |
+
existingItem.quantity++;
|
| 428 |
+
} else {
|
| 429 |
+
cart.push({
|
| 430 |
+
name: productName,
|
| 431 |
+
price: productPrice,
|
| 432 |
+
quantity: 1
|
| 433 |
+
});
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
updateCartCount();
|
| 437 |
+
|
| 438 |
+
// Show success message
|
| 439 |
+
const toast = document.createElement('div');
|
| 440 |
+
toast.className = 'fixed top-4 right-4 bg-green-500 text-white px-4 py-2 rounded-md shadow-lg transition-opacity duration-300 opacity-0';
|
| 441 |
+
toast.textContent = `${productName} added to cart!`;
|
| 442 |
+
document.body.appendChild(toast);
|
| 443 |
+
|
| 444 |
+
setTimeout(() => {
|
| 445 |
+
toast.classList.add('opacity-100');
|
| 446 |
+
setTimeout(() => {
|
| 447 |
+
toast.classList.remove('opacity-100');
|
| 448 |
+
setTimeout(() => toast.remove(), 300);
|
| 449 |
+
}, 2000);
|
| 450 |
+
}, 100);
|
| 451 |
+
});
|
| 452 |
+
});
|
| 453 |
+
|
| 454 |
+
// Add cart icon to nav
|
| 455 |
+
const navCart = document.createElement('div');
|
| 456 |
+
navCart.className = 'ml-4 relative cursor-pointer';
|
| 457 |
+
navCart.innerHTML = '<i data-feather="shopping-bag" class="text-gray-500 hover:text-primary"></i>';
|
| 458 |
+
navCart.appendChild(cartCount);
|
| 459 |
+
document.querySelector('nav .hidden.sm\\:ml-6.sm\\:flex.sm\\:items-center').prepend(navCart);
|
| 460 |
+
feather.replace();
|
| 461 |
+
|
| 462 |
+
// Search functionality
|
| 463 |
+
const searchInput = document.querySelector('input[type="text"]');
|
| 464 |
+
searchInput.addEventListener('keyup', function(e) {
|
| 465 |
+
if(e.key === 'Enter') {
|
| 466 |
+
const searchTerm = this.value.toLowerCase();
|
| 467 |
+
const products = document.querySelectorAll('.product-card');
|
| 468 |
+
|
| 469 |
+
products.forEach(product => {
|
| 470 |
+
const name = product.querySelector('h3').textContent.toLowerCase();
|
| 471 |
+
const category = product.querySelector('p.text-gray-500').textContent.toLowerCase();
|
| 472 |
+
|
| 473 |
+
if(name.includes(searchTerm) || category.includes(searchTerm)) {
|
| 474 |
+
product.style.display = 'block';
|
| 475 |
+
} else {
|
| 476 |
+
product.style.display = 'none';
|
| 477 |
+
}
|
| 478 |
+
});
|
| 479 |
+
}
|
| 480 |
+
});
|
| 481 |
+
|
| 482 |
+
// Mobile menu toggle
|
| 483 |
+
const mobileMenuButton = document.querySelector('button.sm\\:hidden');
|
| 484 |
+
const mobileMenu = document.createElement('div');
|
| 485 |
+
mobileMenu.className = 'hidden sm:hidden bg-white shadow-lg rounded-md mt-2 py-2 absolute right-4 w-48 z-50';
|
| 486 |
+
mobileMenu.innerHTML = `
|
| 487 |
+
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Home</a>
|
| 488 |
+
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Explore</a>
|
| 489 |
+
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Categories</a>
|
| 490 |
+
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Sell</a>
|
| 491 |
+
<div class="border-t border-gray-200 my-1"></div>
|
| 492 |
+
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Sign In</a>
|
| 493 |
+
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Sign Up</a>
|
| 494 |
+
`;
|
| 495 |
+
document.querySelector('nav').appendChild(mobileMenu);
|
| 496 |
+
|
| 497 |
+
mobileMenuButton.addEventListener('click', function() {
|
| 498 |
+
mobileMenu.classList.toggle('hidden');
|
| 499 |
+
});
|
| 500 |
+
|
| 501 |
+
// Close mobile menu when clicking outside
|
| 502 |
+
document.addEventListener('click', function(e) {
|
| 503 |
+
if(!mobileMenu.contains(e.target) && e.target !== mobileMenuButton) {
|
| 504 |
+
mobileMenu.classList.add('hidden');
|
| 505 |
+
}
|
| 506 |
+
});
|
| 507 |
+
|
| 508 |
+
// Product hover animations
|
| 509 |
+
document.querySelectorAll('.product-card').forEach(card => {
|
| 510 |
+
card.addEventListener('mouseenter', function() {
|
| 511 |
+
anime({
|
| 512 |
+
targets: this.querySelector('img'),
|
| 513 |
+
scale: 1.05,
|
| 514 |
+
duration: 300,
|
| 515 |
+
easing: 'easeOutQuad'
|
| 516 |
+
});
|
| 517 |
+
});
|
| 518 |
+
|
| 519 |
+
card.addEventListener('mouseleave', function() {
|
| 520 |
+
anime({
|
| 521 |
+
targets: this.querySelector('img'),
|
| 522 |
+
scale: 1,
|
| 523 |
+
duration: 300,
|
| 524 |
+
easing: 'easeOutQuad'
|
| 525 |
+
});
|
| 526 |
+
});
|
| 527 |
+
});
|
| 528 |
+
</script>
|
| 529 |
</body>
|
| 530 |
</html>
|
login.html
CHANGED
|
@@ -5,11 +5,9 @@
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Login - ByteBazaar</title>
|
| 7 |
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
| 8 |
-
<link rel="stylesheet" href="styles.css">
|
| 9 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 10 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 11 |
-
<
|
| 12 |
-
<style>
|
| 13 |
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
| 14 |
body {
|
| 15 |
font-family: 'Inter', sans-serif;
|
|
@@ -106,5 +104,21 @@
|
|
| 106 |
</div>
|
| 107 |
</div>
|
| 108 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
</body>
|
| 110 |
</html>
|
|
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Login - ByteBazaar</title>
|
| 7 |
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
|
|
|
| 8 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 10 |
+
<style>
|
|
|
|
| 11 |
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
| 12 |
body {
|
| 13 |
font-family: 'Inter', sans-serif;
|
|
|
|
| 104 |
</div>
|
| 105 |
</div>
|
| 106 |
</div>
|
| 107 |
+
|
| 108 |
+
<script>
|
| 109 |
+
feather.replace();
|
| 110 |
+
|
| 111 |
+
document.getElementById('loginForm').addEventListener('submit', function(e) {
|
| 112 |
+
e.preventDefault();
|
| 113 |
+
const email = document.getElementById('email').value;
|
| 114 |
+
const password = document.getElementById('password').value;
|
| 115 |
+
|
| 116 |
+
// Here you would typically send this to your backend
|
| 117 |
+
console.log('Login attempt with:', { email, password });
|
| 118 |
+
|
| 119 |
+
// For demo purposes, we'll just redirect
|
| 120 |
+
window.location.href = 'index.html';
|
| 121 |
+
});
|
| 122 |
+
</script>
|
| 123 |
</body>
|
| 124 |
</html>
|
script.js
CHANGED
|
@@ -1,124 +1,114 @@
|
|
| 1 |
```javascript
|
| 2 |
-
//
|
| 3 |
-
document.addEventListener('DOMContentLoaded', function() {
|
| 4 |
-
// Initialize components
|
| 5 |
-
initVantaBackground();
|
| 6 |
-
initFeatherIcons();
|
| 7 |
-
initCart();
|
| 8 |
-
initMobileMenu();
|
| 9 |
-
initProductHover();
|
| 10 |
-
initLoginForm();
|
| 11 |
-
initSearch();
|
| 12 |
-
});
|
| 13 |
-
|
| 14 |
-
// Vanta.js Background
|
| 15 |
function initVantaBackground() {
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
});
|
| 32 |
-
}
|
| 33 |
}
|
| 34 |
|
| 35 |
-
// Feather Icons
|
| 36 |
function initFeatherIcons() {
|
| 37 |
feather.replace();
|
| 38 |
}
|
| 39 |
|
| 40 |
-
// Cart
|
| 41 |
-
|
| 42 |
-
let cart = [];
|
| 43 |
-
const cartCount = document.createElement('span');
|
| 44 |
-
cartCount.className = 'absolute -top-1 -right-1 bg-red-500 text-white text-xs rounded-full h-5 w-5 flex items-center justify-center hidden';
|
| 45 |
-
|
| 46 |
-
function updateCartCount() {
|
| 47 |
-
const count = cart.reduce((total, item) => total + item.quantity, 0);
|
| 48 |
-
cartCount.textContent = count;
|
| 49 |
-
count > 0 ? cartCount.classList.remove('hidden') : cartCount.classList.add('hidden');
|
| 50 |
-
}
|
| 51 |
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
if(existingItem) {
|
| 60 |
-
existingItem.quantity++;
|
| 61 |
-
} else {
|
| 62 |
-
cart.push({
|
| 63 |
-
name: productName,
|
| 64 |
-
price: productPrice,
|
| 65 |
-
quantity: 1
|
| 66 |
-
});
|
| 67 |
-
}
|
| 68 |
-
|
| 69 |
-
updateCartCount();
|
| 70 |
-
showToast(`${productName} added to cart!`);
|
| 71 |
-
});
|
| 72 |
-
});
|
| 73 |
|
| 74 |
-
|
| 75 |
-
const
|
| 76 |
-
if
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
| 83 |
}
|
|
|
|
|
|
|
|
|
|
| 84 |
}
|
| 85 |
|
| 86 |
-
|
| 87 |
-
function showToast(message) {
|
| 88 |
const toast = document.createElement('div');
|
| 89 |
-
toast.className =
|
| 90 |
toast.textContent = message;
|
| 91 |
document.body.appendChild(toast);
|
| 92 |
|
| 93 |
setTimeout(() => {
|
| 94 |
-
toast.classList.add('
|
| 95 |
setTimeout(() => {
|
| 96 |
-
toast.classList.remove('
|
| 97 |
setTimeout(() => toast.remove(), 300);
|
| 98 |
}, 2000);
|
| 99 |
}, 100);
|
| 100 |
}
|
| 101 |
|
| 102 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
function initMobileMenu() {
|
| 104 |
const mobileMenuButton = document.querySelector('.mobile-menu-button');
|
| 105 |
const mobileMenu = document.querySelector('.mobile-menu');
|
| 106 |
-
|
| 107 |
if (mobileMenuButton && mobileMenu) {
|
| 108 |
mobileMenuButton.addEventListener('click', function() {
|
| 109 |
-
mobileMenu.classList.toggle('
|
| 110 |
});
|
| 111 |
-
|
| 112 |
-
// Close when clicking outside
|
| 113 |
document.addEventListener('click', function(e) {
|
| 114 |
if (!mobileMenu.contains(e.target) && e.target !== mobileMenuButton) {
|
| 115 |
-
mobileMenu.classList.remove('
|
| 116 |
}
|
| 117 |
});
|
| 118 |
}
|
| 119 |
}
|
| 120 |
|
| 121 |
-
// Product
|
| 122 |
function initProductHover() {
|
| 123 |
document.querySelectorAll('.product-card').forEach(card => {
|
| 124 |
card.addEventListener('mouseenter', function() {
|
|
@@ -141,8 +131,9 @@ function initProductHover() {
|
|
| 141 |
});
|
| 142 |
}
|
| 143 |
|
| 144 |
-
//
|
| 145 |
-
function
|
|
|
|
| 146 |
const loginForm = document.getElementById('loginForm');
|
| 147 |
if (loginForm) {
|
| 148 |
loginForm.addEventListener('submit', function(e) {
|
|
@@ -157,29 +148,51 @@ function initLoginForm() {
|
|
| 157 |
window.location.href = 'index.html';
|
| 158 |
});
|
| 159 |
}
|
| 160 |
-
}
|
| 161 |
|
| 162 |
-
//
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
const searchTerm = this.value.toLowerCase();
|
| 169 |
-
const products = document.querySelectorAll('.product-card');
|
| 170 |
-
|
| 171 |
-
products.forEach(product => {
|
| 172 |
-
const name = product.querySelector('h3').textContent.toLowerCase();
|
| 173 |
-
const category = product.querySelector('.product-category').textContent.toLowerCase();
|
| 174 |
-
|
| 175 |
-
if(name.includes(searchTerm) || category.includes(searchTerm)) {
|
| 176 |
-
product.style.display = 'block';
|
| 177 |
-
} else {
|
| 178 |
-
product.style.display = 'none';
|
| 179 |
-
}
|
| 180 |
-
});
|
| 181 |
-
}
|
| 182 |
});
|
| 183 |
}
|
| 184 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
```
|
|
|
|
| 1 |
```javascript
|
| 2 |
+
// Initialize Vanta.js background animation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
function initVantaBackground() {
|
| 4 |
+
VANTA.NET({
|
| 5 |
+
el: "#vanta-background",
|
| 6 |
+
mouseControls: true,
|
| 7 |
+
touchControls: true,
|
| 8 |
+
gyroControls: false,
|
| 9 |
+
minHeight: 200.00,
|
| 10 |
+
minWidth: 200.00,
|
| 11 |
+
scale: 1.00,
|
| 12 |
+
scaleMobile: 1.00,
|
| 13 |
+
color: 0x6366f1,
|
| 14 |
+
backgroundColor: 0xf8fafc,
|
| 15 |
+
points: 10.00,
|
| 16 |
+
maxDistance: 22.00,
|
| 17 |
+
spacing: 18.00
|
| 18 |
+
});
|
|
|
|
|
|
|
| 19 |
}
|
| 20 |
|
| 21 |
+
// Initialize Feather Icons
|
| 22 |
function initFeatherIcons() {
|
| 23 |
feather.replace();
|
| 24 |
}
|
| 25 |
|
| 26 |
+
// Cart functionality
|
| 27 |
+
let cart = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
function updateCartCount() {
|
| 30 |
+
const count = cart.reduce((total, item) => total + item.quantity, 0);
|
| 31 |
+
document.querySelector('.cart-count').textContent = count;
|
| 32 |
+
count > 0
|
| 33 |
+
? document.querySelector('.cart-count').classList.remove('hidden')
|
| 34 |
+
: document.querySelector('.cart-count').classList.add('hidden');
|
| 35 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
function addToCart(productName, productPrice) {
|
| 38 |
+
const existingItem = cart.find(item => item.name === productName);
|
| 39 |
+
if(existingItem) {
|
| 40 |
+
existingItem.quantity++;
|
| 41 |
+
} else {
|
| 42 |
+
cart.push({
|
| 43 |
+
name: productName,
|
| 44 |
+
price: productPrice,
|
| 45 |
+
quantity: 1
|
| 46 |
+
});
|
| 47 |
}
|
| 48 |
+
|
| 49 |
+
updateCartCount();
|
| 50 |
+
showToast(`${productName} added to cart!`, 'success');
|
| 51 |
}
|
| 52 |
|
| 53 |
+
function showToast(message, type = 'success') {
|
|
|
|
| 54 |
const toast = document.createElement('div');
|
| 55 |
+
toast.className = `toast ${type}`;
|
| 56 |
toast.textContent = message;
|
| 57 |
document.body.appendChild(toast);
|
| 58 |
|
| 59 |
setTimeout(() => {
|
| 60 |
+
toast.classList.add('show');
|
| 61 |
setTimeout(() => {
|
| 62 |
+
toast.classList.remove('show');
|
| 63 |
setTimeout(() => toast.remove(), 300);
|
| 64 |
}, 2000);
|
| 65 |
}, 100);
|
| 66 |
}
|
| 67 |
|
| 68 |
+
// Search functionality
|
| 69 |
+
function initSearch() {
|
| 70 |
+
const searchInput = document.querySelector('input[type="text"]');
|
| 71 |
+
if (searchInput) {
|
| 72 |
+
searchInput.addEventListener('keyup', function(e) {
|
| 73 |
+
if(e.key === 'Enter') {
|
| 74 |
+
const searchTerm = this.value.toLowerCase();
|
| 75 |
+
const products = document.querySelectorAll('.product-card');
|
| 76 |
+
|
| 77 |
+
products.forEach(product => {
|
| 78 |
+
const name = product.querySelector('h3').textContent.toLowerCase();
|
| 79 |
+
const category = product.querySelector('p.text-gray-500').textContent.toLowerCase();
|
| 80 |
+
|
| 81 |
+
if(name.includes(searchTerm) || category.includes(searchTerm)) {
|
| 82 |
+
product.style.display = 'block';
|
| 83 |
+
} else {
|
| 84 |
+
product.style.display = 'none';
|
| 85 |
+
}
|
| 86 |
+
});
|
| 87 |
+
}
|
| 88 |
+
});
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
// Mobile menu toggle
|
| 93 |
function initMobileMenu() {
|
| 94 |
const mobileMenuButton = document.querySelector('.mobile-menu-button');
|
| 95 |
const mobileMenu = document.querySelector('.mobile-menu');
|
| 96 |
+
|
| 97 |
if (mobileMenuButton && mobileMenu) {
|
| 98 |
mobileMenuButton.addEventListener('click', function() {
|
| 99 |
+
mobileMenu.classList.toggle('show-mobile-menu');
|
| 100 |
});
|
| 101 |
+
|
| 102 |
+
// Close mobile menu when clicking outside
|
| 103 |
document.addEventListener('click', function(e) {
|
| 104 |
if (!mobileMenu.contains(e.target) && e.target !== mobileMenuButton) {
|
| 105 |
+
mobileMenu.classList.remove('show-mobile-menu');
|
| 106 |
}
|
| 107 |
});
|
| 108 |
}
|
| 109 |
}
|
| 110 |
|
| 111 |
+
// Product hover animations
|
| 112 |
function initProductHover() {
|
| 113 |
document.querySelectorAll('.product-card').forEach(card => {
|
| 114 |
card.addEventListener('mouseenter', function() {
|
|
|
|
| 131 |
});
|
| 132 |
}
|
| 133 |
|
| 134 |
+
// Form handling
|
| 135 |
+
function initForms() {
|
| 136 |
+
// Login form
|
| 137 |
const loginForm = document.getElementById('loginForm');
|
| 138 |
if (loginForm) {
|
| 139 |
loginForm.addEventListener('submit', function(e) {
|
|
|
|
| 148 |
window.location.href = 'index.html';
|
| 149 |
});
|
| 150 |
}
|
|
|
|
| 151 |
|
| 152 |
+
// Register form
|
| 153 |
+
const registerForm = document.getElementById('registerForm');
|
| 154 |
+
if (registerForm) {
|
| 155 |
+
registerForm.addEventListener('submit', function(e) {
|
| 156 |
+
e.preventDefault();
|
| 157 |
+
// Handle registration logic here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
});
|
| 159 |
}
|
| 160 |
}
|
| 161 |
+
|
| 162 |
+
// Initialize all functionality when DOM is loaded
|
| 163 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 164 |
+
initVantaBackground();
|
| 165 |
+
initFeatherIcons();
|
| 166 |
+
initSearch();
|
| 167 |
+
initMobileMenu();
|
| 168 |
+
initProductHover();
|
| 169 |
+
initForms();
|
| 170 |
+
|
| 171 |
+
// Add cart icon to nav if it doesn't exist
|
| 172 |
+
if (!document.querySelector('.cart-icon')) {
|
| 173 |
+
const navCart = document.createElement('div');
|
| 174 |
+
navCart.className = 'cart-icon ml-4 relative cursor-pointer';
|
| 175 |
+
navCart.innerHTML = `
|
| 176 |
+
<i data-feather="shopping-bag" class="text-gray-500 hover:text-primary"></i>
|
| 177 |
+
<span class="cart-count absolute -top-1 -right-1 bg-red-500 text-white text-xs rounded-full h-5 w-5 flex items-center justify-center hidden">0</span>
|
| 178 |
+
`;
|
| 179 |
+
document.querySelector('nav .hidden.sm\\:ml-6.sm\\:flex.sm\\:items-center').prepend(navCart);
|
| 180 |
+
feather.replace();
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
// Set up event listeners for all "Add to cart" buttons
|
| 184 |
+
document.querySelectorAll('.add-to-cart').forEach(button => {
|
| 185 |
+
button.addEventListener('click', function() {
|
| 186 |
+
const productCard = this.closest('.product-card');
|
| 187 |
+
const productName = productCard.querySelector('h3').textContent;
|
| 188 |
+
const productPrice = parseFloat(productCard.querySelector('.product-price').textContent.replace('$', ''));
|
| 189 |
+
addToCart(productName, productPrice);
|
| 190 |
+
});
|
| 191 |
+
});
|
| 192 |
+
});
|
| 193 |
+
|
| 194 |
+
// Reinitialize Feather Icons when new content is loaded (like AJAX)
|
| 195 |
+
document.addEventListener('feather-icons-update', function() {
|
| 196 |
+
feather.replace();
|
| 197 |
+
});
|
| 198 |
```
|
style.css
CHANGED
|
@@ -1,28 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
body {
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
}
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
margin-top: 0;
|
| 9 |
}
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
font-size: 15px;
|
| 14 |
-
margin-bottom: 10px;
|
| 15 |
-
margin-top: 5px;
|
| 16 |
}
|
| 17 |
|
| 18 |
-
.
|
| 19 |
-
|
| 20 |
-
margin: 0 auto;
|
| 21 |
-
padding: 16px;
|
| 22 |
-
border: 1px solid lightgray;
|
| 23 |
-
border-radius: 16px;
|
| 24 |
}
|
| 25 |
|
| 26 |
-
.
|
| 27 |
-
|
| 28 |
}
|
|
|
|
|
|
| 1 |
+
```css
|
| 2 |
+
/* Main Styles */
|
| 3 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
| 4 |
+
|
| 5 |
body {
|
| 6 |
+
font-family: 'Inter', sans-serif;
|
| 7 |
+
background-color: #f8fafc;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
/* Gradient Background */
|
| 11 |
+
.hero-gradient {
|
| 12 |
+
background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
/* Transitions */
|
| 16 |
+
.transition-all {
|
| 17 |
+
transition-property: all;
|
| 18 |
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
| 19 |
+
transition-duration: 150ms;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
/* Product Card Effects */
|
| 23 |
+
.product-card {
|
| 24 |
+
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
.product-card:hover {
|
| 28 |
+
transform: translateY(-5px);
|
| 29 |
+
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
/* Form Elements */
|
| 33 |
+
.input-field:focus {
|
| 34 |
+
outline: none;
|
| 35 |
+
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/* Buttons */
|
| 39 |
+
.btn-primary {
|
| 40 |
+
background-color: #6366f1;
|
| 41 |
+
color: white;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.btn-primary:hover {
|
| 45 |
+
background-color: #4f46e5;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
.btn-secondary {
|
| 49 |
+
background-color: #8b5cf6;
|
| 50 |
+
color: white;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
.btn-secondary:hover {
|
| 54 |
+
background-color: #7c3aed;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
/* Animation Classes */
|
| 58 |
+
.fade-in {
|
| 59 |
+
animation: fadeIn 0.3s ease-in forwards;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
@keyframes fadeIn {
|
| 63 |
+
from { opacity: 0; }
|
| 64 |
+
to { opacity: 1; }
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
.slide-up {
|
| 68 |
+
animation: slideUp 0.3s ease-out forwards;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
@keyframes slideUp {
|
| 72 |
+
from {
|
| 73 |
+
transform: translateY(20px);
|
| 74 |
+
opacity: 0;
|
| 75 |
+
}
|
| 76 |
+
to {
|
| 77 |
+
transform: translateY(0);
|
| 78 |
+
opacity: 1;
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/* Mobile Menu */
|
| 83 |
+
.mobile-menu {
|
| 84 |
+
display: none;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
.show-mobile-menu {
|
| 88 |
+
display: block;
|
| 89 |
+
animation: slideDown 0.3s ease-out forwards;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
@keyframes slideDown {
|
| 93 |
+
from {
|
| 94 |
+
transform: translateY(-20px);
|
| 95 |
+
opacity: 0;
|
| 96 |
+
}
|
| 97 |
+
to {
|
| 98 |
+
transform: translateY(0);
|
| 99 |
+
opacity: 1;
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
/* Toast Notifications */
|
| 104 |
+
.toast {
|
| 105 |
+
position: fixed;
|
| 106 |
+
top: 1rem;
|
| 107 |
+
right: 1rem;
|
| 108 |
+
padding: 1rem;
|
| 109 |
+
border-radius: 0.375rem;
|
| 110 |
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
| 111 |
+
opacity: 0;
|
| 112 |
+
transition: opacity 0.3s ease;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
.toast.show {
|
| 116 |
+
opacity: 1;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
/* Utility Classes */
|
| 120 |
+
.rounded-1 {
|
| 121 |
+
border-radius: 0.25rem;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
.rounded-2 {
|
| 125 |
+
border-radius: 0.5rem;
|
| 126 |
}
|
| 127 |
|
| 128 |
+
.rounded-3 {
|
| 129 |
+
border-radius: 0.75rem;
|
|
|
|
| 130 |
}
|
| 131 |
|
| 132 |
+
.shadow-sm {
|
| 133 |
+
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
|
|
|
|
|
|
|
|
| 134 |
}
|
| 135 |
|
| 136 |
+
.shadow-md {
|
| 137 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
}
|
| 139 |
|
| 140 |
+
.shadow-lg {
|
| 141 |
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
| 142 |
}
|
| 143 |
+
```
|