codebyjerry's picture
Initial DeepSite commit
5a4691d verified
Raw History Blame Contribute Delete
10.8 kB
<!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>