File size: 10,783 Bytes
5a4691d | 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 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shopping Cart | LUMINA</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/lucide@latest"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;700&display=swap" rel="stylesheet">
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: { 500: '#f97316', 600: '#ea580c' },
creative: { 500: '#0ea5e9' }
},
fontFamily: {
sans: ['Inter', 'sans-serif'],
display: ['Space Grotesk', 'sans-serif'],
}
}
}
}
</script>
<style>
.quantity-btn { @apply w-8 h-8 flex items-center justify-center hover:bg-gray-100 rounded transition-colors; }
</style>
</head>
<body class="bg-gray-50 text-gray-900 min-h-screen">
<!-- Navigation -->
<nav class="sticky top-0 z-50 bg-white/95 backdrop-blur-md border-b border-gray-100">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex items-center justify-between h-16">
<a href="index.html" class="flex items-center gap-2">
<div class="w-10 h-10 bg-gradient-to-br from-primary-500 to-creative-500 rounded-xl flex items-center justify-center">
<i data-lucide="sparkles" class="w-6 h-6 text-white"></i>
</div>
<span class="font-display text-2xl font-bold">LUMINA</span>
</a>
<a href="products.html" class="text-gray-600 hover:text-gray-900 flex items-center gap-2">
<i data-lucide="arrow-left" class="w-4 h-4"></i>
Continue Shopping
</a>
</div>
</div>
</nav>
<!-- Cart Content -->
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<h1 class="font-display text-3xl font-bold mb-8">Shopping Cart</h1>
<div class="grid lg:grid-cols-3 gap-8">
<!-- Cart Items -->
<div class="lg:col-span-2 space-y-4" id="cartItems">
<!-- Items rendered by JS -->
</div>
<!-- Summary -->
<div class="lg:sticky lg:top-24 h-fit">
<div class="bg-white rounded-2xl p-6 border border-gray-100 shadow-sm">
<h2 class="font-display text-xl font-bold mb-6">Order Summary</h2>
<div class="space-y-3 mb-6">
<div class="flex justify-between text-gray-600">
<span>Subtotal</span>
<span id="subtotal">₹0</span>
</div>
<div class="flex justify-between text-gray-600">
<span>Shipping</span>
<span id="shipping">Free</span>
</div>
<div class="flex justify-between text-gray-600">
<span>Tax</span>
<span id="tax">₹0</span>
</div>
<div class="border-t border-gray-200 pt-3">
<div class="flex justify-between font-display text-xl font-bold">
<span>Total</span>
<span id="total">₹0</span>
</div>
</div>
</div>
<a href="checkout.html" id="checkoutBtn" class="block w-full bg-gray-900 hover:bg-primary-500 text-white text-center py-4 rounded-xl font-semibold transition-colors mb-4">
Proceed to Checkout
</a>
<div class="flex items-center justify-center gap-2 text-sm text-gray-500">
<i data-lucide="shield-check" class="w-4 h-4"></i>
Secure checkout
</div>
</div>
<!-- Promo Code -->
<div class="mt-4 bg-white rounded-2xl p-6 border border-gray-100">
<label class="block text-sm font-semibold mb-2">Promo Code</label>
<div class="flex gap-2">
<input type="text" placeholder="Enter code" id="promoInput" class="flex-1 px-4 py-2 border border-gray-200 rounded-lg focus:outline-none focus:border-primary-500">
<button onclick="applyPromo()" class="bg-gray-100 hover:bg-gray-200 px-4 py-2 rounded-lg font-medium transition-colors">Apply</button>
</div>
</div>
</div>
</div>
<!-- Empty State -->
<div id="emptyCart" class="hidden text-center py-20">
<div class="w-24 h-24 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-6">
<i data-lucide="shopping-bag" class="w-10 h-10 text-gray-400"></i>
</div>
<h2 class="font-display text-2xl font-bold mb-2">Your cart is empty</h2>
<p class="text-gray-600 mb-8">Looks like you haven't added anything yet.</p>
<a href="products.html" class="inline-flex items-center gap-2 bg-primary-500 hover:bg-primary-600 text-white px-8 py-3 rounded-xl font-semibold transition-colors">
Start Shopping <i data-lucide="arrow-right" class="w-4 h-4"></i>
</a>
</div>
</main>
<!-- Footer -->
<footer class="bg-white border-t border-gray-100 mt-16 py-8">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 flex flex-col sm:flex-row justify-between items-center gap-4">
<div class="flex items-center gap-2">
<i data-lucide="truck" class="w-5 h-5 text-primary-500"></i>
<span class="text-sm text-gray-600">Free shipping on orders over ₹2,500</span>
</div>
<div class="flex items-center gap-2">
<i data-lucide="refresh-cw" class="w-5 h-5 text-primary-500"></i>
<span class="text-sm text-gray-600">30-day easy returns</span>
</div>
<div class="flex items-center gap-2">
<i data-lucide="shield" class="w-5 h-5 text-primary-500"></i>
<span class="text-sm text-gray-600">Secure payment</span>
</div>
</div>
</footer>
<script src="script.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
lucide.createIcons();
renderCart();
});
function renderCart() {
const cart = getCart();
const container = document.getElementById('cartItems');
const emptyState = document.getElementById('emptyCart');
const summary = document.querySelector('.lg\\:col-span-2').nextElementSibling;
if (cart.length === 0) {
container.innerHTML = '';
emptyState.classList.remove('hidden');
summary.classList.add('hidden');
return;
}
emptyState.classList.add('hidden');
summary.classList.remove('hidden');
container.innerHTML = cart.map((item, index) => {
const product = products.find(p => p.id === item.id);
return `
<div class="bg-white rounded-2xl p-4 sm:p-6 border border-gray-100 flex gap-4 sm:gap-6">
<a href="product-detail.html?id=${product.id}" class="w-24 h-24 sm:w-32 sm:h-32 bg-gray-100 rounded-xl overflow-hidden flex-shrink-0">
<img src="${product.image}" alt="${product.name}" class="w-full h-full object-cover">
</a>
<div class="flex-1 min-w-0">
<div class="flex justify-between items-start mb-2">
<div>
<p class="text-xs text-gray-500 capitalize mb-1">${product.category}</p>
<a href="product-detail.html?id=${product.id}" class="font-semibold text-lg hover:text-primary-600 transition-colors line-clamp-2">${product.name}</a>
</div>
<button onclick="removeFromCart(${index})" class="text-gray-400 hover:text-red-500 transition-colors p-1">
<i data-lucide="trash-2" class="w-5 h-5"></i>
</button>
</div>
${item.size ? `<p class="text-sm text-gray-500 mb-2">Size: ${item.size}</p>` : ''}
${item.color ? `<p class="text-sm text-gray-500 mb-2">Color: ${item.color}</p>` : ''}
<div class="flex items-center justify-between mt-4">
<div class="flex items-center border border-gray-200 rounded-lg">
<button onclick="updateQuantity(${index}, ${item.quantity - 1})" class="quantity-btn">
<i data-lucide="minus" class="w-4 h-4"></i>
</button>
<span class="w-10 text-center font-semibold">${item.quantity}</span>
<button onclick="updateQuantity(${index}, ${item.quantity + 1})" class="quantity-btn">
<i data-lucide="plus" class="w-4 h-4"></i>
</button>
</div>
<div class="text-right">
<div class="font-bold text-lg">₹${(product.price * item.quantity).toLocaleString()}</div>
${item.quantity > 1 ? `<div class="text-sm text-gray-500">₹${product.price.toLocaleString()} each</div>` : ''}
</div>
</div>
</div>
</div>
`;
}).join('');
lucide.createIcons();
updateSummary();
}
function updateQuantity(index, newQty) {
if (newQty < 1) return;
let cart = getCart();
cart[index].quantity = Math.min(10, newQty);
saveCart(cart);
renderCart();
updateCartBadge();
}
function removeFromCart(index) {
let cart = getCart();
cart.splice(index, 1);
saveCart(cart);
renderCart();
updateCartBadge();
}
function updateSummary() {
const cart = getCart();
const subtotal = cart.reduce((sum, item) => {
const product = products.find(p => p.id === item.id);
return sum + (product.price * item.quantity);
}, 0);
const shipping = subtotal > 2500 ? 0 : 99;
const tax = Math.round(subtotal * 0.18);
const total = subtotal + shipping + tax;
document.getElementById('subtotal').textContent = `₹${subtotal.toLocaleString()}`;
document.getElementById('shipping').textContent = shipping === 0 ? 'Free' : `₹${shipping}`;
document.getElementById('tax').textContent = `₹${tax.toLocaleString()}`;
document.getElementById('total').textContent = `₹${total.toLocaleString()}`;
const btn = document.getElementById('checkoutBtn');
if (cart.length === 0) {
btn.classList.add('opacity-50', 'cursor-not-allowed');
btn.href = '#';
} else {
btn.classList.remove('opacity-50', 'cursor-not-allowed');
btn.href = 'checkout.html';
}
}
function applyPromo() {
const code = document.getElementById('promoInput').value.trim().toUpperCase();
if (code === 'CREATIVE20') {
showToast('Promo code applied! 20% discount');
} else {
showToast('Invalid promo code');
}
}
</script>
</body>
</html> |