diff --git a/apps/web/index.html b/apps/web/index.html index 39688cc..98d93bf 100644 --- a/apps/web/index.html +++ b/apps/web/index.html @@ -1,2 +1,12 @@ -
- + + + + + + Recipe Platform + + +
+ + + diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx index 32ca725..8b7e79b 100644 --- a/apps/web/src/App.tsx +++ b/apps/web/src/App.tsx @@ -1,37 +1,35 @@ -import { NavLink, Route, Routes } from 'react-router-dom'; +import { Route, Routes } from 'react-router-dom'; + +import AppShell from './components/shell/AppShell/AppShell'; +import RouteDestination from './components/RouteDestination/RouteDestination'; const pages = [ ['/', 'Explore'], ['/cookbook', 'My Cookbook'], ['/recipes/new', 'Add Recipe'], ] as const; -const Page = ({ title }: { title: string }) => ( -
-

{title}

-
-); export function App() { return ( - <> -
- Recipe Platform - -
- + + }> {pages.map(([path, title]) => ( - } /> + } + /> ))} - } /> - } /> - } /> - - + } + /> + } /> + } + /> + + ); } diff --git a/apps/web/src/components/RouteDestination/RouteDestination.css b/apps/web/src/components/RouteDestination/RouteDestination.css new file mode 100644 index 0000000..b20fd11 --- /dev/null +++ b/apps/web/src/components/RouteDestination/RouteDestination.css @@ -0,0 +1,14 @@ +@layer components { + .route-page { + padding-block: var(--space-8); + } + + .route-page__eyebrow { + margin-bottom: var(--space-3); + color: var(--color-text-accent); + font-size: var(--font-size-sm); + font-weight: var(--font-weight-bold); + letter-spacing: var(--letter-spacing-wide); + text-transform: uppercase; + } +} diff --git a/apps/web/src/components/RouteDestination/RouteDestination.tsx b/apps/web/src/components/RouteDestination/RouteDestination.tsx new file mode 100644 index 0000000..55c8df1 --- /dev/null +++ b/apps/web/src/components/RouteDestination/RouteDestination.tsx @@ -0,0 +1,16 @@ +import './RouteDestination.css'; + +type RouteDestinationProps = { + title: string; +}; + +function RouteDestination({ title }: RouteDestinationProps) { + return ( +
+

Recipe Platform

+

{title}

+
+ ); +} + +export default RouteDestination; diff --git a/apps/web/src/components/shell/AppShell/AppShell.css b/apps/web/src/components/shell/AppShell/AppShell.css new file mode 100644 index 0000000..e945a95 --- /dev/null +++ b/apps/web/src/components/shell/AppShell/AppShell.css @@ -0,0 +1,12 @@ +@layer components { + .app-shell { + min-height: 100dvh; + background: + radial-gradient( + circle at 100% 0%, + color-mix(in srgb, var(--color-brand-accent-soft) 80%, transparent) 0, + transparent 28rem + ), + var(--color-bg-page); + } +} diff --git a/apps/web/src/components/shell/AppShell/AppShell.tsx b/apps/web/src/components/shell/AppShell/AppShell.tsx new file mode 100644 index 0000000..195600a --- /dev/null +++ b/apps/web/src/components/shell/AppShell/AppShell.tsx @@ -0,0 +1,17 @@ +import { Outlet } from 'react-router-dom'; + +import SiteHeader from '../SiteHeader/SiteHeader'; +import './AppShell.css'; + +function AppShell() { + return ( +
+ +
+ +
+
+ ); +} + +export default AppShell; diff --git a/apps/web/src/components/shell/SiteHeader/SiteHeader.css b/apps/web/src/components/shell/SiteHeader/SiteHeader.css new file mode 100644 index 0000000..24cc0f1 --- /dev/null +++ b/apps/web/src/components/shell/SiteHeader/SiteHeader.css @@ -0,0 +1,178 @@ +@layer components { + .site-header { + position: sticky; + z-index: var(--z-sticky); + top: 0; + border-bottom: var(--border-width-thin) solid var(--color-border-divider); + background-color: color-mix(in srgb, var(--color-surface) 94%, transparent); + backdrop-filter: blur(0.75rem); + } + + .site-header__inner { + display: flex; + align-items: center; + gap: var(--space-8); + min-height: 5rem; + } + + .brand { + display: inline-flex; + flex: 0 0 auto; + align-items: center; + gap: var(--space-3); + color: var(--color-text-primary); + font-size: var(--font-size-lg); + font-weight: var(--font-weight-bold); + text-decoration: none; + } + + .brand:hover { + color: var(--color-text-primary); + } + + .brand__mark { + display: grid; + flex: 0 0 auto; + place-items: center; + width: 2.25rem; + height: 2.25rem; + border-radius: var(--radius-md); + color: var(--color-text-inverse); + background-color: var(--color-brand-primary); + font-family: Georgia, serif; + font-size: var(--font-size-xl); + } + + .site-header__controls { + display: flex; + flex: 1 1 auto; + align-items: center; + justify-content: space-between; + gap: var(--space-6); + min-width: 0; + } + + .primary-navigation, + .account-navigation { + display: flex; + align-items: center; + gap: var(--space-2); + } + + .primary-navigation__link, + .account-navigation__link, + .account-navigation__register { + display: inline-flex; + align-items: center; + min-height: var(--target-size-min); + gap: var(--space-2); + padding: var(--space-2) var(--space-3); + border: var(--border-width-thin) solid transparent; + border-radius: var(--radius-md); + color: var(--color-text-secondary); + font-size: var(--font-size-sm); + font-weight: var(--font-weight-semibold); + text-decoration: none; + white-space: nowrap; + transition: + color var(--duration-fast) var(--ease-standard), + background-color var(--duration-fast) var(--ease-standard), + border-color var(--duration-fast) var(--ease-standard); + } + + .primary-navigation__link:hover, + .account-navigation__link:hover { + color: var(--color-text-primary); + background-color: var(--color-surface-hover); + } + + .primary-navigation__link--active, + .account-navigation__link--active { + color: var(--color-brand-primary-active); + background-color: var(--color-surface-selected); + border-color: var(--color-brand-primary); + } + + .primary-navigation__link--active:hover, + .account-navigation__link--active:hover { + color: var(--color-brand-primary-active); + background-color: var(--color-surface-pressed); + } + + .account-navigation__register { + color: var(--color-text-inverse); + background-color: var(--color-brand-primary); + } + + .account-navigation__register:hover { + color: var(--color-text-inverse); + background-color: var(--color-brand-primary-hover); + } + + .account-navigation__register--active, + .account-navigation__register--active:hover { + color: var(--color-text-inverse); + background-color: var(--color-brand-primary-active); + border-color: var(--color-brand-primary-active); + } + + .navigation-link__icon { + flex-shrink: 0; + width: var(--icon-size-md); + height: var(--icon-size-md); + } + + .menu-toggle { + display: none; + margin-left: auto; + } + + @media (max-width: 55rem) { + /* Adjust to tune when the burger menu appears */ + .site-header__inner { + flex-wrap: wrap; + gap: 0; + min-height: 5rem; + padding-block: var(--space-3); + } + + .menu-toggle { + display: inline-flex; + } + + .site-header__controls { + display: none; + flex-basis: 100%; + align-items: stretch; + padding-block: var(--space-3) var(--space-2); + border-top: var(--border-width-thin) solid var(--color-border-subtle); + } + + .site-header__controls--open { + display: flex; + flex-direction: column; + } + + .primary-navigation, + .account-navigation { + align-items: stretch; + flex-direction: column; + gap: var(--space-1); + } + + .primary-navigation__link, + .account-navigation__link, + .account-navigation__register { + width: 100%; + } + + .primary-navigation__link, + .account-navigation__link { + justify-content: flex-start; + } + + .account-navigation__register { + justify-content: center; + } + } +} diff --git a/apps/web/src/components/shell/SiteHeader/SiteHeader.tsx b/apps/web/src/components/shell/SiteHeader/SiteHeader.tsx new file mode 100644 index 0000000..4ad8d4b --- /dev/null +++ b/apps/web/src/components/shell/SiteHeader/SiteHeader.tsx @@ -0,0 +1,95 @@ +import { useState } from 'react'; +import { NavLink } from 'react-router-dom'; + +import { AddRecipeIcon, CloseIcon } from '../../../icons/actions'; +import { + CookbookIcon, + HomeIcon, + MenuIcon, + ProfileIcon, +} from '../../../icons/navigation'; +import IconButton from '../../ui/IconButton/IconButton'; +import './SiteHeader.css'; + +const pages = [ + ['/', 'Explore', HomeIcon], + ['/cookbook', 'My Cookbook', CookbookIcon], + ['/recipes/new', 'Add Recipe', AddRecipeIcon], +] as const; + +function SiteHeader() { + const [menuOpen, setMenuOpen] = useState(false); + + const closeMenu = () => setMenuOpen(false); + + return ( +
+
+ + + Recipe Platform + + + setMenuOpen((isOpen) => !isOpen)} + /> + +
+ + +
+
+
+ ); +} + +export default SiteHeader; diff --git a/e2e/smoke.spec.ts b/e2e/smoke.spec.ts index 4a0efc4..a35de19 100644 --- a/e2e/smoke.spec.ts +++ b/e2e/smoke.spec.ts @@ -1,6 +1,59 @@ import { expect, test } from '@playwright/test'; -test('opens the catalog shell', async ({ page }) => { +const coreRoutes = [ + ['/', 'Explore'], + ['/cookbook', 'My Cookbook'], + ['/recipes/new', 'Add Recipe'], + ['/recipes/42', 'Recipe Detail'], + ['/login', 'Login'], + ['/register', 'Register'], +] as const; + +test('renders each core route through the shared shell', async ({ page }) => { + for (const [path, title] of coreRoutes) { + await page.goto(path === '/' ? '.' : path.slice(1)); + await expect(page.getByRole('heading', { name: title })).toBeVisible(); + await expect(page.getByRole('banner')).toBeVisible(); + } +}); + +test('keeps the mobile shell within the viewport and keyboard reachable', async ({ + page, +}) => { + await page.setViewportSize({ width: 390, height: 844 }); await page.goto('.'); - await expect(page.getByRole('heading', { name: 'Explore' })).toBeVisible(); + + expect( + await page.evaluate(() => document.documentElement.scrollWidth), + ).toBeLessThanOrEqual( + await page.evaluate(() => document.documentElement.clientWidth), + ); + + const menuButton = page.getByRole('button', { + name: 'Open navigation menu', + }); + await menuButton.focus(); + await page.keyboard.press('Enter'); + await expect( + page.getByRole('button', { name: 'Close navigation menu' }), + ).toHaveAttribute('aria-expanded', 'true'); + await expect( + page.getByRole('navigation', { name: 'Primary navigation' }), + ).toBeVisible(); +}); + +test('collapses the header before navigation actions overflow', async ({ + page, +}) => { + await page.setViewportSize({ width: 800, height: 844 }); + await page.goto('.'); + + await expect( + page.getByRole('button', { name: 'Open navigation menu' }), + ).toBeVisible(); + expect( + await page.evaluate(() => document.documentElement.scrollWidth), + ).toBeLessThanOrEqual( + await page.evaluate(() => document.documentElement.clientWidth), + ); });