-
+
{title}
diff --git a/apps/web/src/components/recipe/RecipeRatingInput/RecipeRatingInput.css b/apps/web/src/components/recipe/RecipeRatingInput/RecipeRatingInput.css
new file mode 100644
index 0000000..02572d3
--- /dev/null
+++ b/apps/web/src/components/recipe/RecipeRatingInput/RecipeRatingInput.css
@@ -0,0 +1,79 @@
+@layer components {
+ .recipe-rating-input {
+ margin: 0;
+ padding: 0;
+
+ border: 0;
+ }
+
+ .recipe-rating-input__legend {
+ margin-block-end: var(--space-3);
+
+ color: var(--color-text-primary);
+
+ font-size: var(--font-size-sm);
+ font-weight: var(--font-weight-semibold);
+ }
+
+ .recipe-rating-input__options {
+ display: flex;
+ flex-wrap: wrap;
+ gap: var(--space-2);
+ }
+
+ .recipe-rating-input__option {
+ position: relative;
+
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+
+ width: var(--target-size-min);
+ height: var(--target-size-min);
+
+ color: var(--color-brand-primary);
+ background-color: var(--color-surface);
+
+ border: var(--border-width-thin) solid var(--color-border-default);
+ border-radius: var(--radius-md);
+
+ cursor: pointer;
+
+ transition:
+ color var(--duration-fast) var(--ease-standard),
+ background-color var(--duration-fast) var(--ease-standard),
+ border-color var(--duration-fast) var(--ease-standard),
+ box-shadow var(--duration-fast) var(--ease-standard);
+ }
+
+ .recipe-rating-input__option:hover {
+ background-color: var(--color-surface-hover);
+ border-color: var(--color-brand-primary);
+ }
+
+ .recipe-rating-input__option:has(.recipe-rating-input__control:checked) {
+ background-color: var(--color-brand-accent-soft);
+ border-color: var(--color-brand-primary);
+ }
+
+ .recipe-rating-input__option:has(
+ .recipe-rating-input__control:focus-visible
+ ) {
+ outline: var(--border-width-medium) solid var(--color-focus-ring);
+ outline-offset: 2px;
+ }
+
+ .recipe-rating-input__control {
+ position: absolute;
+
+ width: 1px;
+ height: 1px;
+
+ opacity: 0;
+ pointer-events: none;
+ }
+
+ .recipe-rating-input__star {
+ display: inline-flex;
+ }
+}
diff --git a/apps/web/src/components/recipe/RecipeRatingInput/RecipeRatingInput.tsx b/apps/web/src/components/recipe/RecipeRatingInput/RecipeRatingInput.tsx
new file mode 100644
index 0000000..a279813
--- /dev/null
+++ b/apps/web/src/components/recipe/RecipeRatingInput/RecipeRatingInput.tsx
@@ -0,0 +1,61 @@
+import { StarIcon } from '../../../icons/rating';
+import { Icon } from '../../ui/Icon/Icon';
+
+import './RecipeRatingInput.css';
+
+export type RecipeRatingInputProps = {
+ value: number;
+ onChange: (value: number) => void;
+ name?: string;
+ label?: string;
+};
+
+const STAR_VALUES = [1, 2, 3, 4, 5] as const;
+
+/**
+ * Accessible 1–5 star input used when a user rates a recipe.
+ *
+ * The native radio inputs keep normal form and keyboard semantics while the
+ * labels provide the visual star controls.
+ */
+export default function RecipeRatingInput({
+ value,
+ onChange,
+ name = 'recipe-rating',
+ label = 'Your rating',
+}: RecipeRatingInputProps) {
+ return (
+
+ );
+}
diff --git a/apps/web/src/components/recipe/__tests__/RecipeCard.test.tsx b/apps/web/src/components/recipe/__tests__/RecipeCard.test.tsx
index 5e18fbb..ac78a8b 100644
--- a/apps/web/src/components/recipe/__tests__/RecipeCard.test.tsx
+++ b/apps/web/src/components/recipe/__tests__/RecipeCard.test.tsx
@@ -1,7 +1,7 @@
import { type ComponentProps } from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
-import { MemoryRouter } from 'react-router-dom';
+import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';
import { describe, expect, it, vi } from 'vitest';
import RecipeCard from '../RecipeCard/RecipeCard';
@@ -34,6 +34,16 @@ function renderRecipeCard(props: ComponentProps
) {
);
}
+function LocationStateProbe() {
+ const location = useLocation();
+
+ return (
+
+ );
+}
+
describe('RecipeCard', () => {
it('exposes the recipe link and accessible rating summary', () => {
renderRecipeCard(baseProps);
@@ -51,6 +61,32 @@ describe('RecipeCard', () => {
).toBeTruthy();
});
+ it('keeps the exact browse URL as recipe navigation state', async () => {
+ const user = userEvent.setup();
+
+ render(
+
+
+ } />
+
+ } />
+
+ ,
+ );
+
+ await user.click(
+ screen.getByRole('link', {
+ name: 'Spaghetti Carbonara',
+ }),
+ );
+
+ expect(screen.getByTestId('recipe-location-state').textContent).toBe(
+ JSON.stringify({
+ from: '/?q=pasta&category=dinner&page=2',
+ }),
+ );
+ });
+
it('renders structured cooking time and servings metadata', () => {
renderRecipeCard(baseProps);
diff --git a/apps/web/src/data/recipes.ts b/apps/web/src/data/recipes.ts
index 48eeaeb..a103eaa 100644
--- a/apps/web/src/data/recipes.ts
+++ b/apps/web/src/data/recipes.ts
@@ -34,7 +34,7 @@ export const recipes: Recipe[] = [
servings: 4,
tags: ['vegetarian', 'one-pan', 'breakfast'],
imageUrl:
- 'https://images.unsplash.com/photo-1590412200988-a436970781fa?auto=format&fit=crop&w=900&q=80',
+ 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR3i3sftsOhCx75YM5uWz6DpUYIzKqkfX5xgvJLnOnyvg&s=10',
author: yusuf,
ingredients: [
{
@@ -82,7 +82,7 @@ export const recipes: Recipe[] = [
servings: 4,
tags: ['pasta', 'seafood', 'quick'],
imageUrl:
- 'https://images.unsplash.com/photo-1473093295043-cdd812d0e601?auto=format&fit=crop&w=900&q=80',
+ 'https://www.crunchtimekitchen.com/wp-content/uploads/2024/04/Lemon-Linguine-feature-Feature-1520x1013.jpg',
author: emma,
ingredients: [
{
@@ -130,7 +130,7 @@ export const recipes: Recipe[] = [
servings: 6,
tags: ['vegan', 'budget', 'soup'],
imageUrl:
- 'https://images.unsplash.com/photo-1547592166-23ac45744acd?auto=format&fit=crop&w=900&q=80',
+ 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcREc6I7Eh7Id8ShR_DFGqrN_fWRgWw7JJV-5xtCAvmwH4nNLOcz15U6Qvg&s=10',
author: currentUser,
ingredients: [
{
@@ -178,7 +178,7 @@ export const recipes: Recipe[] = [
servings: 6,
tags: ['rice', 'chicken', 'spicy', 'weekend'],
imageUrl:
- 'https://images.unsplash.com/photo-1563379926898-05f4575a45d8?auto=format&fit=crop&w=900&q=80',
+ 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTXUu2IadiC7B2-y2_FpLd96CB8y9jzmw_Dm7gnkaA4KZJJVL2AM5mGQVLc&s=10',
author: yusuf,
ingredients: [
{
@@ -226,7 +226,7 @@ export const recipes: Recipe[] = [
servings: 4,
tags: ['vegetarian', 'tacos', 'family'],
imageUrl:
- 'https://images.unsplash.com/photo-1551504734-5ee1c4a1479b?auto=format&fit=crop&w=900&q=80',
+ 'https://www.theedgyveg.com/wp-content/uploads/2014/10/m9a4134.jpg',
author: nora,
ingredients: [
{
@@ -274,7 +274,7 @@ export const recipes: Recipe[] = [
servings: 6,
tags: ['waffles', 'dessert', 'norwegian'],
imageUrl:
- 'https://images.unsplash.com/photo-1562376552-0d160a2f238d?auto=format&fit=crop&w=900&q=80',
+ 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSPqyyC6kO12Vo2c05OjkMPLHs9mCOY5IQB0FmL4mraqg&s',
author: emma,
ingredients: [
{
@@ -330,7 +330,7 @@ export const recipes: Recipe[] = [
'weeknight',
],
imageUrl:
- 'https://images.unsplash.com/photo-1540420773420-3366772f4999?auto=format&fit=crop&w=900&q=80',
+ 'https://www.veganricha.com/wp-content/uploads/2022/03/Mediterranean-Veggie-Bowl-1277-e1648603282208.jpg',
author: nora,
ingredients: [
{
@@ -418,7 +418,7 @@ export const recipes: Recipe[] = [
servings: 4,
tags: ['vegetarian', 'lunch', 'protein'],
imageUrl:
- 'https://images.unsplash.com/photo-1512621776951-a57141f2eefd?auto=format&fit=crop&w=900&q=80',
+ 'https://spicecravings.com/wp-content/uploads/2022/07/falafel-salad-47.jpg',
author: yusuf,
ingredients: [
{
@@ -466,7 +466,7 @@ export const recipes: Recipe[] = [
servings: 8,
tags: ['cake', 'apple', 'baking'],
imageUrl:
- 'https://images.unsplash.com/photo-1568571780765-9276ac8b75a2?auto=format&fit=crop&w=900&q=80',
+ 'https://ohsweetbasil.com/wp-content/uploads/old-fashioned-apple-cake-with-warm-caramel-sauce-recipe-12.jpg',
author: currentUser,
ingredients: [
{
@@ -514,7 +514,7 @@ export const recipes: Recipe[] = [
servings: 4,
tags: ['curry', 'spicy', 'dairy-free'],
imageUrl:
- 'https://images.unsplash.com/photo-1455619452474-d2be8b1e70cd?auto=format&fit=crop&w=900&q=80',
+ 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTHnXI31TDQNX8FSjx1Swz_Tso_W2WPyLne0YgokB4GGPGPvMV3QsiUg7Q&s=10',
author: nora,
ingredients: [
{
@@ -561,7 +561,8 @@ export const recipes: Recipe[] = [
cookMinutes: 150,
servings: 6,
tags: ['lamb', 'slow-cooked', 'comfort-food'],
- imageUrl: null,
+ imageUrl:
+ 'https://autoimmunewellness.com/wp-content/uploads/2017/01/batch_Hearty-Irish-Lamb-Stew-lscape.jpg',
author: currentUser,
ingredients: [
{
@@ -596,4 +597,177 @@ export const recipes: Recipe[] = [
createdAt: '2026-09-03T18:00:00Z',
updatedAt: '2026-09-03T18:00:00Z',
},
+ {
+ id: 'ultimate-double-cheeseburger',
+ title:
+ 'Ultimate Double Cheeseburger with Caramelized Onions, Crispy Bacon and Homemade Burger Sauce',
+ description:
+ 'A generously stacked homemade cheeseburger with two juicy beef patties, melted cheddar, crispy bacon, slow-caramelized onions, fresh vegetables and a tangy homemade burger sauce. This recipe is designed as a more detailed test case for the recipe detail page, with a longer title, richer description, more tags, a larger ingredient list and a more complete set of instructions.',
+ category: 'Dinner',
+ cuisine: 'American',
+ difficulty: 'medium',
+ prepMinutes: 35,
+ cookMinutes: 30,
+ servings: 4,
+ tags: [
+ 'burger',
+ 'beef',
+ 'cheeseburger',
+ 'bacon',
+ 'comfort-food',
+ 'homemade',
+ 'weekend',
+ 'grill',
+ ],
+ imageUrl:
+ 'https://ohsweetbasil.com/wp-content/uploads/how-to-grill-a-perfect-burger-recipe-what-ground-beef-to-buy-6-900x600.jpg',
+ author: currentUser,
+ ingredients: [
+ {
+ id: 'ultimate-burger-ground-beef',
+ name: 'Ground beef',
+ amount: 800,
+ unit: 'g',
+ note: 'Preferably 15–20% fat',
+ },
+ {
+ id: 'ultimate-burger-buns',
+ name: 'Burger buns',
+ amount: 4,
+ unit: 'pcs',
+ note: 'Brioche or potato buns work well',
+ },
+ {
+ id: 'ultimate-burger-cheddar',
+ name: 'Cheddar cheese',
+ amount: 8,
+ unit: 'slices',
+ },
+ {
+ id: 'ultimate-burger-bacon',
+ name: 'Bacon',
+ amount: 8,
+ unit: 'slices',
+ },
+ {
+ id: 'ultimate-burger-onions',
+ name: 'Yellow onions',
+ amount: 2,
+ unit: 'pcs',
+ note: 'Thinly sliced',
+ },
+ {
+ id: 'ultimate-burger-butter',
+ name: 'Butter',
+ amount: 20,
+ unit: 'g',
+ },
+ {
+ id: 'ultimate-burger-lettuce',
+ name: 'Crisp lettuce',
+ amount: 4,
+ unit: 'leaves',
+ },
+ {
+ id: 'ultimate-burger-tomato',
+ name: 'Tomato',
+ amount: 1,
+ unit: 'pcs',
+ note: 'Sliced',
+ },
+ {
+ id: 'ultimate-burger-pickles',
+ name: 'Pickles',
+ amount: 12,
+ unit: 'slices',
+ },
+ {
+ id: 'ultimate-burger-mayonnaise',
+ name: 'Mayonnaise',
+ amount: 80,
+ unit: 'g',
+ },
+ {
+ id: 'ultimate-burger-ketchup',
+ name: 'Ketchup',
+ amount: 40,
+ unit: 'g',
+ },
+ {
+ id: 'ultimate-burger-mustard',
+ name: 'Dijon mustard',
+ amount: 20,
+ unit: 'g',
+ },
+ {
+ id: 'ultimate-burger-pickle-juice',
+ name: 'Pickle juice',
+ amount: 10,
+ unit: 'ml',
+ note: 'Optional, for the burger sauce',
+ },
+ {
+ id: 'ultimate-burger-salt',
+ name: 'Salt',
+ amount: 1.5,
+ unit: 'tsp',
+ },
+ {
+ id: 'ultimate-burger-pepper',
+ name: 'Black pepper',
+ amount: 1,
+ unit: 'tsp',
+ note: 'Freshly ground',
+ },
+ ],
+ instructions: [
+ {
+ step: 1,
+ text: 'Prepare the burger sauce by mixing the mayonnaise, ketchup, Dijon mustard and pickle juice in a small bowl. Refrigerate until the burgers are ready to assemble.',
+ },
+ {
+ step: 2,
+ text: 'Melt the butter in a skillet over medium-low heat. Add the sliced onions and cook slowly for 15–20 minutes, stirring regularly, until deeply golden, soft and caramelized.',
+ },
+ {
+ step: 3,
+ text: 'While the onions cook, fry the bacon in a separate skillet until crisp. Transfer it to a plate lined with paper towel and set aside.',
+ },
+ {
+ step: 4,
+ text: 'Divide the ground beef into eight equal portions and gently shape them into thin patties slightly wider than the burger buns. Avoid pressing or compacting the meat too firmly.',
+ },
+ {
+ step: 5,
+ text: 'Season both sides of the patties with salt and freshly ground black pepper just before cooking.',
+ },
+ {
+ step: 6,
+ text: 'Heat a large skillet, griddle or grill over high heat. Cook the patties in batches for about 2–3 minutes on the first side, then flip and cook for another 1–2 minutes.',
+ },
+ {
+ step: 7,
+ text: 'Place one slice of cheddar on each patty during the final minute of cooking. Allow the cheese to melt, then stack two patties together for each burger.',
+ },
+ {
+ step: 8,
+ text: 'Lightly toast the burger buns cut-side down in the skillet or on the grill until golden around the edges.',
+ },
+ {
+ step: 9,
+ text: 'Spread burger sauce over both sides of each toasted bun. Add lettuce and tomato to the bottom bun, followed by the double cheeseburger patties.',
+ },
+ {
+ step: 10,
+ text: 'Top each burger with crispy bacon, caramelized onions and pickle slices. Add a little extra burger sauce if desired, then finish with the top bun and serve immediately.',
+ },
+ ],
+ rating: { average: 4.7, count: 138 },
+ saveCount: 924,
+ visibility: 'public',
+ isSaved: false,
+ isCreatedByCurrentUser: true,
+ createdAt: '2026-09-18T16:30:00Z',
+ updatedAt: '2026-10-08T19:15:00Z',
+ },
];
diff --git a/apps/web/src/features/cookbook/CookbookPage.test.tsx b/apps/web/src/features/cookbook/CookbookPage.test.tsx
index 48b2177..3b6348c 100644
--- a/apps/web/src/features/cookbook/CookbookPage.test.tsx
+++ b/apps/web/src/features/cookbook/CookbookPage.test.tsx
@@ -12,7 +12,7 @@ const scrollToMock = vi.fn();
function LocationProbe() {
const location = useLocation();
- return ;
+ return {location.search}
;
}
function renderCookbookPage(initialEntry = '/cookbook') {
@@ -47,7 +47,11 @@ describe('CookbookPage', () => {
}),
).toBeTruthy();
- expect(screen.getByText('8 recipes found')).toBeTruthy();
+ expect(
+ screen.getByText(/recipes found/i, {
+ selector: '.cookbook-page__result-count',
+ }),
+ ).toBeTruthy();
expect(
(
@@ -307,7 +311,7 @@ describe('CookbookPage', () => {
}),
);
- expect(screen.getByText('8 recipes found')).toBeTruthy();
+ expect(screen.getByText('9 recipes found')).toBeTruthy();
expect(screen.getByTestId('location-search').textContent).toBe('');
await user.click(
@@ -368,7 +372,7 @@ describe('CookbookPage', () => {
screen.getByText('Enter a maximum cooking time before applying filters.'),
).toBeTruthy();
- expect(screen.getByText('8 recipes found')).toBeTruthy();
+ expect(screen.getByText('9 recipes found')).toBeTruthy();
expect(screen.getByTestId('location-search').textContent).toBe('');
});
@@ -408,7 +412,7 @@ describe('CookbookPage', () => {
}),
);
- expect(screen.getByText('8 recipes found')).toBeTruthy();
+ expect(screen.getByText('9 recipes found')).toBeTruthy();
expect(screen.getByTestId('location-search').textContent).toBe('');
expect(
diff --git a/apps/web/src/features/cookbook/mockCookbookQuery.test.ts b/apps/web/src/features/cookbook/mockCookbookQuery.test.ts
index 343a7f5..123eaa3 100644
--- a/apps/web/src/features/cookbook/mockCookbookQuery.test.ts
+++ b/apps/web/src/features/cookbook/mockCookbookQuery.test.ts
@@ -22,7 +22,7 @@ describe('getMockCookbookResult', () => {
it('returns the union of saved and created recipes for All', () => {
const result = getMockCookbookResult(createQuery());
- expect(result.totalItems).toBe(8);
+ expect(result.totalItems).toBe(9);
expect(
result.items.every(
@@ -141,7 +141,6 @@ describe('getMockCookbookResult', () => {
}
const previousMinutes = previous.prepMinutes + previous.cookMinutes;
-
const currentMinutes = current.prepMinutes + current.cookMinutes;
expect(previousMinutes).toBeLessThanOrEqual(currentMinutes);
@@ -175,8 +174,8 @@ describe('getMockCookbookResult', () => {
}),
);
- expect(firstPage.totalItems).toBe(8);
+ expect(firstPage.totalItems).toBe(9);
expect(firstPage.items).toHaveLength(6);
- expect(secondPage.items).toHaveLength(2);
+ expect(secondPage.items).toHaveLength(3);
});
});
diff --git a/apps/web/src/features/explore/ExplorePage.test.tsx b/apps/web/src/features/explore/ExplorePage.test.tsx
index 8f51986..493cb2b 100644
--- a/apps/web/src/features/explore/ExplorePage.test.tsx
+++ b/apps/web/src/features/explore/ExplorePage.test.tsx
@@ -13,7 +13,7 @@ const scrollToMock = vi.fn();
function LocationProbe() {
const location = useLocation();
- return ;
+ return {location.search}
;
}
function HistoryBackButton() {
@@ -106,7 +106,7 @@ describe('ExplorePage', () => {
'dinner',
);
- expect(screen.getByText('5 recipes found')).toBeTruthy();
+ expect(screen.getByRole('status').textContent).toMatch(/recipes found/i);
expect(screen.getByTestId('location-search').textContent).toBe(
'?category=dinner&sort=popular',
@@ -235,7 +235,7 @@ describe('ExplorePage', () => {
await user.clear(searchInput);
- expect(screen.getByText('10 recipes found')).toBeTruthy();
+ expect(screen.getByRole('status').textContent).toMatch(/recipes found/i);
expect(screen.getByTestId('location-search').textContent).toBe(
'?sort=popular',
@@ -267,7 +267,7 @@ describe('ExplorePage', () => {
}),
);
- expect(screen.getByText('10 recipes found')).toBeTruthy();
+ expect(screen.getByRole('status').textContent).toMatch(/recipes found/i);
expect(screen.getByTestId('location-search').textContent).toBe(
'?sort=popular',
diff --git a/apps/web/src/features/explore/mockExploreQuery.test.ts b/apps/web/src/features/explore/mockExploreQuery.test.ts
index ab69a30..674fa26 100644
--- a/apps/web/src/features/explore/mockExploreQuery.test.ts
+++ b/apps/web/src/features/explore/mockExploreQuery.test.ts
@@ -66,7 +66,7 @@ describe('getMockExploreResult', () => {
}),
);
- expect(result.totalItems).toBe(5);
+ expect(result.totalItems).toBe(6);
expect(result.items).toHaveLength(2);
expect(result.items.every((recipe) => recipe.category === 'Dinner')).toBe(
@@ -206,9 +206,9 @@ describe('getMockExploreResult', () => {
);
expect(result.items.slice(0, 3).map((recipe) => recipe.id)).toEqual([
+ 'ultimate-double-cheeseburger',
'thai-green-curry',
'apple-cake',
- 'falafel-bowl',
]);
});
@@ -248,9 +248,9 @@ describe('getMockExploreResult', () => {
}),
);
- expect(firstPage.totalItems).toBe(10);
+ expect(firstPage.totalItems).toBe(11);
expect(firstPage.items).toHaveLength(6);
- expect(secondPage.items).toHaveLength(4);
+ expect(secondPage.items).toHaveLength(5);
expect(firstPage.items[0]?.id).not.toBe(secondPage.items[0]?.id);
});
diff --git a/apps/web/src/features/recipe-detail/RecipeDetailPage.css b/apps/web/src/features/recipe-detail/RecipeDetailPage.css
new file mode 100644
index 0000000..7188470
--- /dev/null
+++ b/apps/web/src/features/recipe-detail/RecipeDetailPage.css
@@ -0,0 +1,540 @@
+@layer components {
+ .recipe-detail-page {
+ display: flex;
+ flex-direction: column;
+ gap: var(--space-4);
+
+ padding-block: var(--space-6) var(--space-16);
+ }
+
+ .recipe-detail-page--not-found {
+ min-height: 60dvh;
+ align-items: center;
+ justify-content: center;
+ }
+
+ .recipe-detail-page__back-row {
+ display: flex;
+ align-items: center;
+ }
+
+ .recipe-detail-page__back-button.button {
+ margin-inline-start: calc(var(--space-3) * -1);
+
+ color: var(--color-text-secondary);
+ }
+
+ .recipe-detail-page__hero-grid {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ align-items: stretch;
+ gap: var(--space-4);
+ }
+
+ .recipe-detail-page__content-grid {
+ display: grid;
+ grid-template-columns: minmax(18rem, 0.8fr) minmax(0, 1.2fr);
+ align-items: start;
+ gap: var(--space-4);
+
+ scroll-margin-top: var(--space-16);
+ }
+
+ .recipe-detail-page__media,
+ .recipe-detail-page__summary,
+ .recipe-detail-page__description-card,
+ .recipe-detail-page__content-card {
+ min-width: 0;
+
+ background-color: var(--color-surface);
+
+ border: var(--border-width-thin) solid var(--color-border-subtle);
+ border-radius: var(--radius-xl);
+
+ box-shadow: var(--shadow-sm);
+ }
+
+ .recipe-detail-page__media {
+ overflow: hidden;
+
+ aspect-ratio: 4 / 3;
+ max-height: 36rem;
+ }
+
+ .recipe-detail-page__image {
+ display: block;
+
+ width: 100%;
+ height: 100%;
+
+ object-fit: cover;
+ }
+
+ .recipe-detail-page__image--fallback {
+ object-fit: cover;
+ }
+
+ .recipe-detail-page__summary {
+ display: flex;
+ flex-direction: column;
+ gap: var(--space-4);
+
+ padding: var(--space-6);
+ }
+
+ .recipe-detail-page__title-row {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: var(--space-3);
+ }
+
+ .recipe-detail-page__title-row h1 {
+ min-width: 0;
+
+ font-size: var(--font-size-3xl);
+ }
+
+ .recipe-detail-page__author-rating {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: var(--space-4);
+ }
+
+ .recipe-detail-page__author {
+ display: inline-flex;
+ align-items: center;
+ gap: var(--space-2);
+
+ color: var(--color-text-secondary);
+
+ font-size: var(--font-size-sm);
+ font-weight: var(--font-weight-medium);
+ }
+
+ .recipe-detail-page__jump-button.button {
+ order: 2;
+
+ width: 100%;
+ }
+
+ .recipe-detail-page__description-card {
+ padding: var(--space-5) var(--space-6);
+ }
+
+ .recipe-detail-page__description-card h2 {
+ margin-block-end: var(--space-3);
+
+ font-size: var(--font-size-xl);
+ }
+
+ .recipe-detail-page__description {
+ width: 100%;
+
+ color: var(--color-text-secondary);
+
+ line-height: var(--line-height-relaxed);
+ }
+
+ .recipe-detail-page__description--mobile {
+ display: none;
+ }
+
+ .recipe-detail-page__meta.recipe-meta {
+ gap: var(--space-6);
+ }
+
+ .recipe-detail-page__meta .recipe-meta__item {
+ font-size: var(--font-size-sm);
+ }
+
+ .recipe-detail-page__tags {
+ display: flex;
+ flex-wrap: wrap;
+ gap: var(--space-2);
+
+ margin: 0;
+ padding: 0;
+
+ list-style: none;
+ }
+
+ .recipe-detail-page__tags > li {
+ display: flex;
+ }
+
+ .recipe-detail-page__category.tag {
+ font-weight: var(--font-weight-semibold);
+
+ border-color: var(--color-brand-primary);
+ }
+
+ .recipe-detail-page__tags-toggle.button {
+ border-radius: var(--radius-full);
+ }
+
+ .recipe-detail-page__actions {
+ order: 1;
+
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: var(--space-3);
+
+ margin-block-start: auto;
+ }
+
+ .recipe-detail-page__actions > :only-child {
+ grid-column: 1 / -1;
+ }
+
+ .recipe-detail-page__actions > .button,
+ .recipe-detail-page__primary-action.button {
+ width: 100%;
+ }
+
+ .recipe-detail-page__action--active.button {
+ color: var(--color-brand-primary-active);
+ background-color: var(--color-surface-selected);
+
+ border-color: var(--color-brand-primary);
+ }
+
+ .recipe-detail-page__action--active.button:hover {
+ background-color: color-mix(
+ in srgb,
+ var(--color-surface-selected) 65%,
+ var(--color-surface-pressed)
+ );
+ }
+
+ .recipe-detail-page__action--active.button:active {
+ background-color: var(--color-surface-pressed);
+ }
+
+ .recipe-detail-page__servings-control {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--space-4);
+
+ padding: var(--space-4);
+
+ background-color: var(--color-surface-raised);
+
+ border: var(--border-width-thin) solid var(--color-border-divider);
+ border-radius: var(--radius-lg);
+ }
+
+ .recipe-detail-page__servings-control--mobile {
+ display: none;
+ }
+
+ .recipe-detail-page__servings-control--desktop {
+ width: 100%;
+
+ background-color: var(--color-surface-muted);
+
+ border-color: var(--color-border-strong);
+ }
+
+ .recipe-detail-page__servings-control h2 {
+ font-size: var(--font-size-md);
+ }
+
+ .recipe-detail-page__servings-control p {
+ margin-block-start: var(--space-1);
+
+ color: var(--color-text-muted);
+
+ font-size: var(--font-size-xs);
+ }
+
+ .recipe-detail-page__stepper {
+ display: flex;
+ flex: 0 0 auto;
+ align-items: center;
+ gap: var(--space-3);
+ }
+
+ .recipe-detail-page__servings-value {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+
+ min-width: 4rem;
+
+ color: var(--color-text-secondary);
+
+ font-size: var(--font-size-xs);
+ line-height: var(--line-height-tight);
+ }
+
+ .recipe-detail-page__servings-value strong {
+ color: var(--color-text-primary);
+
+ font-size: var(--font-size-2xl);
+ line-height: var(--line-height-tight);
+ }
+
+ .recipe-detail-page__content-card {
+ padding: var(--space-5);
+ }
+
+ .recipe-detail-page__section-heading {
+ display: flex;
+ align-items: baseline;
+ justify-content: space-between;
+ gap: var(--space-3);
+
+ margin-block-end: var(--space-4);
+ }
+
+ .recipe-detail-page__section-heading h2 {
+ font-size: var(--font-size-2xl);
+ }
+
+ .recipe-detail-page__section-heading > span {
+ color: var(--color-text-muted);
+
+ font-size: var(--font-size-sm);
+ }
+
+ .recipe-detail-page__ingredients,
+ .recipe-detail-page__instructions {
+ margin: 0;
+ padding: 0;
+
+ list-style: none;
+ }
+
+ .recipe-detail-page__ingredients li {
+ display: grid;
+ grid-template-columns: minmax(5.5rem, 0.35fr) minmax(0, 1fr);
+ gap: var(--space-4);
+
+ padding-block: var(--space-3);
+
+ border-top: var(--border-width-thin) solid var(--color-border-divider);
+ }
+
+ .recipe-detail-page__ingredients li:first-child {
+ border-top: 0;
+ }
+
+ .recipe-detail-page__ingredients strong {
+ color: var(--color-text-primary);
+
+ white-space: nowrap;
+ }
+
+ .recipe-detail-page__ingredients span {
+ min-width: 0;
+
+ color: var(--color-text-secondary);
+ }
+
+ .recipe-detail-page__instructions li {
+ display: grid;
+ grid-template-columns: auto minmax(0, 1fr);
+ align-items: flex-start;
+ gap: var(--space-3);
+
+ padding-block: var(--space-3);
+
+ border-top: var(--border-width-thin) solid var(--color-border-divider);
+ }
+
+ .recipe-detail-page__instructions li:first-child {
+ padding-block-start: 0;
+
+ border-top: 0;
+ }
+
+ .recipe-detail-page__instruction-number {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+
+ width: 2rem;
+ height: 2rem;
+
+ color: var(--color-brand-primary-active);
+ background-color: var(--color-brand-accent-soft);
+
+ font-weight: var(--font-weight-semibold);
+
+ border-radius: var(--radius-full);
+ }
+
+ .recipe-detail-page__instructions p {
+ padding-block-start: var(--space-1);
+
+ color: var(--color-text-secondary);
+
+ line-height: var(--line-height-relaxed);
+ }
+
+ .recipe-detail-page__toast-region {
+ position: fixed;
+ right: var(--space-6);
+ bottom: var(--space-6);
+ z-index: var(--z-overlay);
+
+ width: min(24rem, calc(100% - (2 * var(--space-6))));
+ }
+
+ @media (min-width: 60.001rem) {
+ .recipe-detail-page__hero-grid--oversized-summary
+ .recipe-detail-page__media {
+ align-self: start;
+
+ aspect-ratio: 5 / 4;
+ }
+
+ .recipe-detail-page__title-row h1.recipe-detail-page__title--medium {
+ font-size: 2.375rem;
+ }
+
+ .recipe-detail-page__title-row h1.recipe-detail-page__title--long {
+ font-size: 2.25rem;
+ }
+ }
+
+ @media (max-width: 65em) and (min-width: 60.001rem) {
+ .recipe-detail-page__hero-grid {
+ grid-template-columns: 1fr;
+ align-items: start;
+ }
+
+ .recipe-detail-page__media {
+ max-height: none;
+
+ aspect-ratio: 16 / 9;
+ }
+
+ .recipe-detail-page__hero-grid--oversized-summary
+ .recipe-detail-page__media {
+ align-self: auto;
+
+ aspect-ratio: 16 / 9;
+ }
+ }
+
+ @media (max-width: 60rem) {
+ .recipe-detail-page__hero-grid,
+ .recipe-detail-page__content-grid {
+ grid-template-columns: 1fr;
+ }
+
+ .recipe-detail-page__hero-grid {
+ align-items: start;
+ }
+
+ .recipe-detail-page__media {
+ max-height: none;
+
+ aspect-ratio: 16 / 9;
+ }
+
+ .recipe-detail-page__jump-button.button {
+ order: 0;
+ }
+
+ .recipe-detail-page__description-card {
+ display: none;
+ }
+
+ .recipe-detail-page__description--mobile {
+ display: block;
+ }
+
+ .recipe-detail-page__actions {
+ order: 0;
+
+ margin-block-start: 0;
+ }
+
+ .recipe-detail-page__servings-control--desktop {
+ display: none;
+ }
+
+ .recipe-detail-page__servings-control--mobile {
+ display: flex;
+ }
+
+ .recipe-detail-page__content-grid {
+ gap: var(--space-4);
+ }
+ }
+
+ @media (max-width: 44rem) {
+ .recipe-detail-page {
+ gap: var(--space-3);
+
+ padding-block: var(--space-4) var(--space-12);
+ }
+
+ .recipe-detail-page__back-button.button {
+ margin-inline-start: calc(var(--space-2) * -1);
+ }
+
+ .recipe-detail-page__hero-grid,
+ .recipe-detail-page__content-grid {
+ gap: var(--space-3);
+ }
+
+ .recipe-detail-page__media {
+ aspect-ratio: 4 / 3;
+ }
+
+ .recipe-detail-page__summary,
+ .recipe-detail-page__content-card {
+ padding: var(--space-4);
+ }
+
+ .recipe-detail-page__title-row {
+ align-items: center;
+ }
+
+ .recipe-detail-page__title-row h1 {
+ font-size: var(--font-size-2xl);
+ }
+
+ .recipe-detail-page__author-rating {
+ gap: var(--space-3);
+ }
+
+ .recipe-detail-page__actions {
+ grid-template-columns: 1fr;
+ }
+
+ .recipe-detail-page__servings-control {
+ align-items: flex-start;
+ flex-direction: column;
+ }
+
+ .recipe-detail-page__stepper {
+ justify-content: center;
+
+ width: 100%;
+ }
+
+ .recipe-detail-page__section-heading h2 {
+ font-size: var(--font-size-xl);
+ }
+
+ .recipe-detail-page__ingredients li {
+ grid-template-columns: minmax(4.75rem, auto) minmax(0, 1fr);
+ gap: var(--space-3);
+ }
+
+ .recipe-detail-page__toast-region {
+ right: var(--space-4);
+ bottom: var(--space-4);
+ left: var(--space-4);
+
+ width: auto;
+ }
+ }
+}
diff --git a/apps/web/src/features/recipe-detail/RecipeDetailPage.test.tsx b/apps/web/src/features/recipe-detail/RecipeDetailPage.test.tsx
new file mode 100644
index 0000000..68a2a1b
--- /dev/null
+++ b/apps/web/src/features/recipe-detail/RecipeDetailPage.test.tsx
@@ -0,0 +1,206 @@
+import '@testing-library/jest-dom/vitest';
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';
+import { beforeEach, describe, expect, it } from 'vitest';
+
+import { INITIAL_SAVED_RECIPE_IDS, useAppStore } from '../../store';
+
+import RecipeDetailPage from './RecipeDetailPage';
+
+function LocationProbe() {
+ const location = useLocation();
+
+ return (
+
+ );
+}
+
+function renderRecipeDetail(
+ initialEntry:
+ | string
+ | {
+ pathname: string;
+ state?: unknown;
+ },
+) {
+ return render(
+
+
+ } />
+ } />
+
+ ,
+ );
+}
+
+describe('RecipeDetailPage', () => {
+ beforeEach(() => {
+ useAppStore.setState({
+ savedRecipeIds: [...INITIAL_SAVED_RECIPE_IDS],
+ userRatings: {},
+ });
+ });
+
+ it('shows public non-owner recipe actions and total cooking time', () => {
+ renderRecipeDetail('/recipes/salmon-pasta');
+
+ expect(
+ screen.getByRole('heading', { name: 'Creamy salmon pasta' }),
+ ).toBeInTheDocument();
+
+ expect(screen.getByText('30 min')).toBeInTheDocument();
+
+ expect(
+ screen.getByRole('button', { name: 'Save to Cookbook' }),
+ ).toBeInTheDocument();
+
+ expect(
+ screen.getByRole('button', { name: 'Rate Recipe' }),
+ ).toBeInTheDocument();
+ });
+
+ it('scales ingredient amounts when servings change', async () => {
+ const user = userEvent.setup();
+
+ renderRecipeDetail('/recipes/salmon-pasta');
+
+ expect(screen.getByText('400 g')).toBeInTheDocument();
+
+ const increaseServingButtons = screen.getAllByRole('button', {
+ name: 'Increase servings',
+ });
+
+ expect(increaseServingButtons.length).toBeGreaterThan(0);
+
+ await user.click(increaseServingButtons[0]!);
+
+ expect(screen.getByText('500 g')).toBeInTheDocument();
+
+ expect(screen.getAllByText('5 servings').length).toBeGreaterThan(0);
+ });
+
+ it('saves a recipe into shared cookbook state', async () => {
+ const user = userEvent.setup();
+
+ renderRecipeDetail('/recipes/salmon-pasta');
+
+ await user.click(
+ screen.getByRole('button', {
+ name: 'Save to Cookbook',
+ }),
+ );
+
+ expect(useAppStore.getState().savedRecipeIds).toContain('salmon-pasta');
+
+ expect(screen.getByRole('button', { name: 'Saved' })).toHaveAttribute(
+ 'aria-pressed',
+ 'true',
+ );
+ });
+
+ it('stores a mock user rating and allows it to be changed later', async () => {
+ const user = userEvent.setup();
+
+ renderRecipeDetail('/recipes/salmon-pasta');
+
+ await user.click(
+ screen.getByRole('button', {
+ name: 'Rate Recipe',
+ }),
+ );
+
+ await user.click(
+ screen.getByRole('radio', {
+ name: '5 stars',
+ }),
+ );
+
+ await user.click(
+ screen.getByRole('button', {
+ name: 'Save rating',
+ }),
+ );
+
+ expect(useAppStore.getState().userRatings['salmon-pasta']).toBe(5);
+
+ expect(
+ screen.getByRole('button', {
+ name: 'Change rating, currently 5 out of 5',
+ }),
+ ).toBeInTheDocument();
+ });
+
+ it('shows owner controls and hides ratings for a private recipe', () => {
+ renderRecipeDetail('/recipes/tomato-soup');
+
+ expect(screen.getByText('Private')).toBeInTheDocument();
+
+ expect(
+ screen.getByRole('link', {
+ name: 'Edit Recipe',
+ }),
+ ).toBeInTheDocument();
+
+ expect(screen.queryByRole('img', { name: /out of 5/ })).toBeNull();
+
+ expect(
+ screen.queryByRole('button', {
+ name: 'Rate Recipe',
+ }),
+ ).toBeNull();
+
+ expect(
+ screen.queryByRole('button', {
+ name: 'Save to Cookbook',
+ }),
+ ).toBeNull();
+ });
+
+ it('returns to the exact source URL stored by recipe navigation', async () => {
+ const user = userEvent.setup();
+
+ renderRecipeDetail({
+ pathname: '/recipes/salmon-pasta',
+ state: {
+ from: '/?q=pasta&category=dinner&page=2',
+ },
+ });
+
+ await user.click(
+ screen.getByRole('button', {
+ name: 'Back to Explore',
+ }),
+ );
+
+ expect(screen.getByTestId('location')).toHaveTextContent(
+ '/?q=pasta&category=dinner&page=2',
+ );
+ });
+
+ it('uses the cookbook fallback for an owner recipe opened directly', async () => {
+ const user = userEvent.setup();
+
+ renderRecipeDetail('/recipes/lentil-soup');
+
+ await user.click(
+ screen.getByRole('button', {
+ name: 'Back to My Cookbook',
+ }),
+ );
+
+ expect(screen.getByTestId('location')).toHaveTextContent('/cookbook');
+ });
+
+ it('shows a simple not-found state for an unknown recipe id', () => {
+ renderRecipeDetail('/recipes/does-not-exist');
+
+ expect(
+ screen.getByRole('heading', {
+ name: 'Recipe not found',
+ }),
+ ).toBeInTheDocument();
+ });
+});
diff --git a/apps/web/src/features/recipe-detail/RecipeDetailPage.tsx b/apps/web/src/features/recipe-detail/RecipeDetailPage.tsx
new file mode 100644
index 0000000..062632d
--- /dev/null
+++ b/apps/web/src/features/recipe-detail/RecipeDetailPage.tsx
@@ -0,0 +1,692 @@
+import { useMemo, useState } from 'react';
+
+import { useLocation, useNavigate, useParams } from 'react-router-dom';
+
+import fallbackRecipeImage from '../../assets/recipe-fallback.png';
+import RecipeMeta from '../../components/recipe/RecipeMeta/RecipeMeta';
+import RecipeRating from '../../components/recipe/RecipeRating/RecipeRating';
+import RecipeRatingInput from '../../components/recipe/RecipeRatingInput/RecipeRatingInput';
+import Avatar from '../../components/ui/Avatar/Avatar';
+import Button from '../../components/ui/Button/Button';
+import ConfirmationDialog from '../../components/ui/ConfirmationDialog/ConfirmationDialog';
+import Dialog from '../../components/ui/Dialog/Dialog';
+import EmptyState from '../../components/ui/EmptyState/EmptyState';
+import { Icon } from '../../components/ui/Icon/Icon';
+import IconButton from '../../components/ui/IconButton/IconButton';
+import LinkButton from '../../components/ui/LinkButton/LinkButton';
+import Tag from '../../components/ui/Tag/Tag';
+import Toast, { type ToastTone } from '../../components/ui/Toast/Toast';
+import { recipes } from '../../data/recipes';
+import {
+ BookmarkIcon,
+ EditIcon,
+ MinusIcon,
+ PlusIcon,
+} from '../../icons/actions';
+import { BackIcon } from '../../icons/navigation';
+import { StarIcon } from '../../icons/rating';
+import { EmptyStateIcon, PrivateIcon } from '../../icons/recipe';
+import { useAppStore } from '../../store';
+import type { Recipe } from '../../types/recipe';
+
+import './RecipeDetailPage.css';
+
+const MIN_SERVINGS = 1;
+const MAX_SERVINGS = 20;
+const MAX_VISIBLE_TAGS = 5;
+
+interface RecipeDetailLocationState {
+ from?: string;
+}
+
+interface RecipeDetailContentProps {
+ recipe: Recipe;
+}
+
+type DetailFeedback = {
+ tone: ToastTone;
+ title: string;
+ message: string;
+};
+
+function formatTagLabel(tag: string) {
+ return tag
+ .split('-')
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(' ');
+}
+
+function formatScaledAmount(
+ amount: number,
+ selectedServings: number,
+ originalServings: number,
+) {
+ const scaledAmount = amount * (selectedServings / originalServings);
+
+ if (scaledAmount >= 200) {
+ return String(Math.round(scaledAmount / 5) * 5);
+ }
+
+ if (scaledAmount >= 50) {
+ return String(Math.round(scaledAmount));
+ }
+
+ if (scaledAmount >= 3) {
+ return String(Math.round(scaledAmount * 10) / 10);
+ }
+
+ return String(Math.round(scaledAmount * 100) / 100);
+}
+
+function getDisplayedRating(recipe: Recipe, userRating?: number) {
+ if (!userRating) {
+ return recipe.rating;
+ }
+
+ const nextCount = recipe.rating.count + 1;
+ const nextAverage =
+ (recipe.rating.average * recipe.rating.count + userRating) / nextCount;
+
+ return {
+ average: Number(nextAverage.toFixed(1)),
+ count: nextCount,
+ };
+}
+
+function getSourcePath(locationState: unknown) {
+ const state = locationState as RecipeDetailLocationState | null;
+
+ return typeof state?.from === 'string' && state.from.startsWith('/')
+ ? state.from
+ : undefined;
+}
+
+function RecipeDetailContent({ recipe }: RecipeDetailContentProps) {
+ const navigate = useNavigate();
+ const location = useLocation();
+
+ const savedRecipeIds = useAppStore((state) => state.savedRecipeIds);
+ const setRecipeSaved = useAppStore((state) => state.setRecipeSaved);
+ const userRatings = useAppStore((state) => state.userRatings);
+ const setUserRating = useAppStore((state) => state.setUserRating);
+ const removeUserRating = useAppStore((state) => state.removeUserRating);
+
+ const [selectedServings, setSelectedServings] = useState(recipe.servings);
+ const [confirmUnsaveOpen, setConfirmUnsaveOpen] = useState(false);
+ const [ratingDialogOpen, setRatingDialogOpen] = useState(false);
+ const [pendingRating, setPendingRating] = useState(0);
+ const [feedback, setFeedback] = useState(null);
+ const [showAllTags, setShowAllTags] = useState(false);
+
+ // TODO(server-auth): replace this mock ownership flag with the authenticated
+ // user's recipe ownership/authorization returned by the backend.
+ const isOwner = recipe.isCreatedByCurrentUser;
+ const isPrivate = recipe.visibility === 'private';
+ const isSaved = savedRecipeIds.includes(recipe.id);
+ const canSaveOrRate = !isOwner && !isPrivate;
+ const userRating = userRatings[recipe.id];
+ const displayedRating = getDisplayedRating(recipe, userRating);
+ const totalMinutes = recipe.prepMinutes + recipe.cookMinutes;
+
+ const visibleTags = recipe.tags.filter(
+ (tag) =>
+ formatTagLabel(tag).toLowerCase() !== recipe.category.toLowerCase(),
+ );
+
+ const hasHiddenTags = visibleTags.length > MAX_VISIBLE_TAGS;
+ const displayedTags = showAllTags
+ ? visibleTags
+ : visibleTags.slice(0, MAX_VISIBLE_TAGS);
+ const hiddenTagCount = visibleTags.length - MAX_VISIBLE_TAGS;
+
+ const titleSizeClass =
+ recipe.title.length > 85
+ ? 'recipe-detail-page__title--long'
+ : recipe.title.length > 60
+ ? 'recipe-detail-page__title--medium'
+ : undefined;
+
+ const hasOversizedSummary = Boolean(titleSizeClass) || hasHiddenTags;
+
+ const sourcePath = getSourcePath(location.state);
+ const fallbackPath = isOwner || isPrivate ? '/cookbook' : '/';
+
+ const backLabel = sourcePath
+ ? sourcePath.startsWith('/cookbook')
+ ? 'Back to My Cookbook'
+ : 'Back to Explore'
+ : isOwner || isPrivate
+ ? 'Back to My Cookbook'
+ : 'Back to Explore';
+
+ function handleBack() {
+ if (sourcePath) {
+ navigate(sourcePath, { replace: true });
+ return;
+ }
+
+ if (location.key !== 'default' && window.history.length > 1) {
+ navigate(-1);
+ return;
+ }
+
+ navigate(fallbackPath);
+ }
+
+ function handleJumpToRecipe() {
+ document.getElementById('recipe-detail-recipe')?.scrollIntoView({
+ behavior: 'smooth',
+ block: 'start',
+ });
+ }
+
+ function handleSaveClick() {
+ if (isSaved) {
+ setConfirmUnsaveOpen(true);
+ return;
+ }
+
+ setRecipeSaved(recipe.id, true);
+
+ setFeedback({
+ tone: 'success',
+ title: 'Recipe saved',
+ message: `${recipe.title} was added to My Cookbook.`,
+ });
+ }
+
+ function handleConfirmUnsave() {
+ setConfirmUnsaveOpen(false);
+
+ setRecipeSaved(recipe.id, false);
+
+ setFeedback({
+ tone: 'info',
+ title: 'Recipe removed',
+ message: `${recipe.title} was removed from My Cookbook.`,
+ });
+ }
+
+ function handleOpenRating() {
+ setPendingRating(userRating ?? 0);
+ setRatingDialogOpen(true);
+ }
+
+ function handleSubmitRating() {
+ if (pendingRating < 1 || pendingRating > 5) {
+ return;
+ }
+
+ setUserRating(recipe.id, pendingRating);
+ setRatingDialogOpen(false);
+
+ setFeedback({
+ tone: 'success',
+ title: userRating ? 'Rating updated' : 'Rating saved',
+ message: `You rated ${recipe.title} ${pendingRating} out of 5.`,
+ });
+ }
+
+ function handleRemoveRating() {
+ removeUserRating(recipe.id);
+ setRatingDialogOpen(false);
+ setPendingRating(0);
+
+ setFeedback({
+ tone: 'info',
+ title: 'Rating removed',
+ message: `Your rating for ${recipe.title} was removed.`,
+ });
+ }
+
+ return (
+
+
+
+
+
+
+
+

+
+
+
+
+
+ {recipe.title}
+
+
+ {isPrivate ? (
+
+ Private
+
+ ) : null}
+
+
+
+
+
+
+
By {recipe.author.name}
+
+
+ {!isPrivate ? (
+
+ ) : null}
+
+
+
+
+
+ {recipe.description}
+
+
+
+
+
+ -
+
+ {recipe.category}
+
+
+
+ {displayedTags.map((tag) => (
+ -
+ {formatTagLabel(tag)}
+
+ ))}
+
+ {hasHiddenTags ? (
+ -
+
+
+ ) : null}
+
+
+
+ {isOwner ? (
+
+
+ Edit Recipe
+
+ ) : canSaveOrRate ? (
+ <>
+
+
+
+ >
+ ) : null}
+
+
+
+
+
Adjust Servings
+
+
Ingredient amounts update automatically.
+
+
+
+
+ setSelectedServings((current) =>
+ Math.max(MIN_SERVINGS, current - 1),
+ )
+ }
+ />
+
+
+
+ = MAX_SERVINGS}
+ onClick={() =>
+ setSelectedServings((current) =>
+ Math.min(MAX_SERVINGS, current + 1),
+ )
+ }
+ />
+
+
+
+
+
+
+ About this recipe
+
+ {recipe.description}
+
+
+
+
+
Adjust Servings
+
+
Ingredient amounts update automatically.
+
+
+
+
+ setSelectedServings((current) =>
+ Math.max(MIN_SERVINGS, current - 1),
+ )
+ }
+ />
+
+
+
+ = MAX_SERVINGS}
+ onClick={() =>
+ setSelectedServings((current) =>
+ Math.min(MAX_SERVINGS, current + 1),
+ )
+ }
+ />
+
+
+
+
+
+
+
Ingredients
+
+
+ {selectedServings}{' '}
+ {selectedServings === 1 ? 'serving' : 'servings'}
+
+
+
+
+ {recipe.ingredients.map((ingredient) => {
+ const scaledAmount = formatScaledAmount(
+ ingredient.amount,
+ selectedServings,
+ recipe.servings,
+ );
+
+ const amountWithUnit =
+ `${scaledAmount} ${ingredient.unit}`.trim();
+
+ return (
+ -
+ {amountWithUnit}
+
+
+ {ingredient.name}
+ {ingredient.note ? `, ${ingredient.note}` : ''}
+
+
+ );
+ })}
+
+
+
+
+
+
Instructions
+
+
+
+ {recipe.instructions.map((instruction) => (
+ -
+
+ {instruction.step}
+
+
+
+ Step {instruction.step}:
+ {instruction.text}
+
+
+ ))}
+
+
+
+
+ {canSaveOrRate ? (
+ <>
+ setConfirmUnsaveOpen(false)}
+ >
+ You can save this recipe again later.
+
+
+
+ >
+ ) : null}
+
+ {feedback ? (
+
+ setFeedback(null)}
+ >
+ {feedback.message}
+
+
+ ) : null}
+
+ );
+}
+
+function RecipeDetailPage() {
+ const { id } = useParams();
+
+ const recipe = useMemo(
+ () => recipes.find((candidate) => candidate.id === id),
+ [id],
+ );
+
+ if (!recipe) {
+ return (
+
+ Back to Explore}
+ />
+
+ );
+ }
+
+ return ;
+}
+
+export default RecipeDetailPage;
diff --git a/apps/web/src/icons/actions.tsx b/apps/web/src/icons/actions.tsx
index 116fc13..4c5ad25 100644
--- a/apps/web/src/icons/actions.tsx
+++ b/apps/web/src/icons/actions.tsx
@@ -29,6 +29,22 @@ export function AddRecipeIcon(props: IconProps) {
);
}
+export function PlusIcon(props: IconProps) {
+ return (
+
+
+
+ );
+}
+
+export function MinusIcon(props: IconProps) {
+ return (
+
+
+
+ );
+}
+
export function HeartIcon({ filled = false, ...props }: ToggleFillIconProps) {
return (
diff --git a/apps/web/src/store.ts b/apps/web/src/store.ts
index f771f46..a93b3c7 100644
--- a/apps/web/src/store.ts
+++ b/apps/web/src/store.ts
@@ -24,12 +24,18 @@ interface AppState {
savedRecipeIds: string[];
setRecipeSaved: (recipeId: string, saved: boolean) => void;
+
+ userRatings: Record;
+ setUserRating: (recipeId: string, rating: number) => void;
+
+ removeUserRating: (recipeId: string) => void;
}
export const useAppStore = create((set) => ({
search: '',
currentUser: null,
savedRecipeIds: [...INITIAL_SAVED_RECIPE_IDS],
+ userRatings: {},
setSearch: (search) => set({ search }),
@@ -52,6 +58,17 @@ export const useAppStore = create((set) => ({
signOut: () => set({ currentUser: null }),
+ removeUserRating: (recipeId) =>
+ set((state) => {
+ const nextUserRatings = { ...state.userRatings };
+
+ delete nextUserRatings[recipeId];
+
+ return {
+ userRatings: nextUserRatings,
+ };
+ }),
+
setRecipeSaved: (recipeId, saved) =>
set((state) => {
if (saved) {
@@ -72,4 +89,12 @@ export const useAppStore = create((set) => ({
),
};
}),
+
+ setUserRating: (recipeId, rating) =>
+ set((state) => ({
+ userRatings: {
+ ...state.userRatings,
+ [recipeId]: Math.min(5, Math.max(1, Math.round(rating))),
+ },
+ })),
}));
diff --git a/e2e/smoke.spec.ts b/e2e/smoke.spec.ts
index d03c045..dbfa423 100644
--- a/e2e/smoke.spec.ts
+++ b/e2e/smoke.spec.ts
@@ -4,7 +4,7 @@ const coreRoutes = [
['/', 'Explore'],
['/cookbook', 'My Cookbook'],
['/recipes/new', 'Add Recipe'],
- ['/recipes/42', 'Recipe Detail'],
+ ['/recipes/salmon-pasta', 'Creamy salmon pasta'],
['/login', 'Log in'],
['/register', 'Register'],
] as const;