- {/* Header */}
-
-
- 🍳 Cookable
-
-
- Enter your available ingredients and get AI-powered recipe suggestions
-
-
-
- {/* Main Content */}
-
- {/* Step 1: Ingredient Input */}
-
-
- 1️⃣ Enter Your Ingredients
-
-
+
+
+
- {/* Step 2: Filter Options */}
-
-
- 2️⃣ Optional Filters
-
-
-
-
- {/* Step 3: Get Recipe Button */}
-
-
- {loading ? '🍳 Cooking up a recipe...' : '🍽️ Get Recipe Recommendation'}
-
-
+
+
- {/* Error Display */}
- {error && (
-
- {error}
-
- )}
+
+ {loading ? 'Cooking up a recipe...' : 'Get my recipe →'}
+
- {/* Step 4: Recipe Display */}
- {recipe && (
-
-
- 3️⃣ Your Recipe
-
-
-
- )}
+ {error && (
+
+ {error}
+
+ )}
- {/* Reset Button */}
- {recipe && (
-
-
- 🔄 Start Over
-
-
- )}
-
-
+ {recipe && (
+ <>
+
+
+ Start over
+
+ >
+ )}
+
);
}
diff --git a/frontend/src/components/FilterOptions.tsx b/frontend/src/components/FilterOptions.tsx
index e22ed28..09ad951 100644
--- a/frontend/src/components/FilterOptions.tsx
+++ b/frontend/src/components/FilterOptions.tsx
@@ -1,142 +1,77 @@
-import { FilterOptions as FilterOptionsType } from '@/types/recipe';
+import { Card, StepHeading } from '@/components/ui/Card';
+import { ToggleChip } from '@/components/ui/Chip';
+import { fieldClass } from '@/components/ui/field';
+import type { FilterOptions as Filters } from '@/types/recipe';
-interface FilterOptionsProps {
- filters: FilterOptionsType & { allow_external_ingredients: boolean };
- onFiltersChange: (filters: FilterOptionsType & { allow_external_ingredients: boolean }) => void;
-}
-
-const dietaryOptions = [
- { value: 'vegetarian', label: '🥬 Vegetarian' },
- { value: 'vegan', label: '🌱 Vegan' },
- { value: 'gluten-free', label: '🌾 Gluten-Free' },
- { value: 'dairy-free', label: '🥛 Dairy-Free' },
- { value: 'low-carb', label: '🍞 Low-Carb' },
- { value: 'quick', label: '⚡ Quick (< 30 min)' },
+const DIETARY_OPTIONS = [
+ { value: 'vegetarian', label: 'Vegetarian' },
+ { value: 'vegan', label: 'Vegan' },
+ { value: 'gluten-free', label: 'Gluten-free' },
+ { value: 'dairy-free', label: 'Dairy-free' },
+ { value: 'low-carb', label: 'Low-carb' },
];
-const cookingTimeOptions = [
- { value: 15, label: '15 minutes' },
- { value: 30, label: '30 minutes' },
- { value: 45, label: '45 minutes' },
- { value: 60, label: '1 hour' },
- { value: 90, label: '1.5 hours' },
-];
+const COOKING_TIMES = [15, 30, 45, 60, 90];
+
+interface FilterOptionsProps {
+ filters: Filters;
+ onFiltersChange: (filters: Filters) => void;
+}
export default function FilterOptions({ filters, onFiltersChange }: FilterOptionsProps) {
- const handleDietaryPreferenceChange = (preference: string) => {
- const newPreferences = filters.dietary_preferences.includes(preference)
- ? filters.dietary_preferences.filter(p => p !== preference)
- : [...filters.dietary_preferences, preference];
-
- onFiltersChange({
- ...filters,
- dietary_preferences: newPreferences
- });
- };
+ const update = (changes: Partial
) => onFiltersChange({ ...filters, ...changes });
- const handleCookingTimeChange = (time: number | null) => {
- onFiltersChange({
- ...filters,
- max_cooking_time: time
+ const togglePreference = (preference: string) => {
+ const current = filters.dietary_preferences;
+ update({
+ dietary_preferences: current.includes(preference)
+ ? current.filter((p) => p !== preference)
+ : [...current, preference],
});
};
return (
-
- {/* External Ingredients Toggle */}
-
-
- Suggest recipes with extra ingredients?
-
-
onFiltersChange({ ...filters, allow_external_ingredients: e.target.checked })}
- />
-
-
-
-
-
- If enabled, we'll suggest recipes that might require a few extra items, and we'll provide a shopping list for them.
-
-
-
- {/* Dietary Preferences */}
-
-
Dietary Preferences:
-
- {dietaryOptions.map((option) => (
-
- handleDietaryPreferenceChange(option.value)}
- className="w-4 h-4 text-orange-600 bg-gray-100 border-gray-300 rounded focus:ring-orange-500 focus:ring-2"
- />
- {option.label}
-
- ))}
-
-
+
+
- {/* Cooking Time */}
-
-
Maximum Cooking Time:
-
-
handleCookingTimeChange(null)}
- className={`px-4 py-2 rounded-lg text-sm font-medium transition-colors duration-200 ${
- filters.max_cooking_time === null
- ? 'bg-orange-500 text-white'
- : 'bg-gray-100 text-gray-700 hover:bg-gray-200'
- }`}
+
+ {DIETARY_OPTIONS.map(({ value, label }) => (
+ togglePreference(value)}
>
- No Limit
-
- {cookingTimeOptions.map((option) => (
- handleCookingTimeChange(option.value)}
- className={`px-4 py-2 rounded-lg text-sm font-medium transition-colors duration-200 ${
- filters.max_cooking_time === option.value
- ? 'bg-orange-500 text-white'
- : 'bg-gray-100 text-gray-700 hover:bg-gray-200'
- }`}
- >
- {option.label}
-
- ))}
-
+ {label}
+
+ ))}
- {/* Selected Filters Summary */}
- {(filters.dietary_preferences.length > 0 || filters.max_cooking_time !== null) && (
-
-
Active Filters:
-
- {filters.dietary_preferences.map((preference) => (
-
- {dietaryOptions.find(opt => opt.value === preference)?.label || preference}
-
+
+
+ Max time
+ update({ max_cooking_time: e.target.value ? Number(e.target.value) : null })}
+ className={`h-10 px-3 ${fieldClass}`}
+ >
+ Any
+ {COOKING_TIMES.map((minutes) => (
+ {minutes} min
))}
- {filters.max_cooking_time !== null && (
-
- ⏱️ Max {filters.max_cooking_time} min
-
- )}
-
-
- )}
-
+
+
+
+
+ update({ allow_external_ingredients: e.target.checked })}
+ className="size-5 accent-primary"
+ />
+ Allow a few extras
+ (adds a shopping list)
+
+
+
);
-}
\ No newline at end of file
+}
diff --git a/frontend/src/components/IngredientInput.tsx b/frontend/src/components/IngredientInput.tsx
index a63e941..1c5c858 100644
--- a/frontend/src/components/IngredientInput.tsx
+++ b/frontend/src/components/IngredientInput.tsx
@@ -1,4 +1,10 @@
-import { useState } from 'react';
+import { useState, type FormEvent } from 'react';
+import { Button } from '@/components/ui/Button';
+import { Card, StepHeading } from '@/components/ui/Card';
+import { RemovableChip } from '@/components/ui/Chip';
+import { fieldClass } from '@/components/ui/field';
+
+const QUICK_ADD = ['onion', 'garlic', 'tomato', 'chicken', 'rice', 'pasta', 'egg', 'cheese'];
interface IngredientInputProps {
ingredients: string[];
@@ -8,94 +14,66 @@ interface IngredientInputProps {
export default function IngredientInput({ ingredients, onIngredientsChange }: IngredientInputProps) {
const [inputValue, setInputValue] = useState('');
- const handleAddIngredient = () => {
- const trimmedValue = inputValue.trim();
- if (trimmedValue && !ingredients.includes(trimmedValue.toLowerCase())) {
- onIngredientsChange([...ingredients, trimmedValue.toLowerCase()]);
- setInputValue('');
+ const add = (name: string) => {
+ const ingredient = name.trim().toLowerCase();
+ if (ingredient && !ingredients.includes(ingredient)) {
+ onIngredientsChange([...ingredients, ingredient]);
}
};
- const handleRemoveIngredient = (ingredient: string) => {
- const newIngredients = ingredients.filter((i) => i !== ingredient);
- onIngredientsChange(newIngredients);
+ const remove = (ingredient: string) => {
+ onIngredientsChange(ingredients.filter((i) => i !== ingredient));
};
- const handleKeyDown = (e: React.KeyboardEvent) => {
- if (e.key === 'Enter') {
- handleAddIngredient();
- }
+ const handleSubmit = (e: FormEvent) => {
+ e.preventDefault();
+ add(inputValue);
+ setInputValue('');
};
return (
-
- {/* Input Field */}
-
+
+
+
+
+
+
- {/* Ingredients List */}
{ingredients.length > 0 && (
-
-
Your Ingredients:
-
- {ingredients.map((ingredient) => (
-
- {ingredient}
- handleRemoveIngredient(ingredient)}
- aria-label={`Remove ${ingredient}`}
- className="text-orange-600 hover:text-orange-800 text-lg font-bold"
- >
- ×
-
-
- ))}
-
+
+ {ingredients.map((ingredient) => (
+ remove(ingredient)} />
+ ))}
)}
- {/* Quick Add Suggestions */}
-
-
Quick Add Common Ingredients:
+
+
Quick add
- {['onion', 'garlic', 'tomato', 'chicken', 'rice', 'pasta', 'egg', 'cheese'].map((suggestion) => (
+ {QUICK_ADD.map((name) => (
{
- if (!ingredients.includes(suggestion)) {
- onIngredientsChange([...ingredients, suggestion]);
- }
- }}
- disabled={ingredients.includes(suggestion)}
- className="px-3 py-1 bg-gray-100 hover:bg-gray-200 disabled:bg-gray-50 disabled:text-gray-400 text-gray-700 rounded-full text-sm transition-colors duration-200"
+ key={name}
+ onClick={() => add(name)}
+ disabled={ingredients.includes(name)}
+ className="h-9 rounded-[10px] border border-field-line bg-field px-3.5 text-sm transition-opacity disabled:opacity-40"
>
- {suggestion}
+ + {name}
))}
-
+
);
-}
\ No newline at end of file
+}
diff --git a/frontend/src/components/RecipeDisplay.tsx b/frontend/src/components/RecipeDisplay.tsx
index a6c51ab..38f40ba 100644
--- a/frontend/src/components/RecipeDisplay.tsx
+++ b/frontend/src/components/RecipeDisplay.tsx
@@ -1,131 +1,53 @@
-import { Recipe } from '@/types/recipe';
+import { Card } from '@/components/ui/Card';
+import { Tag } from '@/components/ui/Chip';
+import type { Recipe } from '@/types/recipe';
interface RecipeDisplayProps {
recipe: Recipe;
}
export default function RecipeDisplay({ recipe }: RecipeDisplayProps) {
- const getDifficultyColor = (difficulty: string) => {
- switch (difficulty.toLowerCase()) {
- case 'easy':
- return 'bg-green-100 text-green-800';
- case 'medium':
- return 'bg-yellow-100 text-yellow-800';
- case 'hard':
- return 'bg-red-100 text-red-800';
- default:
- return 'bg-gray-100 text-gray-800';
- }
- };
+ const shoppingList = recipe.shopping_list ?? [];
return (
-
- {/* Recipe Header */}
-
-
{recipe.title}
-
-
- ⏱️ {recipe.cooking_time} minutes
-
-
- {recipe.difficulty}
-
-
- 👥 {recipe.servings} servings
-
-
-
-
- {/* Recipe Tags */}
- {recipe.tags.length > 0 && (
-
- {recipe.tags.map((tag, index) => (
-
- {tag}
-
+
+
+
{recipe.title}
+
+ {recipe.cooking_time} min
+ {recipe.difficulty}
+ Serves {recipe.servings}
+ {recipe.tags.map((tag) => (
+ {tag}
))}
- )}
-
- {/* Ingredients */}
-
-
- 🥘 Ingredients
-
-
- {recipe.ingredients.map((ingredient, index) => (
-
-
- {ingredient}
-
- ))}
-
-
-
- {/* Instructions */}
-
-
- 📝 Instructions
-
-
- {recipe.instructions.map((instruction, index) => (
-
-
- {index + 1}
-
- {instruction}
-
- ))}
-
- {/* Shopping List */}
- {recipe.shopping_list && recipe.shopping_list.length > 0 && (
-
-
- 🛒 Shopping List
-
-
- {recipe.shopping_list.map((item, index) => (
-
-
- {item}
-
+
+
+
Ingredients
+
+ {recipe.ingredients.map((ingredient, i) => (
+ {ingredient}
))}
- )}
-
- {/* Recipe Summary */}
-
-
Recipe Summary
-
-
-
{recipe.cooking_time}
-
Minutes
-
-
-
{recipe.servings}
-
Servings
-
-
-
{recipe.ingredients.length}
-
Ingredients
-
+
+
Steps
+
+ {recipe.instructions.map((step, i) => (
+ {step}
+ ))}
+
-
+
+ {shoppingList.length > 0 && (
+
+ Shopping list
+ {shoppingList.join(', ')}
+
+ )}
+
);
-}
\ No newline at end of file
+}
diff --git a/frontend/src/components/ThemeToggle.tsx b/frontend/src/components/ThemeToggle.tsx
new file mode 100644
index 0000000..a1230b8
--- /dev/null
+++ b/frontend/src/components/ThemeToggle.tsx
@@ -0,0 +1,29 @@
+import { useTheme } from '@/hooks/useTheme';
+
+export default function ThemeToggle() {
+ const { theme, toggle } = useTheme();
+ const next = theme === 'dark' ? 'light' : 'dark';
+
+ return (
+
+
+ {theme === 'dark' ? (
+ // Sun: shown in dark mode, switches to light
+ <>
+
+
+ >
+ ) : (
+ // Moon: shown in light mode, switches to dark
+
+ )}
+
+
+ );
+}
diff --git a/frontend/src/components/ui/Button.tsx b/frontend/src/components/ui/Button.tsx
new file mode 100644
index 0000000..67e73dc
--- /dev/null
+++ b/frontend/src/components/ui/Button.tsx
@@ -0,0 +1,23 @@
+import type { ButtonHTMLAttributes } from 'react';
+
+type Variant = 'primary' | 'strong' | 'outline';
+
+const variants: Record
= {
+ primary: 'bg-primary text-on-primary',
+ strong: 'bg-strong text-on-strong',
+ outline: 'border-2 border-field-line text-fg hover:bg-surface',
+};
+
+interface ButtonProps extends ButtonHTMLAttributes {
+ variant?: Variant;
+}
+
+export function Button({ variant = 'strong', className = '', type = 'button', ...props }: ButtonProps) {
+ return (
+
+ );
+}
diff --git a/frontend/src/components/ui/Card.tsx b/frontend/src/components/ui/Card.tsx
new file mode 100644
index 0000000..9563239
--- /dev/null
+++ b/frontend/src/components/ui/Card.tsx
@@ -0,0 +1,34 @@
+import type { ReactNode } from 'react';
+
+interface CardProps {
+ children: ReactNode;
+ highlight?: boolean;
+ className?: string;
+}
+
+export function Card({ children, highlight = false, className = '' }: CardProps) {
+ const border = highlight ? 'border-primary' : 'border-line';
+ return (
+
+ );
+}
+
+interface StepHeadingProps {
+ step: number;
+ title: string;
+ hint?: string;
+}
+
+export function StepHeading({ step, title, hint }: StepHeadingProps) {
+ return (
+
+ {String(step).padStart(2, '0')}
+
+ {title}
+ {hint && {hint} }
+
+
+ );
+}
diff --git a/frontend/src/components/ui/Chip.tsx b/frontend/src/components/ui/Chip.tsx
new file mode 100644
index 0000000..c5dba58
--- /dev/null
+++ b/frontend/src/components/ui/Chip.tsx
@@ -0,0 +1,57 @@
+import type { ReactNode } from 'react';
+
+interface ToggleChipProps {
+ children: ReactNode;
+ selected: boolean;
+ onClick: () => void;
+}
+
+/** A pill that can be switched on and off, e.g. a filter. */
+export function ToggleChip({ children, selected, onClick }: ToggleChipProps) {
+ const look = selected
+ ? 'border-selected bg-selected text-on-selected font-semibold'
+ : 'border-field-line bg-field text-fg';
+ return (
+
+ {children}
+
+ );
+}
+
+interface RemovableChipProps {
+ label: string;
+ onRemove: () => void;
+}
+
+/** A selected item with a remove button, e.g. an added ingredient. */
+export function RemovableChip({ label, onRemove }: RemovableChipProps) {
+ return (
+
+ {label}
+
+ ×
+
+
+ );
+}
+
+interface TagProps {
+ children: ReactNode;
+ accent?: boolean;
+}
+
+/** A small read-only label, e.g. a recipe's cooking time. */
+export function Tag({ children, accent = false }: TagProps) {
+ const look = accent ? 'bg-primary text-on-primary' : 'bg-tag text-on-tag';
+ return {children} ;
+}
diff --git a/frontend/src/components/ui/field.ts b/frontend/src/components/ui/field.ts
new file mode 100644
index 0000000..a8221b9
--- /dev/null
+++ b/frontend/src/components/ui/field.ts
@@ -0,0 +1,3 @@
+// Shared look for text inputs and selects
+export const fieldClass =
+ 'rounded-xl border-2 border-field-line bg-field text-fg placeholder:text-muted focus:border-primary focus:outline-none';
diff --git a/frontend/src/hooks/useTheme.ts b/frontend/src/hooks/useTheme.ts
new file mode 100644
index 0000000..d2ec958
--- /dev/null
+++ b/frontend/src/hooks/useTheme.ts
@@ -0,0 +1,53 @@
+import { useEffect, useState } from 'react';
+
+export type Theme = 'light' | 'dark';
+
+const STORAGE_KEY = 'theme';
+const systemQuery = window.matchMedia('(prefers-color-scheme: dark)');
+
+function savedTheme(): Theme | null {
+ try {
+ const value = localStorage.getItem(STORAGE_KEY);
+ return value === 'light' || value === 'dark' ? value : null;
+ } catch {
+ return null;
+ }
+}
+
+function applyTheme(theme: Theme) {
+ document.documentElement.classList.toggle('dark', theme === 'dark');
+}
+
+/**
+ * Light/dark theme. Follows the OS setting until the user picks one with
+ * toggle(); the inline script in index.html applies it before first paint.
+ */
+export function useTheme() {
+ const [theme, setTheme] = useState(
+ () => savedTheme() ?? (systemQuery.matches ? 'dark' : 'light'),
+ );
+
+ useEffect(() => {
+ applyTheme(theme);
+ }, [theme]);
+
+ useEffect(() => {
+ const onSystemChange = (e: MediaQueryListEvent) => {
+ if (!savedTheme()) setTheme(e.matches ? 'dark' : 'light');
+ };
+ systemQuery.addEventListener('change', onSystemChange);
+ return () => systemQuery.removeEventListener('change', onSystemChange);
+ }, []);
+
+ const toggle = () => {
+ const next = theme === 'dark' ? 'light' : 'dark';
+ try {
+ localStorage.setItem(STORAGE_KEY, next);
+ } catch {
+ // Storage can be unavailable (e.g. private mode); the theme still switches
+ }
+ setTheme(next);
+ };
+
+ return { theme, toggle };
+}
diff --git a/frontend/src/index.css b/frontend/src/index.css
index 2325ed8..4b513d4 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -1,10 +1,76 @@
@import "tailwindcss";
-@theme {
+/*
+ * Color tokens. Components only use the semantic names below (bg-surface,
+ * text-muted, ...), so each theme is defined once here.
+ */
+:root {
+ color-scheme: light;
+ --bg: #fef3e2;
+ --surface: #fffaf3;
+ --line: #f2c478;
+ --field: #ffffff;
+ --field-line: #ebc07e;
+ --fg: #2a1a0e;
+ --muted: #6b5440;
+ --accent: #c27000;
+ --accent-text: #8f5a0e;
+ --primary: #f4ae52;
+ --on-primary: #2a1a0e;
+ --strong: #2a1a0e;
+ --on-strong: #fef3e2;
+ --selected: #f4ae52;
+ --on-selected: #2a1a0e;
+ --tag: #2a1a0e;
+ --on-tag: #fef3e2;
+ --danger: #b42318;
+}
+
+:root.dark {
+ color-scheme: dark;
+ --bg: #2a1a0e;
+ --surface: #3a2617;
+ --line: #3a2617;
+ --field: #2a1a0e;
+ --field-line: #5a3f28;
+ --fg: #fef3e2;
+ --muted: #c9b29a;
+ --accent: #f4ae52;
+ --accent-text: #f4ae52;
+ --primary: #f4ae52;
+ --on-primary: #2a1a0e;
+ --strong: #f4ae52;
+ --on-strong: #2a1a0e;
+ --selected: #fef3e2;
+ --on-selected: #2a1a0e;
+ --tag: #5a3f28;
+ --on-tag: #fef3e2;
+ --danger: #fda29b;
+}
+
+@theme inline {
--font-sans: "Geist Variable", ui-sans-serif, system-ui, sans-serif;
+
+ --color-bg: var(--bg);
+ --color-surface: var(--surface);
+ --color-line: var(--line);
+ --color-field: var(--field);
+ --color-field-line: var(--field-line);
+ --color-fg: var(--fg);
+ --color-muted: var(--muted);
+ --color-accent: var(--accent);
+ --color-accent-text: var(--accent-text);
+ --color-primary: var(--primary);
+ --color-on-primary: var(--on-primary);
+ --color-strong: var(--strong);
+ --color-on-strong: var(--on-strong);
+ --color-selected: var(--selected);
+ --color-on-selected: var(--on-selected);
+ --color-tag: var(--tag);
+ --color-on-tag: var(--on-tag);
+ --color-danger: var(--danger);
}
body {
- background: #fff7ed;
- color: #171717;
+ @apply bg-bg text-fg;
}
diff --git a/frontend/src/types/recipe.ts b/frontend/src/types/recipe.ts
index d95928c..30f4c11 100644
--- a/frontend/src/types/recipe.ts
+++ b/frontend/src/types/recipe.ts
@@ -19,4 +19,5 @@ export interface IngredientRequest {
export interface FilterOptions {
dietary_preferences: string[];
max_cooking_time: number | null;
+ allow_external_ingredients: boolean;
}