Spaces:
Running
Running
undefined - Initial Deployment
Browse files- README.md +7 -5
- index.html +449 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: candy-test
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: yellow
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,449 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>SnackAttack - Quick Bites Delivered</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
@keyframes float {
|
| 11 |
+
0%, 100% { transform: translateY(0); }
|
| 12 |
+
50% { transform: translateY(-10px); }
|
| 13 |
+
}
|
| 14 |
+
.floating {
|
| 15 |
+
animation: float 3s ease-in-out infinite;
|
| 16 |
+
}
|
| 17 |
+
.snack-card:hover {
|
| 18 |
+
transform: translateY(-5px);
|
| 19 |
+
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
| 20 |
+
}
|
| 21 |
+
.cart-pulse {
|
| 22 |
+
animation: pulse 2s infinite;
|
| 23 |
+
}
|
| 24 |
+
@keyframes pulse {
|
| 25 |
+
0% { transform: scale(1); }
|
| 26 |
+
50% { transform: scale(1.1); }
|
| 27 |
+
100% { transform: scale(1); }
|
| 28 |
+
}
|
| 29 |
+
</style>
|
| 30 |
+
</head>
|
| 31 |
+
<body class="bg-gradient-to-br from-purple-50 to-pink-50 min-h-screen">
|
| 32 |
+
<!-- Header -->
|
| 33 |
+
<header class="sticky top-0 z-50 bg-white shadow-sm">
|
| 34 |
+
<div class="container mx-auto px-4 py-3 flex justify-between items-center">
|
| 35 |
+
<div class="flex items-center space-x-2">
|
| 36 |
+
<div class="w-10 h-10 rounded-full bg-gradient-to-r from-purple-500 to-pink-500 flex items-center justify-center text-white font-bold text-xl">S</div>
|
| 37 |
+
<h1 class="text-2xl font-bold bg-gradient-to-r from-purple-600 to-pink-600 bg-clip-text text-transparent">SnackAttack</h1>
|
| 38 |
+
</div>
|
| 39 |
+
<div class="flex items-center space-x-4">
|
| 40 |
+
<button id="cart-btn" class="relative">
|
| 41 |
+
<i class="fas fa-shopping-cart text-2xl text-purple-600"></i>
|
| 42 |
+
<span id="cart-count" class="absolute -top-2 -right-2 bg-pink-500 text-white rounded-full w-6 h-6 flex items-center justify-center text-xs font-bold">0</span>
|
| 43 |
+
</button>
|
| 44 |
+
<button class="hidden md:block bg-gradient-to-r from-purple-500 to-pink-500 text-white px-4 py-2 rounded-full font-medium hover:shadow-lg transition-all">Sign In</button>
|
| 45 |
+
</div>
|
| 46 |
+
</div>
|
| 47 |
+
</header>
|
| 48 |
+
|
| 49 |
+
<!-- Hero Section -->
|
| 50 |
+
<section class="container mx-auto px-4 py-12 flex flex-col md:flex-row items-center">
|
| 51 |
+
<div class="md:w-1/2 mb-8 md:mb-0">
|
| 52 |
+
<h2 class="text-4xl md:text-5xl font-bold text-gray-800 mb-4">Cravings? <span class="bg-gradient-to-r from-purple-600 to-pink-600 bg-clip-text text-transparent">SnackAttack!</span></h2>
|
| 53 |
+
<p class="text-lg text-gray-600 mb-6">Get your favorite munchies delivered in minutes. Perfect for those sudden snack emergencies!</p>
|
| 54 |
+
<div class="flex space-x-4">
|
| 55 |
+
<button class="bg-gradient-to-r from-purple-500 to-pink-500 text-white px-6 py-3 rounded-full font-medium hover:shadow-lg transition-all">Order Now</button>
|
| 56 |
+
<button class="border-2 border-purple-500 text-purple-500 px-6 py-3 rounded-full font-medium hover:bg-purple-50 transition-all">See Menu</button>
|
| 57 |
+
</div>
|
| 58 |
+
</div>
|
| 59 |
+
<div class="md:w-1/2 flex justify-center">
|
| 60 |
+
<div class="relative w-full max-w-md">
|
| 61 |
+
<img src="https://images.unsplash.com/photo-1550583724-b2692b85b150?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=774&q=80"
|
| 62 |
+
alt="Assorted snacks"
|
| 63 |
+
class="rounded-2xl shadow-xl w-full h-auto floating">
|
| 64 |
+
<div class="absolute -bottom-4 -right-4 bg-white p-3 rounded-xl shadow-lg">
|
| 65 |
+
<div class="flex items-center">
|
| 66 |
+
<div class="w-10 h-10 rounded-full bg-yellow-400 flex items-center justify-center text-white">
|
| 67 |
+
<i class="fas fa-bolt"></i>
|
| 68 |
+
</div>
|
| 69 |
+
<div class="ml-2">
|
| 70 |
+
<p class="text-xs text-gray-500">Delivery in</p>
|
| 71 |
+
<p class="font-bold text-purple-600">15-20 min</p>
|
| 72 |
+
</div>
|
| 73 |
+
</div>
|
| 74 |
+
</div>
|
| 75 |
+
</div>
|
| 76 |
+
</div>
|
| 77 |
+
</section>
|
| 78 |
+
|
| 79 |
+
<!-- Categories -->
|
| 80 |
+
<section class="container mx-auto px-4 py-8">
|
| 81 |
+
<h3 class="text-2xl font-bold text-gray-800 mb-6">What are you craving?</h3>
|
| 82 |
+
<div class="flex overflow-x-auto pb-4 space-x-4 scrollbar-hide">
|
| 83 |
+
<button class="category-btn flex-shrink-0 px-6 py-2 bg-purple-100 text-purple-700 rounded-full font-medium hover:bg-purple-200 transition-all" data-category="all">All</button>
|
| 84 |
+
<button class="category-btn flex-shrink-0 px-6 py-2 bg-gray-100 text-gray-700 rounded-full font-medium hover:bg-gray-200 transition-all" data-category="chips">Chips</button>
|
| 85 |
+
<button class="category-btn flex-shrink-0 px-6 py-2 bg-gray-100 text-gray-700 rounded-full font-medium hover:bg-gray-200 transition-all" data-category="chocolate">Chocolate</button>
|
| 86 |
+
<button class="category-btn flex-shrink-0 px-6 py-2 bg-gray-100 text-gray-700 rounded-full font-medium hover:bg-gray-200 transition-all" data-category="nuts">Nuts</button>
|
| 87 |
+
<button class="category-btn flex-shrink-0 px-6 py-2 bg-gray-100 text-gray-700 rounded-full font-medium hover:bg-gray-200 transition-all" data-category="candy">Candy</button>
|
| 88 |
+
<button class="category-btn flex-shrink-0 px-6 py-2 bg-gray-100 text-gray-700 rounded-full font-medium hover:bg-gray-200 transition-all" data-category="cookies">Cookies</button>
|
| 89 |
+
</div>
|
| 90 |
+
</section>
|
| 91 |
+
|
| 92 |
+
<!-- Snacks Grid -->
|
| 93 |
+
<section class="container mx-auto px-4 py-8">
|
| 94 |
+
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6" id="snacks-container">
|
| 95 |
+
<!-- Snack cards will be inserted here by JavaScript -->
|
| 96 |
+
</div>
|
| 97 |
+
</section>
|
| 98 |
+
|
| 99 |
+
<!-- Cart Sidebar -->
|
| 100 |
+
<div id="cart-sidebar" class="fixed top-0 right-0 h-full w-full md:w-96 bg-white shadow-xl transform translate-x-full transition-transform duration-300 z-50 overflow-y-auto">
|
| 101 |
+
<div class="p-6">
|
| 102 |
+
<div class="flex justify-between items-center mb-6">
|
| 103 |
+
<h3 class="text-2xl font-bold text-gray-800">Your Snack Cart</h3>
|
| 104 |
+
<button id="close-cart" class="text-gray-500 hover:text-gray-700">
|
| 105 |
+
<i class="fas fa-times text-2xl"></i>
|
| 106 |
+
</button>
|
| 107 |
+
</div>
|
| 108 |
+
|
| 109 |
+
<div id="cart-items" class="space-y-4 mb-6">
|
| 110 |
+
<!-- Cart items will be inserted here -->
|
| 111 |
+
<div class="text-center py-10">
|
| 112 |
+
<i class="fas fa-shopping-cart text-4xl text-gray-300 mb-4"></i>
|
| 113 |
+
<p class="text-gray-500">Your cart is empty</p>
|
| 114 |
+
</div>
|
| 115 |
+
</div>
|
| 116 |
+
|
| 117 |
+
<div class="border-t border-gray-200 pt-4">
|
| 118 |
+
<div class="flex justify-between mb-2">
|
| 119 |
+
<span class="text-gray-600">Subtotal</span>
|
| 120 |
+
<span id="cart-subtotal" class="font-medium">$0.00</span>
|
| 121 |
+
</div>
|
| 122 |
+
<div class="flex justify-between mb-4">
|
| 123 |
+
<span class="text-gray-600">Delivery</span>
|
| 124 |
+
<span class="font-medium">$2.99</span>
|
| 125 |
+
</div>
|
| 126 |
+
<div class="flex justify-between text-lg font-bold mb-6">
|
| 127 |
+
<span>Total</span>
|
| 128 |
+
<span id="cart-total">$2.99</span>
|
| 129 |
+
</div>
|
| 130 |
+
<button id="checkout-btn" class="w-full bg-gradient-to-r from-purple-500 to-pink-500 text-white py-3 rounded-full font-medium hover:shadow-lg transition-all disabled:opacity-50" disabled>
|
| 131 |
+
Checkout
|
| 132 |
+
</button>
|
| 133 |
+
</div>
|
| 134 |
+
</div>
|
| 135 |
+
</div>
|
| 136 |
+
<div id="cart-overlay" class="fixed inset-0 bg-black bg-opacity-50 z-40 hidden"></div>
|
| 137 |
+
|
| 138 |
+
<!-- Confetti Effect Container -->
|
| 139 |
+
<div id="confetti-container" class="fixed inset-0 pointer-events-none z-60 overflow-hidden hidden"></div>
|
| 140 |
+
|
| 141 |
+
<!-- Footer -->
|
| 142 |
+
<footer class="bg-white py-8 mt-12">
|
| 143 |
+
<div class="container mx-auto px-4">
|
| 144 |
+
<div class="flex flex-col md:flex-row justify-between items-center">
|
| 145 |
+
<div class="mb-6 md:mb-0">
|
| 146 |
+
<div class="flex items-center space-x-2">
|
| 147 |
+
<div class="w-8 h-8 rounded-full bg-gradient-to-r from-purple-500 to-pink-500 flex items-center justify-center text-white font-bold text-sm">S</div>
|
| 148 |
+
<h2 class="text-xl font-bold bg-gradient-to-r from-purple-600 to-pink-600 bg-clip-text text-transparent">SnackAttack</h2>
|
| 149 |
+
</div>
|
| 150 |
+
<p class="text-gray-500 mt-2">Satisfying cravings since 2023</p>
|
| 151 |
+
</div>
|
| 152 |
+
<div class="flex space-x-6">
|
| 153 |
+
<a href="#" class="text-gray-500 hover:text-purple-600"><i class="fab fa-twitter text-xl"></i></a>
|
| 154 |
+
<a href="#" class="text-gray-500 hover:text-purple-600"><i class="fab fa-instagram text-xl"></i></a>
|
| 155 |
+
<a href="#" class="text-gray-500 hover:text-purple-600"><i class="fab fa-facebook text-xl"></i></a>
|
| 156 |
+
</div>
|
| 157 |
+
</div>
|
| 158 |
+
<div class="border-t border-gray-200 mt-8 pt-8 text-center text-gray-500 text-sm">
|
| 159 |
+
<p>© 2023 SnackAttack. All rights reserved.</p>
|
| 160 |
+
</div>
|
| 161 |
+
</div>
|
| 162 |
+
</footer>
|
| 163 |
+
|
| 164 |
+
<script>
|
| 165 |
+
// Snack data
|
| 166 |
+
const snacks = [
|
| 167 |
+
{ id: 1, name: "Crunchy Potato Chips", price: 2.99, category: "chips", image: "https://images.unsplash.com/photo-1621259182978-fbf93132d53d?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1332&q=80" },
|
| 168 |
+
{ id: 2, name: "Chocolate Bar", price: 3.49, category: "chocolate", image: "https://images.unsplash.com/photo-1575377427642-087cf684f29d?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=774&q=80" },
|
| 169 |
+
{ id: 3, name: "Salted Almonds", price: 4.99, category: "nuts", image: "https://images.unsplash.com/photo-1617317962009-3c49a1b17b6e?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=774&q=80" },
|
| 170 |
+
{ id: 4, name: "Gummy Bears", price: 2.49, category: "candy", image: "https://images.unsplash.com/photo-1604187351574-c75ca79f5807?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1740&q=80" },
|
| 171 |
+
{ id: 5, name: "Chocolate Chip Cookies", price: 3.99, category: "cookies", image: "https://images.unsplash.com/photo-1558961363-fa8fdf82db35?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1064&q=80" },
|
| 172 |
+
{ id: 6, name: "BBQ Corn Chips", price: 2.79, category: "chips", image: "https://images.unsplash.com/photo-1561758033-48d52648ae8b?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=774&q=80" },
|
| 173 |
+
{ id: 7, name: "Dark Chocolate", price: 3.99, category: "chocolate", image: "https://images.unsplash.com/photo-1606313564200-e75c5edbdd77?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1740&q=80" },
|
| 174 |
+
{ id: 8, name: "Caramel Popcorn", price: 3.29, category: "candy", image: "https://images.unsplash.com/photo-1571575173700-afb9492e6a50?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=774&q=80" }
|
| 175 |
+
];
|
| 176 |
+
|
| 177 |
+
// Cart state
|
| 178 |
+
let cart = [];
|
| 179 |
+
let currentCategory = 'all';
|
| 180 |
+
|
| 181 |
+
// DOM elements
|
| 182 |
+
const snacksContainer = document.getElementById('snacks-container');
|
| 183 |
+
const cartBtn = document.getElementById('cart-btn');
|
| 184 |
+
const cartCount = document.getElementById('cart-count');
|
| 185 |
+
const cartSidebar = document.getElementById('cart-sidebar');
|
| 186 |
+
const closeCartBtn = document.getElementById('close-cart');
|
| 187 |
+
const cartOverlay = document.getElementById('cart-overlay');
|
| 188 |
+
const cartItems = document.getElementById('cart-items');
|
| 189 |
+
const cartSubtotal = document.getElementById('cart-subtotal');
|
| 190 |
+
const cartTotal = document.getElementById('cart-total');
|
| 191 |
+
const checkoutBtn = document.getElementById('checkout-btn');
|
| 192 |
+
const categoryBtns = document.querySelectorAll('.category-btn');
|
| 193 |
+
const confettiContainer = document.getElementById('confetti-container');
|
| 194 |
+
|
| 195 |
+
// Initialize the app
|
| 196 |
+
function init() {
|
| 197 |
+
renderSnacks();
|
| 198 |
+
setupEventListeners();
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
// Render snacks based on current category
|
| 202 |
+
function renderSnacks() {
|
| 203 |
+
snacksContainer.innerHTML = '';
|
| 204 |
+
|
| 205 |
+
const filteredSnacks = currentCategory === 'all'
|
| 206 |
+
? snacks
|
| 207 |
+
: snacks.filter(snack => snack.category === currentCategory);
|
| 208 |
+
|
| 209 |
+
filteredSnacks.forEach(snack => {
|
| 210 |
+
const snackCard = document.createElement('div');
|
| 211 |
+
snackCard.className = 'snack-card bg-white rounded-xl shadow-md overflow-hidden transition-all duration-300';
|
| 212 |
+
snackCard.innerHTML = `
|
| 213 |
+
<div class="relative h-48 overflow-hidden">
|
| 214 |
+
<img src="${snack.image}" alt="${snack.name}" class="w-full h-full object-cover">
|
| 215 |
+
<div class="absolute top-2 right-2 bg-white rounded-full p-2 shadow-md">
|
| 216 |
+
<i class="fas fa-heart text-gray-300 hover:text-pink-500 cursor-pointer"></i>
|
| 217 |
+
</div>
|
| 218 |
+
</div>
|
| 219 |
+
<div class="p-4">
|
| 220 |
+
<h4 class="font-bold text-lg text-gray-800 mb-1">${snack.name}</h4>
|
| 221 |
+
<p class="text-purple-600 font-bold mb-4">$${snack.price.toFixed(2)}</p>
|
| 222 |
+
<button class="add-to-cart w-full bg-purple-100 text-purple-700 py-2 rounded-lg font-medium hover:bg-purple-200 transition-all" data-id="${snack.id}">
|
| 223 |
+
Add to Cart
|
| 224 |
+
</button>
|
| 225 |
+
</div>
|
| 226 |
+
`;
|
| 227 |
+
snacksContainer.appendChild(snackCard);
|
| 228 |
+
});
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
// Setup event listeners
|
| 232 |
+
function setupEventListeners() {
|
| 233 |
+
// Cart toggle
|
| 234 |
+
cartBtn.addEventListener('click', () => {
|
| 235 |
+
cartSidebar.classList.remove('translate-x-full');
|
| 236 |
+
cartOverlay.classList.remove('hidden');
|
| 237 |
+
document.body.style.overflow = 'hidden';
|
| 238 |
+
});
|
| 239 |
+
|
| 240 |
+
closeCartBtn.addEventListener('click', closeCart);
|
| 241 |
+
cartOverlay.addEventListener('click', closeCart);
|
| 242 |
+
|
| 243 |
+
// Category filtering
|
| 244 |
+
categoryBtns.forEach(btn => {
|
| 245 |
+
btn.addEventListener('click', () => {
|
| 246 |
+
// Update active category button
|
| 247 |
+
categoryBtns.forEach(b => b.classList.remove('bg-purple-100', 'text-purple-700'));
|
| 248 |
+
categoryBtns.forEach(b => b.classList.add('bg-gray-100', 'text-gray-700'));
|
| 249 |
+
btn.classList.remove('bg-gray-100', 'text-gray-700');
|
| 250 |
+
btn.classList.add('bg-purple-100', 'text-purple-700');
|
| 251 |
+
|
| 252 |
+
// Update category and re-render
|
| 253 |
+
currentCategory = btn.dataset.category;
|
| 254 |
+
renderSnacks();
|
| 255 |
+
});
|
| 256 |
+
});
|
| 257 |
+
|
| 258 |
+
// Add to cart (delegated event)
|
| 259 |
+
document.addEventListener('click', (e) => {
|
| 260 |
+
if (e.target.classList.contains('add-to-cart')) {
|
| 261 |
+
const snackId = parseInt(e.target.dataset.id);
|
| 262 |
+
addToCart(snackId);
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
// Remove item from cart
|
| 266 |
+
if (e.target.classList.contains('remove-item')) {
|
| 267 |
+
const snackId = parseInt(e.target.dataset.id);
|
| 268 |
+
removeFromCart(snackId);
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
// Quantity adjustment
|
| 272 |
+
if (e.target.classList.contains('quantity-up')) {
|
| 273 |
+
const snackId = parseInt(e.target.dataset.id);
|
| 274 |
+
adjustQuantity(snackId, 1);
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
if (e.target.classList.contains('quantity-down')) {
|
| 278 |
+
const snackId = parseInt(e.target.dataset.id);
|
| 279 |
+
adjustQuantity(snackId, -1);
|
| 280 |
+
}
|
| 281 |
+
});
|
| 282 |
+
|
| 283 |
+
// Checkout button
|
| 284 |
+
checkoutBtn.addEventListener('click', () => {
|
| 285 |
+
if (cart.length > 0) {
|
| 286 |
+
// Show confetti
|
| 287 |
+
createConfetti();
|
| 288 |
+
|
| 289 |
+
// Reset cart
|
| 290 |
+
cart = [];
|
| 291 |
+
updateCartUI();
|
| 292 |
+
closeCart();
|
| 293 |
+
|
| 294 |
+
// Show success message
|
| 295 |
+
setTimeout(() => {
|
| 296 |
+
alert('Order placed successfully! Your snacks are on the way! ');
|
| 297 |
+
}, 500);
|
| 298 |
+
}
|
| 299 |
+
});
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
// Add item to cart
|
| 303 |
+
function addToCart(snackId) {
|
| 304 |
+
const snack = snacks.find(s => s.id === snackId);
|
| 305 |
+
const existingItem = cart.find(item => item.id === snackId);
|
| 306 |
+
|
| 307 |
+
if (existingItem) {
|
| 308 |
+
existingItem.quantity += 1;
|
| 309 |
+
} else {
|
| 310 |
+
cart.push({
|
| 311 |
+
id: snack.id,
|
| 312 |
+
name: snack.name,
|
| 313 |
+
price: snack.price,
|
| 314 |
+
quantity: 1,
|
| 315 |
+
image: snack.image
|
| 316 |
+
});
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
updateCartUI();
|
| 320 |
+
|
| 321 |
+
// Pulse cart button
|
| 322 |
+
cartBtn.classList.add('cart-pulse');
|
| 323 |
+
setTimeout(() => {
|
| 324 |
+
cartBtn.classList.remove('cart-pulse');
|
| 325 |
+
}, 1000);
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
// Remove item from cart
|
| 329 |
+
function removeFromCart(snackId) {
|
| 330 |
+
cart = cart.filter(item => item.id !== snackId);
|
| 331 |
+
updateCartUI();
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
// Adjust item quantity
|
| 335 |
+
function adjustQuantity(snackId, change) {
|
| 336 |
+
const item = cart.find(item => item.id === snackId);
|
| 337 |
+
if (item) {
|
| 338 |
+
item.quantity += change;
|
| 339 |
+
|
| 340 |
+
// Remove if quantity is 0 or less
|
| 341 |
+
if (item.quantity <= 0) {
|
| 342 |
+
removeFromCart(snackId);
|
| 343 |
+
} else {
|
| 344 |
+
updateCartUI();
|
| 345 |
+
}
|
| 346 |
+
}
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
// Update cart UI
|
| 350 |
+
function updateCartUI() {
|
| 351 |
+
// Update cart count
|
| 352 |
+
const totalItems = cart.reduce((sum, item) => sum + item.quantity, 0);
|
| 353 |
+
cartCount.textContent = totalItems;
|
| 354 |
+
|
| 355 |
+
// Update cart items list
|
| 356 |
+
if (cart.length === 0) {
|
| 357 |
+
cartItems.innerHTML = `
|
| 358 |
+
<div class="text-center py-10">
|
| 359 |
+
<i class="fas fa-shopping-cart text-4xl text-gray-300 mb-4"></i>
|
| 360 |
+
<p class="text-gray-500">Your cart is empty</p>
|
| 361 |
+
</div>
|
| 362 |
+
`;
|
| 363 |
+
checkoutBtn.disabled = true;
|
| 364 |
+
} else {
|
| 365 |
+
cartItems.innerHTML = cart.map(item => `
|
| 366 |
+
<div class="flex items-center p-3 bg-gray-50 rounded-lg">
|
| 367 |
+
<img src="${item.image}" alt="${item.name}" class="w-16 h-16 object-cover rounded-lg">
|
| 368 |
+
<div class="ml-4 flex-1">
|
| 369 |
+
<h4 class="font-medium text-gray-800">${item.name}</h4>
|
| 370 |
+
<p class="text-purple-600 font-bold">$${item.price.toFixed(2)}</p>
|
| 371 |
+
</div>
|
| 372 |
+
<div class="flex items-center">
|
| 373 |
+
<button class="quantity-down w-8 h-8 rounded-full bg-gray-200 text-gray-700 flex items-center justify-center" data-id="${item.id}">
|
| 374 |
+
<i class="fas fa-minus text-xs"></i>
|
| 375 |
+
</button>
|
| 376 |
+
<span class="mx-2 font-medium">${item.quantity}</span>
|
| 377 |
+
<button class="quantity-up w-8 h-8 rounded-full bg-purple-100 text-purple-700 flex items-center justify-center" data-id="${item.id}">
|
| 378 |
+
<i class="fas fa-plus text-xs"></i>
|
| 379 |
+
</button>
|
| 380 |
+
</div>
|
| 381 |
+
<button class="remove-item ml-4 text-gray-400 hover:text-red-500" data-id="${item.id}">
|
| 382 |
+
<i class="fas fa-trash"></i>
|
| 383 |
+
</button>
|
| 384 |
+
</div>
|
| 385 |
+
`).join('');
|
| 386 |
+
|
| 387 |
+
checkoutBtn.disabled = false;
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
// Update totals
|
| 391 |
+
const subtotal = cart.reduce((sum, item) => sum + (item.price * item.quantity), 0);
|
| 392 |
+
cartSubtotal.textContent = `$${subtotal.toFixed(2)}`;
|
| 393 |
+
cartTotal.textContent = `$${(subtotal + 2.99).toFixed(2)}`;
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
// Close cart
|
| 397 |
+
function closeCart() {
|
| 398 |
+
cartSidebar.classList.add('translate-x-full');
|
| 399 |
+
cartOverlay.classList.add('hidden');
|
| 400 |
+
document.body.style.overflow = 'auto';
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
// Create confetti effect
|
| 404 |
+
function createConfetti() {
|
| 405 |
+
confettiContainer.innerHTML = '';
|
| 406 |
+
confettiContainer.classList.remove('hidden');
|
| 407 |
+
|
| 408 |
+
// Create confetti elements
|
| 409 |
+
for (let i = 0; i < 100; i++) {
|
| 410 |
+
const confetti = document.createElement('div');
|
| 411 |
+
confetti.className = 'absolute w-2 h-2 rounded-full';
|
| 412 |
+
|
| 413 |
+
// Random colors
|
| 414 |
+
const colors = ['bg-purple-500', 'bg-pink-500', 'bg-yellow-400', 'bg-blue-400'];
|
| 415 |
+
const randomColor = colors[Math.floor(Math.random() * colors.length)];
|
| 416 |
+
confetti.classList.add(randomColor);
|
| 417 |
+
|
| 418 |
+
// Random position and animation
|
| 419 |
+
confetti.style.left = `${Math.random() * 100}%`;
|
| 420 |
+
confetti.style.top = `${Math.random() * 100}%`;
|
| 421 |
+
confetti.style.transform = `rotate(${Math.random() * 360}deg)`;
|
| 422 |
+
confetti.style.animation = `fall ${Math.random() * 3 + 2}s linear forwards`;
|
| 423 |
+
|
| 424 |
+
confettiContainer.appendChild(confetti);
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
// Add CSS for falling animation
|
| 428 |
+
const style = document.createElement('style');
|
| 429 |
+
style.textContent = `
|
| 430 |
+
@keyframes fall {
|
| 431 |
+
to {
|
| 432 |
+
transform: translateY(100vh) rotate(360deg);
|
| 433 |
+
opacity: 0;
|
| 434 |
+
}
|
| 435 |
+
}
|
| 436 |
+
`;
|
| 437 |
+
document.head.appendChild(style);
|
| 438 |
+
|
| 439 |
+
// Hide after animation
|
| 440 |
+
setTimeout(() => {
|
| 441 |
+
confettiContainer.classList.add('hidden');
|
| 442 |
+
}, 3000);
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
// Initialize the app
|
| 446 |
+
init();
|
| 447 |
+
</script>
|
| 448 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=froilo/candy-test" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 449 |
+
</html>
|