Spaces:
Running
Running
File size: 23,866 Bytes
0107898 |
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 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SnackAttack - Quick Bites Delivered</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-10px); }
}
.floating {
animation: float 3s ease-in-out infinite;
}
.snack-card:hover {
transform: translateY(-5px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.cart-pulse {
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.1); }
100% { transform: scale(1); }
}
</style>
</head>
<body class="bg-gradient-to-br from-purple-50 to-pink-50 min-h-screen">
<!-- Header -->
<header class="sticky top-0 z-50 bg-white shadow-sm">
<div class="container mx-auto px-4 py-3 flex justify-between items-center">
<div class="flex items-center space-x-2">
<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>
<h1 class="text-2xl font-bold bg-gradient-to-r from-purple-600 to-pink-600 bg-clip-text text-transparent">SnackAttack</h1>
</div>
<div class="flex items-center space-x-4">
<button id="cart-btn" class="relative">
<i class="fas fa-shopping-cart text-2xl text-purple-600"></i>
<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>
</button>
<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>
</div>
</div>
</header>
<!-- Hero Section -->
<section class="container mx-auto px-4 py-12 flex flex-col md:flex-row items-center">
<div class="md:w-1/2 mb-8 md:mb-0">
<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>
<p class="text-lg text-gray-600 mb-6">Get your favorite munchies delivered in minutes. Perfect for those sudden snack emergencies!</p>
<div class="flex space-x-4">
<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>
<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>
</div>
</div>
<div class="md:w-1/2 flex justify-center">
<div class="relative w-full max-w-md">
<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"
alt="Assorted snacks"
class="rounded-2xl shadow-xl w-full h-auto floating">
<div class="absolute -bottom-4 -right-4 bg-white p-3 rounded-xl shadow-lg">
<div class="flex items-center">
<div class="w-10 h-10 rounded-full bg-yellow-400 flex items-center justify-center text-white">
<i class="fas fa-bolt"></i>
</div>
<div class="ml-2">
<p class="text-xs text-gray-500">Delivery in</p>
<p class="font-bold text-purple-600">15-20 min</p>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Categories -->
<section class="container mx-auto px-4 py-8">
<h3 class="text-2xl font-bold text-gray-800 mb-6">What are you craving?</h3>
<div class="flex overflow-x-auto pb-4 space-x-4 scrollbar-hide">
<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>
<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>
<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>
<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>
<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>
<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>
</div>
</section>
<!-- Snacks Grid -->
<section class="container mx-auto px-4 py-8">
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6" id="snacks-container">
<!-- Snack cards will be inserted here by JavaScript -->
</div>
</section>
<!-- Cart Sidebar -->
<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">
<div class="p-6">
<div class="flex justify-between items-center mb-6">
<h3 class="text-2xl font-bold text-gray-800">Your Snack Cart</h3>
<button id="close-cart" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times text-2xl"></i>
</button>
</div>
<div id="cart-items" class="space-y-4 mb-6">
<!-- Cart items will be inserted here -->
<div class="text-center py-10">
<i class="fas fa-shopping-cart text-4xl text-gray-300 mb-4"></i>
<p class="text-gray-500">Your cart is empty</p>
</div>
</div>
<div class="border-t border-gray-200 pt-4">
<div class="flex justify-between mb-2">
<span class="text-gray-600">Subtotal</span>
<span id="cart-subtotal" class="font-medium">$0.00</span>
</div>
<div class="flex justify-between mb-4">
<span class="text-gray-600">Delivery</span>
<span class="font-medium">$2.99</span>
</div>
<div class="flex justify-between text-lg font-bold mb-6">
<span>Total</span>
<span id="cart-total">$2.99</span>
</div>
<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>
Checkout
</button>
</div>
</div>
</div>
<div id="cart-overlay" class="fixed inset-0 bg-black bg-opacity-50 z-40 hidden"></div>
<!-- Confetti Effect Container -->
<div id="confetti-container" class="fixed inset-0 pointer-events-none z-60 overflow-hidden hidden"></div>
<!-- Footer -->
<footer class="bg-white py-8 mt-12">
<div class="container mx-auto px-4">
<div class="flex flex-col md:flex-row justify-between items-center">
<div class="mb-6 md:mb-0">
<div class="flex items-center space-x-2">
<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>
<h2 class="text-xl font-bold bg-gradient-to-r from-purple-600 to-pink-600 bg-clip-text text-transparent">SnackAttack</h2>
</div>
<p class="text-gray-500 mt-2">Satisfying cravings since 2023</p>
</div>
<div class="flex space-x-6">
<a href="#" class="text-gray-500 hover:text-purple-600"><i class="fab fa-twitter text-xl"></i></a>
<a href="#" class="text-gray-500 hover:text-purple-600"><i class="fab fa-instagram text-xl"></i></a>
<a href="#" class="text-gray-500 hover:text-purple-600"><i class="fab fa-facebook text-xl"></i></a>
</div>
</div>
<div class="border-t border-gray-200 mt-8 pt-8 text-center text-gray-500 text-sm">
<p>© 2023 SnackAttack. All rights reserved.</p>
</div>
</div>
</footer>
<script>
// Snack data
const snacks = [
{ 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" },
{ 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" },
{ 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" },
{ 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" },
{ 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" },
{ 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" },
{ 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" },
{ 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" }
];
// Cart state
let cart = [];
let currentCategory = 'all';
// DOM elements
const snacksContainer = document.getElementById('snacks-container');
const cartBtn = document.getElementById('cart-btn');
const cartCount = document.getElementById('cart-count');
const cartSidebar = document.getElementById('cart-sidebar');
const closeCartBtn = document.getElementById('close-cart');
const cartOverlay = document.getElementById('cart-overlay');
const cartItems = document.getElementById('cart-items');
const cartSubtotal = document.getElementById('cart-subtotal');
const cartTotal = document.getElementById('cart-total');
const checkoutBtn = document.getElementById('checkout-btn');
const categoryBtns = document.querySelectorAll('.category-btn');
const confettiContainer = document.getElementById('confetti-container');
// Initialize the app
function init() {
renderSnacks();
setupEventListeners();
}
// Render snacks based on current category
function renderSnacks() {
snacksContainer.innerHTML = '';
const filteredSnacks = currentCategory === 'all'
? snacks
: snacks.filter(snack => snack.category === currentCategory);
filteredSnacks.forEach(snack => {
const snackCard = document.createElement('div');
snackCard.className = 'snack-card bg-white rounded-xl shadow-md overflow-hidden transition-all duration-300';
snackCard.innerHTML = `
<div class="relative h-48 overflow-hidden">
<img src="${snack.image}" alt="${snack.name}" class="w-full h-full object-cover">
<div class="absolute top-2 right-2 bg-white rounded-full p-2 shadow-md">
<i class="fas fa-heart text-gray-300 hover:text-pink-500 cursor-pointer"></i>
</div>
</div>
<div class="p-4">
<h4 class="font-bold text-lg text-gray-800 mb-1">${snack.name}</h4>
<p class="text-purple-600 font-bold mb-4">$${snack.price.toFixed(2)}</p>
<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}">
Add to Cart
</button>
</div>
`;
snacksContainer.appendChild(snackCard);
});
}
// Setup event listeners
function setupEventListeners() {
// Cart toggle
cartBtn.addEventListener('click', () => {
cartSidebar.classList.remove('translate-x-full');
cartOverlay.classList.remove('hidden');
document.body.style.overflow = 'hidden';
});
closeCartBtn.addEventListener('click', closeCart);
cartOverlay.addEventListener('click', closeCart);
// Category filtering
categoryBtns.forEach(btn => {
btn.addEventListener('click', () => {
// Update active category button
categoryBtns.forEach(b => b.classList.remove('bg-purple-100', 'text-purple-700'));
categoryBtns.forEach(b => b.classList.add('bg-gray-100', 'text-gray-700'));
btn.classList.remove('bg-gray-100', 'text-gray-700');
btn.classList.add('bg-purple-100', 'text-purple-700');
// Update category and re-render
currentCategory = btn.dataset.category;
renderSnacks();
});
});
// Add to cart (delegated event)
document.addEventListener('click', (e) => {
if (e.target.classList.contains('add-to-cart')) {
const snackId = parseInt(e.target.dataset.id);
addToCart(snackId);
}
// Remove item from cart
if (e.target.classList.contains('remove-item')) {
const snackId = parseInt(e.target.dataset.id);
removeFromCart(snackId);
}
// Quantity adjustment
if (e.target.classList.contains('quantity-up')) {
const snackId = parseInt(e.target.dataset.id);
adjustQuantity(snackId, 1);
}
if (e.target.classList.contains('quantity-down')) {
const snackId = parseInt(e.target.dataset.id);
adjustQuantity(snackId, -1);
}
});
// Checkout button
checkoutBtn.addEventListener('click', () => {
if (cart.length > 0) {
// Show confetti
createConfetti();
// Reset cart
cart = [];
updateCartUI();
closeCart();
// Show success message
setTimeout(() => {
alert('Order placed successfully! Your snacks are on the way! ');
}, 500);
}
});
}
// Add item to cart
function addToCart(snackId) {
const snack = snacks.find(s => s.id === snackId);
const existingItem = cart.find(item => item.id === snackId);
if (existingItem) {
existingItem.quantity += 1;
} else {
cart.push({
id: snack.id,
name: snack.name,
price: snack.price,
quantity: 1,
image: snack.image
});
}
updateCartUI();
// Pulse cart button
cartBtn.classList.add('cart-pulse');
setTimeout(() => {
cartBtn.classList.remove('cart-pulse');
}, 1000);
}
// Remove item from cart
function removeFromCart(snackId) {
cart = cart.filter(item => item.id !== snackId);
updateCartUI();
}
// Adjust item quantity
function adjustQuantity(snackId, change) {
const item = cart.find(item => item.id === snackId);
if (item) {
item.quantity += change;
// Remove if quantity is 0 or less
if (item.quantity <= 0) {
removeFromCart(snackId);
} else {
updateCartUI();
}
}
}
// Update cart UI
function updateCartUI() {
// Update cart count
const totalItems = cart.reduce((sum, item) => sum + item.quantity, 0);
cartCount.textContent = totalItems;
// Update cart items list
if (cart.length === 0) {
cartItems.innerHTML = `
<div class="text-center py-10">
<i class="fas fa-shopping-cart text-4xl text-gray-300 mb-4"></i>
<p class="text-gray-500">Your cart is empty</p>
</div>
`;
checkoutBtn.disabled = true;
} else {
cartItems.innerHTML = cart.map(item => `
<div class="flex items-center p-3 bg-gray-50 rounded-lg">
<img src="${item.image}" alt="${item.name}" class="w-16 h-16 object-cover rounded-lg">
<div class="ml-4 flex-1">
<h4 class="font-medium text-gray-800">${item.name}</h4>
<p class="text-purple-600 font-bold">$${item.price.toFixed(2)}</p>
</div>
<div class="flex items-center">
<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}">
<i class="fas fa-minus text-xs"></i>
</button>
<span class="mx-2 font-medium">${item.quantity}</span>
<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}">
<i class="fas fa-plus text-xs"></i>
</button>
</div>
<button class="remove-item ml-4 text-gray-400 hover:text-red-500" data-id="${item.id}">
<i class="fas fa-trash"></i>
</button>
</div>
`).join('');
checkoutBtn.disabled = false;
}
// Update totals
const subtotal = cart.reduce((sum, item) => sum + (item.price * item.quantity), 0);
cartSubtotal.textContent = `$${subtotal.toFixed(2)}`;
cartTotal.textContent = `$${(subtotal + 2.99).toFixed(2)}`;
}
// Close cart
function closeCart() {
cartSidebar.classList.add('translate-x-full');
cartOverlay.classList.add('hidden');
document.body.style.overflow = 'auto';
}
// Create confetti effect
function createConfetti() {
confettiContainer.innerHTML = '';
confettiContainer.classList.remove('hidden');
// Create confetti elements
for (let i = 0; i < 100; i++) {
const confetti = document.createElement('div');
confetti.className = 'absolute w-2 h-2 rounded-full';
// Random colors
const colors = ['bg-purple-500', 'bg-pink-500', 'bg-yellow-400', 'bg-blue-400'];
const randomColor = colors[Math.floor(Math.random() * colors.length)];
confetti.classList.add(randomColor);
// Random position and animation
confetti.style.left = `${Math.random() * 100}%`;
confetti.style.top = `${Math.random() * 100}%`;
confetti.style.transform = `rotate(${Math.random() * 360}deg)`;
confetti.style.animation = `fall ${Math.random() * 3 + 2}s linear forwards`;
confettiContainer.appendChild(confetti);
}
// Add CSS for falling animation
const style = document.createElement('style');
style.textContent = `
@keyframes fall {
to {
transform: translateY(100vh) rotate(360deg);
opacity: 0;
}
}
`;
document.head.appendChild(style);
// Hide after animation
setTimeout(() => {
confettiContainer.classList.add('hidden');
}, 3000);
}
// Initialize the app
init();
</script>
<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>
</html> |