anycoder-c237ceab / index.html
K3Tapan's picture
Upload folder using huggingface_hub
d7e368f verified
Raw History Blame Contribute Delete
32.4 kB
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="theme-color" content="#0D5C3F">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<title>Grocery Pro - Premium Shopping Planner</title>
<!-- React & ReactDOM -->
<script crossorigin src="https://unpkg.com/react@18.2.0/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18.2.0/umd/react-dom.production.min.js"></script>
<!-- Babel for JSX -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Lucide Icons -->
<script src="https://unpkg.com/lucide@latest"></script>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&family=Inter:wght@300;400;500;600"
rel="stylesheet">
<!-- Tailwind Configuration -->
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
display: ['Manrope', 'sans-serif'],
},
colors: {
gp: {
bg: '#F5F7FA', // Light Mode BG
surface: '#FFFFFF',
elevated: '#F9FAFB',
primary: '#0D5C3F', // Emerald
primaryLight: '#E8F5E9',
accent: '#D97757', // Terracotta
accentLight: '#FCEBE3',
text: '#111827',
textSecondary: '#6B7280',
textMuted: '#9CA3AF',
success: '#10B981',
danger: '#EF4444',
darkBg: '#0B1215',
darkSurface: '#1C1F26',
darkElevated: '#232730',
}
}
}
}
}
</script>
<style>
:root {
--safe-top: 0px;
--safe-bottom: 0px;
}
@supports (padding-top: env(safe-area-inset-top)) {
:root {
--safe-top: env(safe-area-inset-top);
--safe-bottom: env(safe-area-inset-bottom);
}
}
body {
font-family: 'Inter', sans-serif;
background-color: var(--bg-color);
color: var(--text-color);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
overflow: hidden;
/* Prevent body scroll, app handles scroll */
}
/* Scrollbar hiding */
.no-scrollbar::-webkit-scrollbar {
display: none;
}
.no-scrollbar {
-ms-overflow-style: none;
scrollbar-width: none;
}
/* Animations */
@keyframes slideUp {
from {
transform: translateY(100%);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes pulse-subtle {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.8;
}
}
.animate-slide-up {
animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.animate-fade-in {
animation: fadeIn 0.2s ease-out forwards;
}
/* Glassmorphism */
.glass {
background: rgba(255, 255, 255, 0.85);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border-top: 1px solid rgba(255, 255, 255, 0.3);
}
[data-theme="dark"] .glass {
background: rgba(28, 31, 38, 0.85);
border-top: 1px solid rgba(255, 255, 255, 0.05);
}
/* Checkbox custom */
.checkbox-wrapper {
position: relative;
cursor: pointer;
display: inline-block;
}
.checkbox-input {
position: absolute;
opacity: 0;
width: 0;
height: 0;
}
.checkbox-custom {
display: inline-block;
width: 24px;
height: 24px;
border-radius: 6px;
border: 2px solid #D1D5DB;
transition: all 0.2s;
}
.checkbox-input:checked+.checkbox-custom {
background-color: #0D5C3F;
border-color: #0D5C3F;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'%3E%3C/path%3E%3C/svg%3E");
background-size: 16px;
background-position: center;
background-repeat: no-repeat;
}
/* Strikethrough transition */
.checked-text {
transition: color 0.2s, text-decoration 0.2s;
}
/* Safe area padding helpers */
.pt-safe {
padding-top: var(--safe-top);
}
.pb-safe {
padding-bottom: var(--safe-bottom);
}
/* Utility for preventing text selection on UI elements */
.ui-select-none {
-webkit-user-select: none;
user-select: none;
}
</style>
</head>
<body id="app-root">
<script type="text/babel">
// ==========================================
// 1. DATA & SIMULATION CORE
// ==========================================
const SEED_DATA = {
products: [
{ id: 'p1', name: 'Bio Milch 1L', category: 'Milchprodukte', price: 1.49, brand: 'Eigenmarke', unit: '1L', tags: ['bio'] },
{ id: 'p2', name: 'Brot Toastbrot', category: 'Brot & Backwaren', price: 1.99, brand: 'Standard', unit: '500g', tags: [] },
{ id: 'p3', name: 'Bananen Bio', category: 'Obst & Gemüse', price: 2.49, brand: 'Bio', unit: 'kg', tags: ['bio', 'fruit'] },
{ id: 'p4', name: 'Hähnchenbrust', category: 'Fleisch & Fisch', price: 5.99, brand: 'Premium', unit: '500g', tags: ['meat'] },
{ id: 'p5', name: 'Spaghetti', category: 'Brot & Backwaren', price: 0.89, brand: 'Standard', unit: '500g', tags: ['pasta'] },
{ id: 'p6', name: 'Tomaten Sauce', category: 'Internationale Spezialitäten', price: 1.29, brand: 'Standard', unit: '400g', tags: ['sauce'] },
{ id: 'p7', name: 'Parmesan', category: 'Milchprodukte', price: 3.99, brand: 'Premium', unit: '200g', tags: ['cheese'] },
{ id: 'p8', name: 'Eier M', category: 'Milchprodukte', price: 2.19, brand: 'Standard', unit: '10 St', tags: [] },
{ id: 'p9', name: 'Apfel Gala', category: 'Obst & Gemüse', price: 1.99, brand: 'Standard', unit: 'kg', tags: ['fruit'] },
{ id: 'p10', name: 'Kaffee Espresso', category: 'Kaffee, Tee & Frühstück', price: 4.49, brand: 'Premium', unit: '250g', tags: ['coffee'] },
],
stores: [
{ id: 's1', name: 'Markt Winnenden', type: 'Discounter', distance: 1.2, priceIndex: 0.85, coverage: 0.65, open: true },
{ id: 's2', name: 'FreshCenter', type: 'Supermarket', distance: 3.5, priceIndex: 1.0, coverage: 0.95, open: true },
{ id: 's3', name: 'BioMarkt', type: 'Specialist', distance: 5.8, priceIndex: 1.25, coverage: 0.40, open: true },
],
recipes: [
{ id: 'r1', title: 'Spaghetti Bolognese', image: 'https://images.unsplash.com/photo-1621996346565-e3e6d4d0012e?auto=format&fit=crop&q=80&w=400', ingredients: ['p5', 'p4', 'p6'], servings: 2, time: '45 min' },
{ id: 'r2', title: 'Frühstück Power', image: 'https://images.unsplash.com/photo-1512621776951-a5c3717d980e?auto=format&fit=crop&q=80&w=400', ingredients: ['p1', 'p2', 'p9', 'p10'], servings: 1, time: '10 min' }
]
};
// ==========================================
// 2. STATE MANAGEMENT (Context & Reducer)
// ==========================================
const AppContext = React.createContext();
const initialState = {
activeTab: 'dashboard', // dashboard, listen, katalog, rezepte, settings
navStack: [], // Stack for push navigation
lists: [],
settings: {
householdSize: 2,
dietStyle: 'omnivor',
budget: 150,
theme: 'light'
},
currentListId: null,
toast: null,
};
function appReducer(state, action) {
switch (action.type) {
case 'SET_TAB':
return { ...state, activeTab: action.payload, navStack: [] };
case 'PUSH_SCREEN':
return { ...state, navStack: [...state.navStack, action.payload] };
case 'POP_SCREEN':
return { ...state, navStack: state.navStack.slice(0, -1) };
case 'SET_LIST':
return { ...state, currentListId: action.payload };
case 'ADD_LIST':
return { ...state, lists: [...state.lists, action.payload] };
case 'UPDATE_LIST':
return {
...state,
lists: state.lists.map(l => l.id === action.payload.id ? action.payload : l)
};
case 'DELETE_LIST':
return { ...state, lists: state.lists.filter(l => l.id !== action.payload) };
case 'TOGGLE_THEME':
const newTheme = state.settings.theme === 'light' ? 'dark' : 'light';
return { ...state, settings: { ...state.settings, theme: newTheme } };
case 'SHOW_TOAST':
return { ...state, toast: { message: action.payload, visible: true } };
case 'HIDE_TOAST':
return { ...state, toast: { ...state.toast, visible: false } };
default:
return state;
}
}
// ==========================================
// 3. UI COMPONENTS (Atomic)
// ==========================================
const Icon = ({ name, size = 20, className = "" }) => {
const icons = {
home: <path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><path d="M9 22V12h6v10"/>,
list: <path d="M8 6h13"/><path d="M8 12h13"/><path d="M8 18h13"/><path d="M3 6h.01"/><path d="M3 12h.01"/><path d="M3 18h.01"/>,
grid: <rect width="7" height="7" x="3" y="3" rx="1"/><rect width="7" height="7" x="14" y="3" rx="1"/><rect width="7" height="7" x="14" y="14" rx="1"/><rect width="7" height="7" x="3" y="14" rx="1"/>,
book: <path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/>,
settings: <path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.1a2 2 0 0 1-1-1.72v-.51a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>,
plus: <path d="M5 12h14"/><path d="M12 5v14"/>,
check: <path d="M20 6L9 17l-5-5"/>,
chevronRight: <path d="M9 18l6-6-6-6"/>,
search: <circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>,
cart: <circle cx="8" cy="21" r="1"/><circle cx="19" cy="21" r="1"/><path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"/>
};
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width={size}
height={size}
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className={className}
>
{icons[name] || <circle cx="12" cy="12" r="10"/>}
</svg>
);
};
const Card = ({ children, className = "", onClick }) => (
<div
onClick={onClick}
className={`bg-white dark:bg-gp-darkSurface rounded-xl shadow-sm border border-gray-100 dark:border-gray-800 p-4 ${className} transition-all active:scale-[0.98] cursor-pointer`}
>
{children}
</div>
);
const Button = ({ children, variant = "primary", className = "", onClick }) => {
const styles = {
primary: "bg-gp-primary text-white hover:bg-opacity-90 shadow-md shadow-gp-primary/30",
secondary: "bg-white dark:bg-gp-darkElevated text-gp-text border border-gray-200 dark:border-gray-700",
ghost: "bg-transparent text-gp-textSecondary hover:bg-gray-100 dark:hover:bg-gray-800"
};
return (
<button
onClick={onClick}
className={`px-4 py-3 rounded-lg font-medium text-sm transition-all flex items-center justify-center gap-2 ${styles[variant]} ${className}`}
>
{children}
</button>
);
};
const Chip = ({ label, active, onClick }) => (
<span
onClick={onClick}
className={`px-3 py-1.5 rounded-full text-xs font-medium transition-colors cursor-pointer whitespace-nowrap
${active ? 'bg-gp-primary text-white' : 'bg-gray-100 dark:bg-gray-800 text-gp-textSecondary'}`}
>
{label}
</span>
);
const Toast = ({ message, visible, onClose }) => {
if (!visible) return null;
return (
<div className="fixed top-20 left-1/2 -translate-x-1/2 z-50 animate-fade-in">
<div className="bg-gp-text text-white px-6 py-3 rounded-full shadow-lg flex items-center gap-3">
<Icon name="check" size={16} className="text-gp-success" />
<span className="font-medium text-sm">{message}</span>
</div>
</div>
);
};
// ==========================================
// 4. SCREENS
// ==========================================
// --- Dashboard Screen ---
const DashboardScreen = () => {
const { state, dispatch } = React.useContext(AppContext);
// Simulation Logic
const activeList = state.lists.find(l => l.id === state.currentListId);
const totalItems = activeList ? activeList.items.length : 0;
const checkedItems = activeList ? activeList.items.filter(i => i.checked).length : 0;
const progress = totalItems > 0 ? checkedItems / totalItems : 0;
const estimatedCost = activeList ? activeList.items.reduce((acc, i) => acc + (i.price || 0), 0) : 0;
// Recommendation Logic
const recommendedStore = SEED_DATA.stores[1]; // FreshCenter as default recommendation
return (
<div className="flex flex-col gap-6 pb-24 pt-safe">
{/* Header */}
<div className="px-5">
<h1 className="font-display text-3xl font-bold text-gp-text mb-1">Dashboard</h1>
<p className="text-gp-textSecondary text-sm">Guten Morgen, hier ist dein Plan für heute.</p>
</div>
{/* Strategy Card */}
<Card className="bg-gradient-to-br from-gp-primary to-emerald-800 text-white border-none shadow-xl">
<div className="flex justify-between items-start mb-4">
<div>
<span className="text-emerald-200 text-xs font-bold uppercase tracking-wider mb-1 block">Strategie</span>
<h3 className="font-display text-xl font-bold">Wochenplanung</h3>
</div>
<div className="bg-white/20 p-2 rounded-lg">
<Icon name="book" className="text-white" />
</div>
</div>
<div className="flex items-end justify-between">
<div>
<div className="text-2xl font-bold font-display">{estimatedCost.toFixed(2)} €</div>
<div className="text-emerald-100 text-xs opacity-80">geschätzte Kosten</div>
</div>
<div className="text-right">
<div className="text-lg font-bold">{recommendedStore.name}</div>
<div className="text-emerald-100 text-xs opacity-80">bestes Angebot</div>
</div>
</div>
</Card>
{/* Active List Status */}
<div className="px-5">
<div className="flex justify-between items-center mb-3">
<h2 className="font-display text-lg font-bold text-gp-text">Aktive Liste</h2>
<button
onClick={() => dispatch({ type: 'SET_TAB', payload: 'listen' })}
className="text-gp-primary text-sm font-medium hover:underline"
>
Alle ansehen
</button>
</div>
{activeList ? (
<Card onClick={() => dispatch({ type: 'SET_LIST', payload: activeList.id })}>
<div className="flex justify-between items-center mb-2">
<h3 className="font-bold text-gp-text">{activeList.name}</h3>
<span className="text-xs text-gp-textSecondary bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded">
{activeList.items.length} Items
</span>
</div>
<div className="flex items-center gap-4 mt-3">
<div className="h-10 w-10 rounded-full border-3 border-gray-100 dark:border-gray-700 flex items-center justify-center relative">
<svg className="absolute w-full h-full transform -rotate-90">
<circle cx="20" cy="20" r="16" stroke="currentColor" strokeWidth="4" fill="transparent" className="text-gray-100 dark:text-gray-700" />
<circle cx="20" cy="20" r="16" stroke="currentColor" strokeWidth="4" fill="transparent" strokeDasharray={100} strokeDashoffset={100 - (progress * 100)} className="text-gp-success transition-all duration-500" />
</svg>
<Icon name="check" size={14} className="text-gp-success" />
</div>
<div className="flex-1">
<div className="text-sm font-medium text-gp-text">
{Math.round(progress * 100)}% erledigt
</div>
<div className="text-xs text-gp-textSecondary">
{totalItems - checkedItems} Artikel übrig
</div>
</div>
</div>
</Card>
) : (
<div className="bg-gray-50 dark:bg-gray-800/50 rounded-xl p-6 text-center border-2 border-dashed border-gray-200 dark:border-gray-700">
<p className="text-gp-textSecondary text-sm mb-3">Keine aktive Liste</p>
<Button variant="primary" onClick={() => dispatch({ type: 'SET_TAB', payload: 'listen' })}>
Neue Liste erstellen
</Button>
</div>
)}
</div>
{/* Recommendations */}
<div className="px-5">
<h2 className="font-display text-lg font-bold text-gp-text mb-3">Smart Insights</h2>
<div className="grid gap-3">
<Card className="flex items-center gap-3 py-3">
<div className="bg-gp-accentLight p-2 rounded-lg text-gp-accent">
<Icon name="home" size={18} />
</div>
<div>
<div className="font-medium text-sm text-gp-text">Vorrat prüfen</div>
<div className="text-xs text-gp-textSecondary">Du hast wahrscheinlich noch Eier im Kühlschrank.</div>
</div>
</Card>
<Card className="flex items-center gap-3 py-3">
<div className="bg-blue-100 dark:bg-blue-900/30 p-2 rounded-lg text-blue-600">
<Icon name="book" size={18} />
</div>
<div>
<div className="font-medium text-sm text-gp-text">Angebot: Spaghetti</div>
<div className="text-xs text-gp-textSecondary">-20% bei Markt Winnenden.</div>
</div>
</Card>
</div>
</div>
</div>
);
};
// --- Listen Screen (Lists Overview) ---
const ListenScreen = () => {
const { state, dispatch } = React.useContext(AppContext);
return (
<div className="flex flex-col pb-24 pt-safe min-h-full">
<div className="px-5 mb-6 flex justify-between items-center">
<h1 className="font-display text-3xl font-bold text-gp-text">Einkaufslisten</h1>
<button
onClick={() => dispatch({ type: 'ADD_LIST', payload: {
id: Date.now().toString(),
name: `Liste ${state.lists.length + 1}`,
items: [],
createdAt: new Date()
}})}
className="bg-gp-primary text-white p-2 rounded-lg shadow-lg active:scale-0.95 transition-transform"
>
<Icon name="plus" />
</button>
</div>
<div className="px-5 flex flex-col gap-3">
{state.lists.length === 0 && (
<div className="text-center py-10 text-gp-textSecondary">
<p>Keine Listen vorhanden.</p>
<p className="text-xs mt-2">Starte mit der "+" Button oben.</p>
</div>
)}
{state.lists.map(list => {
const checked = list.items.filter(i => i.checked).length;
const total = list.items.length;
return (
<Card
key={list.id}
onClick={() => dispatch({ type: 'SET_LIST', payload: list.id })}
className="flex justify-between items-center py-4"
>
<div>
<h3 className="font-bold text-gp-text text-lg">{list.name}</h3>
<p className="text-xs text-gp-textSecondary mt-1">
{total === 0 ? 'Leer' : `${checked}/${total} erledigt`}
</p>
</div>
<div className="h-10 w-10 rounded-full bg-gray-100 dark:bg-gray-800 flex items-center justify-center text-gp-textSecondary">
<Icon name="chevronRight" size={18} />
</div>
</Card>
);
})}
</div>
</div>
);
};
// --- Active List Screen (Detail) ---
const ActiveListScreen = () => {
const { state, dispatch } = React.useContext(AppContext);
const list = state.lists.find(l => l.id === state.currentListId);
const [filter, setFilter] = React.useState('all'); // all, unchecked
if (!list) return <div>Liste nicht gefunden</div>;
const toggleItem = (itemId) => {
const updatedItems = list.items.map(i =>
i.id === itemId ? { ...i, checked: !i.checked } : i
);
dispatch({ type: 'UPDATE_LIST', payload: { ...list, items: updatedItems } });
};
const addItem = (e) => {
e.preventDefault();
const formData = new FormData(e.target);
const name = formData.get('name');
if (!name) return;
// Simple simulation: find product or generic
const product = SEED_DATA.products.find(p => p.name.toLowerCase() === name.toLowerCase());
const newItem = {
id: Date.now().toString(),
name: name,
checked: false,
price: product ? product.price : 0,
category: product ? product.category : 'Allgemein'
};
dispatch({
type: 'UPDATE_LIST',
payload: { ...list, items: [...list.items, newItem] }
});
dispatch({ type: 'SHOW_TOAST', payload: `${name} hinzugefügt` });
};
const filteredItems = filter === 'unchecked' ? list.items.filter(i => !i.checked) : list.items;
return (
<div className="flex flex-col pb-24 pt-safe min-h-full bg-gp-bg dark:bg-gp-darkBg">
{/* Sticky Header */}
<div className="sticky top-0 z-10 bg-white/90 dark:bg-gp-darkSurface/90 backdrop-blur-md border-b border-gray-200 dark:border-gray-800 px-5 py-4 pt-safe-top">
<div className="flex justify-between items-center mb-4">
<div>
<h1 className="font-display text-2xl font-bold text-gp-text">{list.name}</h1>
<p className="text-xs text-gp-textSecondary">{list.items.length} Artikel</p>
</div>
<button
onClick={() => dispatch({ type: 'POP_SCREEN' })}
className="text-gp-textSecondary hover:text-gp-text"
>
<Icon name="home" />
</button>
</div>
<div className="flex gap-2">
<Chip label="Alle" active={filter === 'all'} onClick={() => setFilter('all')} />
<Chip label="Offen" active={filter === 'unchecked'} onClick={() => setFilter('unchecked')} />
</div>
</div>
{/* List Items */}
<div className="px-5 py-4 flex-1 overflow-y-auto no-scrollbar">
{filteredItems.length === 0 ? (
<div className="text-center py-10 opacity-50">
<Icon name="list" size={48} className="mx-auto mb-2 text-gp-textMuted" />
<p className="text-sm">Keine Artikel in dieser Ansicht.</p>
</div>
) : (
filteredItems.map(item => (
<div
key={item.id}
className={`flex items-center justify-between py-3 border-b border-gray-100 dark:border-gray-800 last:border-0 transition-all ${item.checked ? 'opacity-60' : 'opacity-100'}`}
>
<div className="flex items-center gap-3 flex-1">
<label className="checkbox-wrapper">
<input
type="checkbox"
className="checkbox-input"
checked={item.checked}
onChange={() => toggleItem(item.id)}
/>
<span className="checkbox-custom"></span>
</label>
<div className="flex-1">
<div className={`font-medium text-gp-text checked-text ${item.checked ? 'text-gp-textMuted' : ''}`}>
{item.name}
</div>
<div className="text-xs text-gp-textSecondary">
{item.category} • {item.price > 0 ? `${item.price.toFixed(2)}€` : 'Preis unbekannt'}
</div>
</div>
</div>
</div>
))
)}
</div>
{/* Add Item Input */}
<div className="px-5 pb-4 sticky bottom-0 bg-white/80 dark:bg-gp-darkSurface/80 backdrop-blur border-t border-gray-200 dark:border-gray-800 pb-safe">
<form onSubmit={addItem} className="flex gap-2">
<input
name="name"
type="text"
placeholder="Produkt hinzufügen..."
className="flex-1 bg-gray-100 dark:bg-gray-800 rounded-lg px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-gp-primary/50 text-gp-text"
/>
<button type="submit" className="bg-gp-primary text-white rounded-lg px-4 py-3">
<Icon name="plus" />
</button>
</form>
</div>
</div>
);
};
// --- Catalog Screen ---
const CatalogScreen = () => {
const categories = [
"Obst & Gemüse", "Milchprodukte", "Brot & Backwaren",
"Fleisch & Fisch", "Getränke", "Süßwaren", "Reinigung"
];
return (
<div className="flex flex-col pb-24 pt-safe min-h-full">
<div className="px-5 mb-6">
<h1 className="font-display text-3xl font-bold text-gp-text">Katalog</h1>
<div className="relative mt-4">
<Icon name="search" className="absolute left-3 top-3 text-gp-textMuted" size={18} />
<input
type="text"
placeholder="Suche im Sortiment..."
className="w-full bg-white dark:bg-gp-darkSurface border border-gray-200 dark:border-gray-700 rounded-xl py-3 pl-10 pr-4 text-sm focus:outline-none focus:border-gp-primary text-gp-text"
/>
</div>
</div>
<div className="px-5 grid grid-cols-2 gap-3">
{categories.map((cat, idx) => (
<Card key={idx} className="flex flex-col justify-between h-32 bg-gray-50 dark:bg-gray-800">
<span className="font-bold text-gp-text text-sm">{cat}</span>
<div className="self-end text-gp-textMuted">
<Icon name="grid" size={24} />
</div>
</Card>
))}
</div>
<div className="px-5 mt-6">
<h2 className="font-display text-lg font-bold text-gp-text mb-3">Beliebt</h2>
<div className="flex flex-col gap-3">
{SEED_DATA.products.slice(0, 3).map(p => (
<Card key={p.id} className="flex justify-between items-center py-3">
<div>
<div className="font-medium text-gp-text">{p.name}</div>
<div className="text-xs text-gp-textSecondary">{p.brand}</div>
</div>
<div className="font-bold text-gp-primary">{p.price.toFixed(2)}€</div>
</Card>
))}
</div>
</div>
</div>
);
};
// --- Recipes Screen ---
const RecipesScreen = () => {
const { dispatch } = React.useContext(AppContext);
const handleAddToList = (recipe) => {
// Create a new list with recipe ingredients
const newListId = Date.now().toString();
const newItems = recipe.ingredients.map(pId => {
const product = SEED_DATA.products.find(p => p.id === pId);
return {
id: pId,
name: product.name,
checked: false,
price: product.price,
category: product.category
};
});
dispatch({
type: 'ADD_LIST',
payload: {
id: newListId,
name: recipe.title,
items: newItems,
createdAt: new Date()
}
});
dispatch({ type: 'SET_LIST', payload: newListId });
dispatch({ type: 'SHOW_TOAST', payload: `Rezept "${recipe.title}" hinzugefügt` });
dispatch({ type: 'SET_TAB', payload: 'listen' });
};
return (
<div className="flex flex-col pb-24 pt-safe min-h-full">
<div className="px-5 mb-6">
<h1 className="font-display text-3xl font-bold text-gp-text">Rezepte</h1>
<p className="text-gp-textSecondary text-sm">Planen und kochen.</p>
</div>
<div className="px-5 flex flex-col gap-6">
{SEED_DATA.recipes.map(recipe => (
<Card key={recipe.id} className="overflow-hidden p-0 group">
<div className="h-48 w-full relative">
<img src={recipe.image} alt={recipe.title} className="w-full h-full object-cover" />
<div className="absolute bottom-0 left-0 w-full h-1/2 bg-gradient-to-t from-black/80 to-transparent"></div>
<div className="absolute bottom-3 left-3 text-white">
<h3 className="font-bold text-lg">{recipe.title}</h3>
<div className="flex items-center gap-2 text-xs opacity-90">
<span>{recipe.time}</span>
<span>•</span>
<span>{recipe.servings} Personen</span>
</div>
</div>
</div>
<div className="p-4">
<div className="flex justify-between items-center">
<div className="text-xs text-gp-textSecondary">
{recipe.ingredients.length} Zutaten
</div>
<button
onClick={() => handleAddToList(recipe)}
className="bg-gp-primary text-white px-3 py-1.5 rounded-lg text-xs font-bold flex items-center gap-1 hover:bg-opacity-90 transition-opacity"
>
<Icon name="plus" size={14} />
In Liste
</button>
</div>
</div>
</Card>
))}
</div>
</div>
);
};
// --- Settings Screen ---