Spaces:
Running
Running
Now create the css and js
Browse files- index.html +11 -153
- login.html +3 -17
- script.js +185 -0
- styles.css +133 -0
index.html
CHANGED
|
@@ -5,11 +5,13 @@
|
|
| 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,8 +61,8 @@
|
|
| 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 |
-
<
|
| 63 |
-
<
|
| 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,12 +186,12 @@
|
|
| 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 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
</button>
|
| 194 |
</div>
|
| 195 |
|
|
@@ -382,149 +384,5 @@
|
|
| 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>
|
|
|
|
| 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 src="script.js" defer></script>
|
| 14 |
+
<script>
|
| 15 |
tailwind.config = {
|
| 16 |
theme: {
|
| 17 |
extend: {
|
|
|
|
| 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 |
+
<a 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</a>
|
| 65 |
+
<a 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</a>
|
| 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 |
<div class="mt-4 flex justify-between">
|
| 187 |
<div>
|
| 188 |
<h3 class="text-sm font-medium text-gray-900">Premium UI Kit</h3>
|
| 189 |
+
<p class="mt-1 text-sm text-gray-500 product-category">Design Templates</p>
|
| 190 |
+
</div>
|
| 191 |
+
<p class="text-sm font-medium text-primary product-price">$29.99</p>
|
| 192 |
+
</div>
|
| 193 |
+
<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 add-to-cart">
|
| 194 |
+
Add to cart
|
| 195 |
</button>
|
| 196 |
</div>
|
| 197 |
|
|
|
|
| 384 |
</div>
|
| 385 |
</div>
|
| 386 |
</footer>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 387 |
</body>
|
| 388 |
</html>
|
login.html
CHANGED
|
@@ -5,9 +5,11 @@
|
|
| 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 |
-
<
|
|
|
|
| 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,21 +106,5 @@
|
|
| 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>
|
|
|
|
| 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 |
+
<script src="script.js" defer></script>
|
| 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 |
</div>
|
| 107 |
</div>
|
| 108 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
</body>
|
| 110 |
</html>
|
script.js
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
```javascript
|
| 2 |
+
// DOM Ready
|
| 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 |
+
if (document.getElementById('vanta-background')) {
|
| 17 |
+
VANTA.NET({
|
| 18 |
+
el: "#vanta-background",
|
| 19 |
+
mouseControls: true,
|
| 20 |
+
touchControls: true,
|
| 21 |
+
gyroControls: false,
|
| 22 |
+
minHeight: 200.00,
|
| 23 |
+
minWidth: 200.00,
|
| 24 |
+
scale: 1.00,
|
| 25 |
+
scaleMobile: 1.00,
|
| 26 |
+
color: 0x6366f1,
|
| 27 |
+
backgroundColor: 0xf8fafc,
|
| 28 |
+
points: 10.00,
|
| 29 |
+
maxDistance: 22.00,
|
| 30 |
+
spacing: 18.00
|
| 31 |
+
});
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
// Feather Icons
|
| 36 |
+
function initFeatherIcons() {
|
| 37 |
+
feather.replace();
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
// Cart Functionality
|
| 41 |
+
function initCart() {
|
| 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 |
+
document.querySelectorAll('.add-to-cart').forEach(button => {
|
| 53 |
+
button.addEventListener('click', function() {
|
| 54 |
+
const productCard = this.closest('.product-card');
|
| 55 |
+
const productName = productCard.querySelector('h3').textContent;
|
| 56 |
+
const productPrice = parseFloat(productCard.querySelector('.product-price').textContent.replace('$', ''));
|
| 57 |
+
|
| 58 |
+
const existingItem = cart.find(item => item.name === productName);
|
| 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 |
+
// Add cart icon to nav if it exists
|
| 75 |
+
const navContainer = document.querySelector('.nav-container');
|
| 76 |
+
if (navContainer) {
|
| 77 |
+
const navCart = document.createElement('div');
|
| 78 |
+
navCart.className = 'ml-4 relative cursor-pointer';
|
| 79 |
+
navCart.innerHTML = '<i data-feather="shopping-bag" class="text-gray-500 hover:text-primary"></i>';
|
| 80 |
+
navCart.appendChild(cartCount);
|
| 81 |
+
navContainer.prepend(navCart);
|
| 82 |
+
feather.replace();
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
// Show Toast Notification
|
| 87 |
+
function showToast(message) {
|
| 88 |
+
const toast = document.createElement('div');
|
| 89 |
+
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';
|
| 90 |
+
toast.textContent = message;
|
| 91 |
+
document.body.appendChild(toast);
|
| 92 |
+
|
| 93 |
+
setTimeout(() => {
|
| 94 |
+
toast.classList.add('opacity-100');
|
| 95 |
+
setTimeout(() => {
|
| 96 |
+
toast.classList.remove('opacity-100');
|
| 97 |
+
setTimeout(() => toast.remove(), 300);
|
| 98 |
+
}, 2000);
|
| 99 |
+
}, 100);
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
// Mobile Menu Toggle
|
| 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('open');
|
| 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('open');
|
| 116 |
+
}
|
| 117 |
+
});
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
// Product Hover Animations
|
| 122 |
+
function initProductHover() {
|
| 123 |
+
document.querySelectorAll('.product-card').forEach(card => {
|
| 124 |
+
card.addEventListener('mouseenter', function() {
|
| 125 |
+
anime({
|
| 126 |
+
targets: this.querySelector('img'),
|
| 127 |
+
scale: 1.05,
|
| 128 |
+
duration: 300,
|
| 129 |
+
easing: 'easeOutQuad'
|
| 130 |
+
});
|
| 131 |
+
});
|
| 132 |
+
|
| 133 |
+
card.addEventListener('mouseleave', function() {
|
| 134 |
+
anime({
|
| 135 |
+
targets: this.querySelector('img'),
|
| 136 |
+
scale: 1,
|
| 137 |
+
duration: 300,
|
| 138 |
+
easing: 'easeOutQuad'
|
| 139 |
+
});
|
| 140 |
+
});
|
| 141 |
+
});
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
// Login Form Handler
|
| 145 |
+
function initLoginForm() {
|
| 146 |
+
const loginForm = document.getElementById('loginForm');
|
| 147 |
+
if (loginForm) {
|
| 148 |
+
loginForm.addEventListener('submit', function(e) {
|
| 149 |
+
e.preventDefault();
|
| 150 |
+
const email = document.getElementById('email').value;
|
| 151 |
+
const password = document.getElementById('password').value;
|
| 152 |
+
|
| 153 |
+
// Here you would typically send this to your backend
|
| 154 |
+
console.log('Login attempt with:', { email, password });
|
| 155 |
+
|
| 156 |
+
// For demo purposes, we'll just redirect
|
| 157 |
+
window.location.href = 'index.html';
|
| 158 |
+
});
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
// Search Functionality
|
| 163 |
+
function initSearch() {
|
| 164 |
+
const searchInput = document.querySelector('.search-input');
|
| 165 |
+
if (searchInput) {
|
| 166 |
+
searchInput.addEventListener('keyup', function(e) {
|
| 167 |
+
if(e.key === 'Enter') {
|
| 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 |
+
```
|
styles.css
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
```css
|
| 2 |
+
/* Main Styles */
|
| 3 |
+
body {
|
| 4 |
+
font-family: 'Inter', sans-serif;
|
| 5 |
+
line-height: 1.6;
|
| 6 |
+
color: #333;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
/* Animation Classes */
|
| 10 |
+
.transition-all {
|
| 11 |
+
transition: all 0.3s ease;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
/* Buttons */
|
| 15 |
+
.btn-primary {
|
| 16 |
+
background-color: #6366f1;
|
| 17 |
+
color: white;
|
| 18 |
+
padding: 0.75rem 1.5rem;
|
| 19 |
+
border-radius: 0.375rem;
|
| 20 |
+
font-weight: 500;
|
| 21 |
+
transition: background-color 0.3s ease;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
.btn-primary:hover {
|
| 25 |
+
background-color: #4f46e5;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
.btn-secondary {
|
| 29 |
+
background-color: #8b5cf6;
|
| 30 |
+
color: white;
|
| 31 |
+
padding: 0.75rem 1.5rem;
|
| 32 |
+
border-radius: 0.375rem;
|
| 33 |
+
font-weight: 500;
|
| 34 |
+
transition: background-color 0.3s ease;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
.btn-secondary:hover {
|
| 38 |
+
background-color: #7c3aed;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/* Forms */
|
| 42 |
+
.input-field {
|
| 43 |
+
width: 100%;
|
| 44 |
+
padding: 0.75rem;
|
| 45 |
+
border: 1px solid #d1d5db;
|
| 46 |
+
border-radius: 0.375rem;
|
| 47 |
+
transition: border-color 0.3s ease, box-shadow 0.3s ease;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.input-field:focus {
|
| 51 |
+
border-color: #6366f1;
|
| 52 |
+
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
|
| 53 |
+
outline: none;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/* Cards */
|
| 57 |
+
.card {
|
| 58 |
+
background: white;
|
| 59 |
+
border-radius: 0.5rem;
|
| 60 |
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
| 61 |
+
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
.card:hover {
|
| 65 |
+
transform: translateY(-5px);
|
| 66 |
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/* Utility Classes */
|
| 70 |
+
.text-primary {
|
| 71 |
+
color: #6366f1;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
.bg-primary {
|
| 75 |
+
background-color: #6366f1;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
.text-secondary {
|
| 79 |
+
color: #8b5cf6;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
.bg-secondary {
|
| 83 |
+
background-color: #8b5cf6;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/* Responsive Grid */
|
| 87 |
+
.grid-responsive {
|
| 88 |
+
display: grid;
|
| 89 |
+
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
| 90 |
+
gap: 1.5rem;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
/* Navigation */
|
| 94 |
+
.nav-link {
|
| 95 |
+
position: relative;
|
| 96 |
+
padding: 0.5rem 1rem;
|
| 97 |
+
font-weight: 500;
|
| 98 |
+
color: #6b7280;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
.nav-link:hover {
|
| 102 |
+
color: #6366f1;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.nav-link.active {
|
| 106 |
+
color: #6366f1;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
.nav-link.active::after {
|
| 110 |
+
content: '';
|
| 111 |
+
position: absolute;
|
| 112 |
+
bottom: -1px;
|
| 113 |
+
left: 1rem;
|
| 114 |
+
right: 1rem;
|
| 115 |
+
height: 2px;
|
| 116 |
+
background-color: #6366f1;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
/* Mobile Menu */
|
| 120 |
+
.mobile-menu {
|
| 121 |
+
transform: translateX(-100%);
|
| 122 |
+
transition: transform 0.3s ease;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
.mobile-menu.open {
|
| 126 |
+
transform: translateX(0);
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
/* Hero Section */
|
| 130 |
+
.hero-gradient {
|
| 131 |
+
background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
|
| 132 |
+
}
|
| 133 |
+
```
|