Spaces:
Running
Running
create a industy leadng menu ordering food experience for a small town resurant
Browse files- README.md +8 -5
- cart.html +39 -0
- cart.js +69 -0
- components/footer.js +40 -0
- components/header.js +53 -0
- index.html +77 -19
- script.js +118 -0
- style.css +37 -21
README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: BistroByte 🍽️
|
| 3 |
+
colorFrom: purple
|
| 4 |
+
colorTo: pink
|
| 5 |
+
emoji: 🐳
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://huggingface.co/deepsite).
|
cart.html
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>Cart – BistroByte</title>
|
| 7 |
+
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
| 8 |
+
<link rel="stylesheet" href="style.css">
|
| 9 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 10 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 11 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 12 |
+
</head>
|
| 13 |
+
<body class="bg-gray-50 dark:bg-gray-900 text-gray-800 dark:text-gray-100 transition-colors">
|
| 14 |
+
<custom-header></custom-header>
|
| 15 |
+
|
| 16 |
+
<main class="max-w-3xl mx-auto px-4 py-10">
|
| 17 |
+
<h1 class="text-3xl font-bold mb-6">Your Order</h1>
|
| 18 |
+
<div id="cartList" class="space-y-4">
|
| 19 |
+
<!-- Cart items injected by JS -->
|
| 20 |
+
</div>
|
| 21 |
+
<div id="cartEmpty" class="hidden text-center py-16">
|
| 22 |
+
<i data-feather="shopping-cart" class="w-16 h-16 mx-auto text-gray-300"></i>
|
| 23 |
+
<p class="mt-4 text-gray-500">Your cart is empty. <a href="index.html" class="text-orange-500 hover:underline">Go add some goodies!</a></p>
|
| 24 |
+
</div>
|
| 25 |
+
<div id="cartTotal" class="mt-6 border-t dark:border-gray-700 pt-4 flex justify-between items-center">
|
| 26 |
+
<span class="text-xl font-semibold">Total</span>
|
| 27 |
+
<span id="totalPrice" class="text-2xl font-bold text-orange-500">$0.00</span>
|
| 28 |
+
</div>
|
| 29 |
+
<button id="checkoutBtn" class="mt-6 w-full px-6 py-3 rounded-full bg-orange-500 hover:bg-orange-600 text-white font-semibold shadow-lg hover:shadow-xl transform hover:-translate-y-0.5 transition disabled:opacity-50 disabled:cursor-not-allowed">Proceed to Pickup</button>
|
| 30 |
+
</main>
|
| 31 |
+
|
| 32 |
+
<custom-footer></custom-footer>
|
| 33 |
+
|
| 34 |
+
<script src="components/header.js"></script>
|
| 35 |
+
<script src="components/footer.js"></script>
|
| 36 |
+
<script src="cart.js"></script>
|
| 37 |
+
<script>feather.replace();</script>
|
| 38 |
+
</body>
|
| 39 |
+
</html>
|
cart.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const Store = {
|
| 2 |
+
cart: JSON.parse(localStorage.getItem('bbCart') || '[]')
|
| 3 |
+
};
|
| 4 |
+
|
| 5 |
+
function renderCart() {
|
| 6 |
+
const list = document.getElementById('cartList');
|
| 7 |
+
const empty = document.getElementById('cartEmpty');
|
| 8 |
+
const totalEl = document.getElementById('totalPrice');
|
| 9 |
+
const checkout = document.getElementById('checkoutBtn');
|
| 10 |
+
|
| 11 |
+
if (Store.cart.length === 0) {
|
| 12 |
+
empty.classList.remove('hidden');
|
| 13 |
+
list.innerHTML = '';
|
| 14 |
+
totalEl.textContent = '$0.00';
|
| 15 |
+
checkout.disabled = true;
|
| 16 |
+
return;
|
| 17 |
+
}
|
| 18 |
+
empty.classList.add('hidden');
|
| 19 |
+
checkout.disabled = false;
|
| 20 |
+
|
| 21 |
+
let total = 0;
|
| 22 |
+
list.innerHTML = Store.cart.map(item => {
|
| 23 |
+
const sub = item.price * item.qty;
|
| 24 |
+
total += sub;
|
| 25 |
+
return `
|
| 26 |
+
<div class="flex gap-4 items-center bg-white dark:bg-gray-800 p-4 rounded-2xl shadow">
|
| 27 |
+
<img src="${item.img}" alt="${item.name}" class="w-20 h-20 rounded-lg object-cover">
|
| 28 |
+
<div class="flex-1">
|
| 29 |
+
<h3 class="font-semibold">${item.name}</h3>
|
| 30 |
+
<p class="text-sm text-gray-500 dark:text-gray-400">$${item.price.toFixed(2)} each</p>
|
| 31 |
+
</div>
|
| 32 |
+
<div class="flex items-center gap-2">
|
| 33 |
+
<button class="qty-btn" data-id="${item.id}" data-action="dec"><i data-feather="minus" class="w-4 h-4"></i></button>
|
| 34 |
+
<span class="w-8 text-center">${item.qty}</span>
|
| 35 |
+
<button class="qty-btn" data-id="${item.id}" data-action="inc"><i data-feather="plus" class="w-4 h-4"></i></button>
|
| 36 |
+
</div>
|
| 37 |
+
<span class="font-bold text-orange-500 w-16 text-right">$${sub.toFixed(2)}</span>
|
| 38 |
+
</div>
|
| 39 |
+
`;
|
| 40 |
+
}).join('');
|
| 41 |
+
totalEl.textContent = `$${total.toFixed(2)}`;
|
| 42 |
+
feather.replace();
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
function changeQty(e) {
|
| 46 |
+
const id = +e.currentTarget.dataset.id;
|
| 47 |
+
const action = e.currentTarget.dataset.action;
|
| 48 |
+
const item = Store.cart.find(i => i.id === id);
|
| 49 |
+
if (action === 'inc') item.qty += 1;
|
| 50 |
+
else {
|
| 51 |
+
item.qty -= 1;
|
| 52 |
+
if (item.qty <= 0) Store.cart = Store.cart.filter(i => i.id !== id);
|
| 53 |
+
}
|
| 54 |
+
localStorage.setItem('bbCart', JSON.stringify(Store.cart));
|
| 55 |
+
renderCart();
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
document.addEventListener('click', e => {
|
| 59 |
+
if (e.target.closest('.qty-btn')) changeQty(e);
|
| 60 |
+
});
|
| 61 |
+
|
| 62 |
+
document.getElementById('checkoutBtn').addEventListener('click', () => {
|
| 63 |
+
alert("Thanks! We'll start cooking and text you when it's ready.");
|
| 64 |
+
Store.cart = [];
|
| 65 |
+
localStorage.removeItem('bbCart');
|
| 66 |
+
renderCart();
|
| 67 |
+
});
|
| 68 |
+
|
| 69 |
+
renderCart();
|
components/footer.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class CustomFooter extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
this.attachShadow({ mode: 'open' });
|
| 4 |
+
this.shadowRoot.innerHTML = `
|
| 5 |
+
<style>
|
| 6 |
+
footer {
|
| 7 |
+
margin-top: 4rem;
|
| 8 |
+
padding: 2rem 1.5rem;
|
| 9 |
+
text-align: center;
|
| 10 |
+
border-top: 1px solid #e5e7eb;
|
| 11 |
+
font-size: 0.875rem;
|
| 12 |
+
color: #6b7280;
|
| 13 |
+
}
|
| 14 |
+
.dark footer {
|
| 15 |
+
border-color: #374151;
|
| 16 |
+
color: #9ca3af;
|
| 17 |
+
}
|
| 18 |
+
.social {
|
| 19 |
+
display: flex;
|
| 20 |
+
justify-content: center;
|
| 21 |
+
gap: 1rem;
|
| 22 |
+
margin-top: 1rem;
|
| 23 |
+
}
|
| 24 |
+
.social a {
|
| 25 |
+
color: #ff6a00;
|
| 26 |
+
}
|
| 27 |
+
</style>
|
| 28 |
+
<footer>
|
| 29 |
+
<p>© <span id="year"></span> BistroByte – Made with ❤️ in Smallville</p>
|
| 30 |
+
<div class="social">
|
| 31 |
+
<a href="#" aria-label="Instagram"><i data-feather="instagram"></i></a>
|
| 32 |
+
<a href="#" aria-label="Facebook"><i data-feather="facebook"></i></a>
|
| 33 |
+
<a href="#" aria-label="Phone"><i data-feather="phone"></i></a>
|
| 34 |
+
</div>
|
| 35 |
+
</footer>
|
| 36 |
+
`;
|
| 37 |
+
this.shadowRoot.getElementById('year').textContent = new Date().getFullYear();
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
customElements.define('custom-footer', CustomFooter);
|
components/header.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class CustomHeader extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
this.attachShadow({ mode: 'open' });
|
| 4 |
+
this.shadowRoot.innerHTML = `
|
| 5 |
+
<style>
|
| 6 |
+
header {
|
| 7 |
+
display: flex;
|
| 8 |
+
align-items: center;
|
| 9 |
+
justify-content: space-between;
|
| 10 |
+
padding: 1rem 1.5rem;
|
| 11 |
+
background: rgba(255,255,255,0.8);
|
| 12 |
+
backdrop-filter: blur(10px);
|
| 13 |
+
border-bottom: 1px solid #e5e7eb;
|
| 14 |
+
}
|
| 15 |
+
.dark header {
|
| 16 |
+
background: rgba(17,24,39,0.8);
|
| 17 |
+
border-color: #374151;
|
| 18 |
+
}
|
| 19 |
+
.logo {
|
| 20 |
+
font-weight: 800;
|
| 21 |
+
font-size: 1.25rem;
|
| 22 |
+
color: #ff6a00;
|
| 23 |
+
letter-spacing: -0.5px;
|
| 24 |
+
}
|
| 25 |
+
nav a {
|
| 26 |
+
margin-left: 1rem;
|
| 27 |
+
text-decoration: none;
|
| 28 |
+
color: #111827;
|
| 29 |
+
font-weight: 500;
|
| 30 |
+
}
|
| 31 |
+
.dark nav a {
|
| 32 |
+
color: #f3f4f6;
|
| 33 |
+
}
|
| 34 |
+
nav a:hover {
|
| 35 |
+
color: #ff6a00;
|
| 36 |
+
}
|
| 37 |
+
@media (max-width: 640px) {
|
| 38 |
+
nav {
|
| 39 |
+
display: none;
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
</style>
|
| 43 |
+
<header>
|
| 44 |
+
<div class="logo">BistroByte</div>
|
| 45 |
+
<nav>
|
| 46 |
+
<a href="index.html">Menu</a>
|
| 47 |
+
<a href="cart.html">Cart</a>
|
| 48 |
+
</nav>
|
| 49 |
+
</header>
|
| 50 |
+
`;
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
customElements.define('custom-header', CustomHeader);
|
index.html
CHANGED
|
@@ -1,19 +1,77 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>BistroByte – Small-Town Menu Magic</title>
|
| 7 |
+
<link rel="icon" type="image/x-icon" href="http://static.photos/food/64x64/42">
|
| 8 |
+
<link rel="stylesheet" href="style.css">
|
| 9 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 10 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 11 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 12 |
+
</head>
|
| 13 |
+
<body class="bg-gray-50 dark:bg-gray-900 text-gray-800 dark:text-gray-100 transition-colors">
|
| 14 |
+
<custom-header></custom-header>
|
| 15 |
+
|
| 16 |
+
<main>
|
| 17 |
+
<!-- HERO -->
|
| 18 |
+
<section class="relative h-[62vh] flex items-center justify-center text-center overflow-hidden">
|
| 19 |
+
<div class="absolute inset-0 z-0">
|
| 20 |
+
<img src="http://static.photos/restaurant/1200x630/7" alt="Cozy restaurant interior" class="w-full h-full object-cover">
|
| 21 |
+
<div class="absolute inset-0 bg-gradient-to-t from-black/60 via-black/30 to-transparent"></div>
|
| 22 |
+
</div>
|
| 23 |
+
<div class="relative z-10 px-4">
|
| 24 |
+
<h1 class="text-4xl md:text-6xl font-extrabold text-white drop-shadow-lg">Taste the Town</h1>
|
| 25 |
+
<p class="mt-4 text-lg md:text-xl text-white/90 max-w-xl mx-auto">Farm-fresh flavors, neighborly vibes, zero fuss.</p>
|
| 26 |
+
<a href="#menu" class="mt-6 inline-block px-6 py-3 rounded-full bg-orange-500 hover:bg-orange-600 text-white font-semibold shadow-lg hover:shadow-xl transform hover:-translate-y-0.5 transition">Explore Menu</a>
|
| 27 |
+
</div>
|
| 28 |
+
</section>
|
| 29 |
+
|
| 30 |
+
<!-- LIVE SEARCH & FILTERS -->
|
| 31 |
+
<section class="sticky top-0 z-20 bg-white/80 dark:bg-gray-900/80 backdrop-blur-lg border-b border-gray-200 dark:border-gray-700">
|
| 32 |
+
<div class="max-w-7xl mx-auto px-4 py-4 flex flex-col md:flex-row gap-4 items-center">
|
| 33 |
+
<div class="relative w-full md:w-1/3">
|
| 34 |
+
<i data-feather="search" class="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400"></i>
|
| 35 |
+
<input id="searchInput" type="text" placeholder="Search dishes, ingredients..." class="w-full pl-10 pr-4 py-2 rounded-full border border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-800 focus:ring-2 focus:ring-orange-400 outline-none">
|
| 36 |
+
</div>
|
| 37 |
+
<div class="flex gap-2 flex-wrap">
|
| 38 |
+
<button class="filter-btn active" data-filter="all">All</button>
|
| 39 |
+
<button class="filter-btn" data-filter="breakfast">Breakfast</button>
|
| 40 |
+
<button class="filter-btn" data-filter="lunch">Lunch</button>
|
| 41 |
+
<button class="filter-btn" data-filter="dinner">Dinner</button>
|
| 42 |
+
<button class="filter-btn" data-filter="dessert">Dessert</button>
|
| 43 |
+
<button class="filter-btn" data-filter="vegan">Vegan</button>
|
| 44 |
+
</div>
|
| 45 |
+
<div class="ml-auto flex items-center gap-2">
|
| 46 |
+
<button id="themeToggle" class="p-2 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700 transition" aria-label="Toggle theme">
|
| 47 |
+
<i data-feather="moon" class="w-5 h-5"></i>
|
| 48 |
+
</button>
|
| 49 |
+
<a href="cart.html" class="relative p-2 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700 transition">
|
| 50 |
+
<i data-feather="shopping-cart" class="w-5 h-5"></i>
|
| 51 |
+
<span id="cartBadge" class="absolute -top-1 -right-1 w-5 h-5 text-xs grid place-items-center bg-orange-500 text-white rounded-full hidden">0</span>
|
| 52 |
+
</a>
|
| 53 |
+
</div>
|
| 54 |
+
</div>
|
| 55 |
+
</section>
|
| 56 |
+
|
| 57 |
+
<!-- MENU GRID -->
|
| 58 |
+
<section id="menu" class="max-w-7xl mx-auto px-4 py-10">
|
| 59 |
+
<div id="menuGrid" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
| 60 |
+
<!-- Cards injected by JS -->
|
| 61 |
+
</div>
|
| 62 |
+
<div id="emptyState" class="hidden text-center py-16">
|
| 63 |
+
<i data-feather="coffee" class="w-16 h-16 mx-auto text-gray-300"></i>
|
| 64 |
+
<p class="mt-4 text-gray-500">No items match your search. Try something else?</p>
|
| 65 |
+
</div>
|
| 66 |
+
</section>
|
| 67 |
+
</main>
|
| 68 |
+
|
| 69 |
+
<custom-footer></custom-footer>
|
| 70 |
+
|
| 71 |
+
<script src="components/header.js"></script>
|
| 72 |
+
<script src="components/footer.js"></script>
|
| 73 |
+
<script src="script.js"></script>
|
| 74 |
+
<script>feather.replace();</script>
|
| 75 |
+
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
|
| 76 |
+
</body>
|
| 77 |
+
</html>
|
script.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Tiny singleton state
|
| 2 |
+
const Store = {
|
| 3 |
+
cart: JSON.parse(localStorage.getItem('bbCart') || '[]'),
|
| 4 |
+
menu: [],
|
| 5 |
+
filter: 'all',
|
| 6 |
+
search: ''
|
| 7 |
+
};
|
| 8 |
+
|
| 9 |
+
// Dummy menu (in real life: fetch from API)
|
| 10 |
+
const dummyMenu = [
|
| 11 |
+
{ id: 1, name: "Sunrise Skillet", price: 9.50, category: "breakfast", desc: "Two eggs, crispy potatoes, peppers & onions, cheddar, toast.", img: "http://static.photos/food/640x360/1" },
|
| 12 |
+
{ id: 2, name: "Buttermilk Pancakes", price: 8.00, category: "breakfast", desc: "Stack of three, maple syrup, whipped butter.", img: "http://static.photos/food/640x360/2" },
|
| 13 |
+
{ id: 3, name: "Town Club", price: 11.00, category: "lunch", desc: "Roasted turkey, bacon, lettuce, tomato, mayo on sourdough.", img: "http://static.photos/food/640x360/3" },
|
| 14 |
+
{ id: 4, name: "Harvest Bowl", price: 10.50, category: "lunch", desc: "Quinoa, roasted squash, kale, cranberries, goat cheese, balsamic.", img: "http://static.photos/food/640x360/4", vegan: true },
|
| 15 |
+
{ id: 5, name: "Smash Burger", price: 12.00, category: "dinner", desc: "Double patty, American cheese, house sauce, pickles, brioche.", img: "http://static.photos/food/640x360/5" },
|
| 16 |
+
{ id: 6, name: "Grilled Meatloaf", price: 14.00, category: "dinner", desc: "Glazed with tangy ketchup, mashed potatoes, green beans.", img: "http://static.photos/food/640x360/6" },
|
| 17 |
+
{ id: 7, name: "Apple Cobbler", price: 6.50, category: "dessert", desc: "Warm spiced apples, buttery crumble, vanilla ice cream.", img: "http://static.photos/food/640x360/7" },
|
| 18 |
+
{ id: 8, name: "Vegan Brownie", price: 5.00, category: "dessert", desc: "Dark chocolate, walnuts, dusted with sugar.", img: "http://static.photos/food/640x360/8", vegan: true }
|
| 19 |
+
];
|
| 20 |
+
|
| 21 |
+
Store.menu = dummyMenu;
|
| 22 |
+
|
| 23 |
+
// Render menu
|
| 24 |
+
function renderMenu() {
|
| 25 |
+
const grid = document.getElementById('menuGrid');
|
| 26 |
+
const empty = document.getElementById('emptyState');
|
| 27 |
+
const filtered = Store.menu.filter(item => {
|
| 28 |
+
const matchesFilter = Store.filter === 'all' || item.category === Store.filter || (Store.filter === 'vegan' && item.vegan);
|
| 29 |
+
const matchesSearch = item.name.toLowerCase().includes(Store.search.toLowerCase()) || item.desc.toLowerCase().includes(Store.search.toLowerCase());
|
| 30 |
+
return matchesFilter && matchesSearch;
|
| 31 |
+
});
|
| 32 |
+
|
| 33 |
+
if (filtered.length === 0) {
|
| 34 |
+
grid.innerHTML = '';
|
| 35 |
+
empty.classList.remove('hidden');
|
| 36 |
+
return;
|
| 37 |
+
}
|
| 38 |
+
empty.classList.add('hidden');
|
| 39 |
+
grid.innerHTML = filtered.map(item => `
|
| 40 |
+
<div class="bg-white dark:bg-gray-800 rounded-2xl shadow-md card-hover overflow-hidden">
|
| 41 |
+
<img src="${item.img}" alt="${item.name}" class="w-full h-40 object-cover">
|
| 42 |
+
<div class="p-4">
|
| 43 |
+
<div class="flex justify-between items-start">
|
| 44 |
+
<h3 class="text-lg font-semibold">${item.name}</h3>
|
| 45 |
+
<span class="text-orange-500 font-bold">$${item.price.toFixed(2)}</span>
|
| 46 |
+
</div>
|
| 47 |
+
<p class="text-sm text-gray-500 dark:text-gray-400 mt-1">${item.desc}</p>
|
| 48 |
+
<button data-id="${item.id}" class="addBtn mt-4 w-full px-4 py-2 rounded-full bg-orange-500 hover:bg-orange-600 text-white text-sm font-semibold transition">Add to Cart</button>
|
| 49 |
+
</div>
|
| 50 |
+
</div>
|
| 51 |
+
`);
|
| 52 |
+
document.querySelectorAll('.addBtn').forEach(btn => btn.addEventListener('click', addToCart));
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
// Cart logic
|
| 56 |
+
function saveCart() {
|
| 57 |
+
localStorage.setItem('bbCart', JSON.stringify(Store.cart));
|
| 58 |
+
updateBadge();
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
function updateBadge() {
|
| 62 |
+
const badge = document.getElementById('cartBadge');
|
| 63 |
+
const total = Store.cart.reduce((a, b) => a + b.qty, 0);
|
| 64 |
+
badge.textContent = total;
|
| 65 |
+
badge.classList.toggle('hidden', total === 0);
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
function addToCart(e) {
|
| 69 |
+
const id = +e.target.dataset.id;
|
| 70 |
+
const item = Store.menu.find(m => m.id === id);
|
| 71 |
+
const existing = Store.cart.find(i => i.id === id);
|
| 72 |
+
if (existing) existing.qty += 1;
|
| 73 |
+
else Store.cart.push({ ...item, qty: 1 });
|
| 74 |
+
saveCart();
|
| 75 |
+
// Tiny toast
|
| 76 |
+
const toast = document.createElement('div');
|
| 77 |
+
toast.className = 'fixed bottom-6 left-1/2 -translate-x-1/2 px-4 py-2 rounded-full bg-gray-800 text-white text-sm shadow-lg';
|
| 78 |
+
toast.innerText = `${item.name} added!`;
|
| 79 |
+
document.body.appendChild(toast);
|
| 80 |
+
setTimeout(() => toast.remove(), 1500);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
// Filters
|
| 84 |
+
document.querySelectorAll('.filter-btn').forEach(btn => {
|
| 85 |
+
btn.addEventListener('click', e => {
|
| 86 |
+
document.querySelector('.filter-btn.active').classList.remove('active');
|
| 87 |
+
e.target.classList.add('active');
|
| 88 |
+
Store.filter = e.target.dataset.filter;
|
| 89 |
+
renderMenu();
|
| 90 |
+
});
|
| 91 |
+
});
|
| 92 |
+
|
| 93 |
+
// Search
|
| 94 |
+
document.getElementById('searchInput').addEventListener('input', e => {
|
| 95 |
+
Store.search = e.target.value;
|
| 96 |
+
renderMenu();
|
| 97 |
+
});
|
| 98 |
+
|
| 99 |
+
// Theme toggle
|
| 100 |
+
const themeBtn = document.getElementById('themeToggle');
|
| 101 |
+
const html = document.documentElement;
|
| 102 |
+
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
| 103 |
+
html.classList.add('dark');
|
| 104 |
+
themeBtn.innerHTML = '<i data-feather="sun" class="w-5 h-5"></i>';
|
| 105 |
+
} else {
|
| 106 |
+
html.classList.remove('dark');
|
| 107 |
+
themeBtn.innerHTML = '<i data-feather="moon" class="w-5 h-5"></i>';
|
| 108 |
+
}
|
| 109 |
+
themeBtn.addEventListener('click', () => {
|
| 110 |
+
const isDark = html.classList.toggle('dark');
|
| 111 |
+
localStorage.theme = isDark ? 'dark' : 'light';
|
| 112 |
+
themeBtn.innerHTML = isDark ? '<i data-feather="sun" class="w-5 h-5"></i>' : '<i data-feather="moon" class="w-5 h-5"></i>';
|
| 113 |
+
feather.replace();
|
| 114 |
+
});
|
| 115 |
+
|
| 116 |
+
// Init
|
| 117 |
+
renderMenu();
|
| 118 |
+
updateBadge();
|
style.css
CHANGED
|
@@ -1,28 +1,44 @@
|
|
| 1 |
-
|
| 2 |
-
padding: 2rem;
|
| 3 |
-
font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
|
| 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 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Tailwind already loaded via CDN – this file is for extra spice */
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
/* Custom scrollbar */
|
| 4 |
+
::-webkit-scrollbar {
|
| 5 |
+
width: 8px;
|
| 6 |
}
|
| 7 |
+
::-webkit-scrollbar-track {
|
| 8 |
+
background: #f1f1f1;
|
| 9 |
+
}
|
| 10 |
+
::-webkit-scrollbar-thumb {
|
| 11 |
+
background: #ff6a00;
|
| 12 |
+
border-radius: 4px;
|
| 13 |
+
}
|
| 14 |
+
.dark ::-webkit-scrollbar-track {
|
| 15 |
+
background: #1f2937;
|
| 16 |
+
}
|
| 17 |
+
.dark ::-webkit-scrollbar-thumb {
|
| 18 |
+
background: #ff8c00;
|
| 19 |
}
|
| 20 |
|
| 21 |
+
/* Filter pills */
|
| 22 |
+
.filter-btn {
|
| 23 |
+
@apply px-4 py-2 rounded-full text-sm font-medium border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 bg-white dark:bg-gray-800 hover:bg-orange-100 dark:hover:bg-orange-900/30 transition;
|
| 24 |
+
}
|
| 25 |
+
.filter-btn.active {
|
| 26 |
+
@apply bg-orange-500 text-white border-orange-500;
|
| 27 |
}
|
| 28 |
|
| 29 |
+
/* Card hover lift */
|
| 30 |
+
.card-hover {
|
| 31 |
+
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
| 32 |
+
}
|
| 33 |
+
.card-hover:hover {
|
| 34 |
+
transform: translateY(-4px);
|
| 35 |
+
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
|
| 36 |
}
|
| 37 |
+
.dark .card-hover:hover {
|
| 38 |
+
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/* Quantity buttons */
|
| 42 |
+
.qty-btn {
|
| 43 |
+
@apply w-8 h-8 rounded-full flex items-center justify-center bg-gray-200 dark:bg-gray-700 hover:bg-orange-200 dark:hover:bg-orange-800 transition;
|
| 44 |
+
}
|