diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx index 8b26f31..eb0b9c4 100644 --- a/apps/web/src/App.tsx +++ b/apps/web/src/App.tsx @@ -13,6 +13,7 @@ import ExplorePage from './features/explore/ExplorePage'; import CookbookPage from './features/cookbook/CookbookPage'; import RecipeCreatePage from './features/recipes/RecipeCreatePage'; import RecipeDetailPage from './features/recipe-detail/RecipeDetailPage'; +import NotFoundPage from './features/not-found/NotFoundPage'; export function App() { const restoreSession = useAppStore((state) => state.restoreSession); @@ -32,6 +33,8 @@ export function App() { } /> } /> } /> + + } /> ); diff --git a/apps/web/src/assets/illustrations/not-found-chef-hat.png b/apps/web/src/assets/illustrations/not-found-chef-hat.png new file mode 100644 index 0000000..e12b2d4 Binary files /dev/null and b/apps/web/src/assets/illustrations/not-found-chef-hat.png differ diff --git a/apps/web/src/features/not-found/NotFoundPage.css b/apps/web/src/features/not-found/NotFoundPage.css new file mode 100644 index 0000000..7423458 --- /dev/null +++ b/apps/web/src/features/not-found/NotFoundPage.css @@ -0,0 +1,108 @@ +@layer components { + .not-found-page { + display: grid; + place-items: center; + + min-height: 72dvh; + padding: var(--space-10) var(--space-4) var(--space-16); + } + + .not-found-page__card { + display: flex; + flex-direction: column; + align-items: center; + + width: min(100%, 39rem); + padding: var(--space-10) var(--space-8) var(--space-8); + + text-align: center; + + background-color: var(--color-surface); + border: var(--border-width-thin) solid var(--color-border-default); + border-radius: var(--radius-xl); + box-shadow: var(--shadow-md); + } + + .not-found-page__illustration { + width: clamp(5rem, 12vw, 7rem); + height: auto; + + margin-block-end: var(--space-3); + + object-fit: contain; + } + + .not-found-page__content { + display: flex; + flex-direction: column; + align-items: center; + gap: var(--space-2); + } + + .not-found-page__code { + margin: 0; + + font-size: clamp(4rem, 9vw, 5.5rem); + font-weight: var(--font-weight-bold); + line-height: 0.95; + letter-spacing: -0.04em; + } + + .not-found-page__title { + margin: 0; + + font-size: var(--font-size-2xl); + font-weight: var(--font-weight-bold); + line-height: var(--line-height-tight); + } + + .not-found-page__description { + margin: 0; + + color: var(--color-text-secondary); + + font-size: var(--font-size-lg); + line-height: var(--line-height-relaxed); + } + + .not-found-page__actions { + display: flex; + justify-content: center; + gap: var(--space-3); + + width: 100%; + margin-block-start: var(--space-6); + } + + .not-found-page__actions > * { + min-width: 9.5rem; + } + + .not-found-page__hint { + margin: var(--space-5) 0 0; + + color: var(--color-text-secondary); + + font-size: var(--font-size-sm); + line-height: var(--line-height-relaxed); + } + + @media (max-width: 36rem) { + .not-found-page { + min-height: auto; + padding-block: var(--space-8) var(--space-12); + } + + .not-found-page__card { + padding: var(--space-8) var(--space-5); + } + + .not-found-page__actions { + flex-direction: column; + } + + .not-found-page__actions > * { + width: 100%; + } + } +} diff --git a/apps/web/src/features/not-found/NotFoundPage.tsx b/apps/web/src/features/not-found/NotFoundPage.tsx new file mode 100644 index 0000000..fe0e204 --- /dev/null +++ b/apps/web/src/features/not-found/NotFoundPage.tsx @@ -0,0 +1,63 @@ +import { useNavigate } from 'react-router-dom'; + +import Button from '../../components/ui/Button/Button'; +import LinkButton from '../../components/ui/LinkButton/LinkButton'; +import chefHatIllustration from '../../assets/illustrations/not-found-chef-hat.png'; + +import './NotFoundPage.css'; + +function NotFoundPage() { + const navigate = useNavigate(); + + function handleGoBack() { + navigate(-1); + } + + return ( +
+
+ + +
+ + +

+ Page not found +

+ +

+ The recipe you’re looking for isn’t here. +

+
+ +
+ + Explore Recipes + + + +
+ +

+ Try searching or return to Explore. +

+
+
+ ); +} + +export default NotFoundPage; diff --git a/e2e/smoke.spec.ts b/e2e/smoke.spec.ts index 3802107..2a6e477 100644 --- a/e2e/smoke.spec.ts +++ b/e2e/smoke.spec.ts @@ -66,3 +66,53 @@ test('collapses the header before navigation actions overflow', async ({ await page.evaluate(() => document.documentElement.clientWidth), ); }); + +test('returns to Explore from the global not-found page', async ({ page }) => { + await page.goto('this-route-does-not-exist'); + + await page.getByRole('link', { name: 'Explore Recipes' }).click(); + + await expect( + page.getByRole('heading', { name: 'Explore Recipes' }), + ).toBeVisible(); + + await expect( + page.getByRole('heading', { name: 'Page not found' }), + ).not.toBeVisible(); +}); + +test('Go Back returns to the previous page from the global not-found page', async ({ + page, +}) => { + await page.goto('.'); + + await expect( + page.getByRole('heading', { name: 'Explore Recipes' }), + ).toBeVisible(); + + await page.goto('this-route-does-not-exist'); + + await expect( + page.getByRole('heading', { name: 'Page not found' }), + ).toBeVisible(); + + await page.getByRole('button', { name: 'Go Back' }).click(); + + await expect( + page.getByRole('heading', { name: 'Explore Recipes' }), + ).toBeVisible(); +}); + +test('keeps recipe-specific not-found handling separate from the global 404', async ({ + page, +}) => { + await page.goto('recipes/does-not-exist'); + + await expect( + page.getByRole('heading', { name: 'Recipe not found' }), + ).toBeVisible(); + + await expect( + page.getByRole('heading', { name: 'Page not found' }), + ).not.toBeVisible(); +});