Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ 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';
import { devPagesElement } from './dev/devPagesRoute';

export function App() {
const restoreSession = useAppStore((state) => state.restoreSession);
Expand All @@ -39,6 +40,8 @@ export function App() {

<Route path="*" element={<NotFoundPage />} />
</Route>
{/* Design-system review pages; only exists in `npm run dev`. */}
{devPagesElement && <Route path="/dev/*" element={devPagesElement} />}
</Routes>
);
}
13 changes: 11 additions & 2 deletions apps/web/src/components/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,24 @@ The component library is intentionally small and project-specific. Add a new gen

## Visual review

The app currently renders `showcase/UiShowcaseCatalog.tsx`, which displays the component showcases as one long scrollable page. Use it as the primary visual and responsive review surface.
`showcase/UiShowcaseCatalog.tsx` displays the component showcases as one long scrollable page. Use it as the primary visual and responsive review surface. It is mounted on development-only routes (`src/dev/`), so it is never part of the production build.

Run:

```bash
npm run dev
```

Then scroll through the catalog and resize the browser. The showcase is intentionally kept as one page so it is quick to compare components, inspect states, and notice responsive regressions.
Then open `http://localhost:5173/project2/dev/` and choose a page:

| Route | Content |
| ------------------ | ---------------------------------------------- |
| `/dev/ui` | All UI component showcases |
| `/dev/recipe-card` | `RecipeCard` variants (`../recipe/showcase/`) |
| `/dev/styles` | Style guide (`src/styles/style_guide/`) |
| `/dev/style-tests` | Style stress tests (`src/styles/style_tests/`) |

Scroll through the catalog and resize the browser. The showcase is intentionally kept as one page so it is quick to compare components, inspect states, and notice responsive regressions.

Storybook is not currently necessary. The showcase already covers the project's main visual-review need with less setup and maintenance.

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/ui/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The UI folder is a small project-specific component library for the recipe appli

- `src/components/ui/README.md` — human-facing component documentation and usage examples.
- `src/styles/style_guide/SKILL.md` — source of truth for tokens, cascade layers, base styles, utilities, motion, sizing, and global CSS conventions.
- `src/components/ui/showcase/UiShowcaseCatalog.tsx` — primary visual and responsive review surface.
- `src/components/ui/showcase/UiShowcaseCatalog.tsx` — primary visual and responsive review surface, at `/project2/dev/ui` in `npm run dev` (see `src/dev/`).
- `src/components/ui/__tests__/` — intentionally small, behavior-focused test suite.

## Folder responsibilities
Expand Down
7 changes: 0 additions & 7 deletions apps/web/src/data/users.ts

This file was deleted.

67 changes: 67 additions & 0 deletions apps/web/src/dev/DevPages.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Link, Route, Routes } from 'react-router-dom';

import RecipeCardShowcase from '../components/recipe/showcase/RecipeCardShowcase';
import UiShowcaseCatalog from '../components/ui/showcase/UiShowcaseCatalog';
import StylesGuide from '../styles/style_guide/StylesGuide';
import StyleTestSuite from '../styles/style_tests/StyleTestSuite';

/**
* Design-system review pages for development.
*
* Mounted at /dev/* only when Vite runs in development mode (see App.tsx),
* so none of this code is part of the production build. Open
* http://localhost:5173/project2/dev/ while `npm run dev` is running.
*/
const pages = [
{
path: 'ui',
label: 'UI components',
description: 'Every shared component and its states.',
element: <UiShowcaseCatalog />,
},
{
path: 'recipe-card',
label: 'Recipe card',
description: 'RecipeCard variants and edge cases.',
element: <RecipeCardShowcase />,
},
{
path: 'styles',
label: 'Style guide',
description: 'Tokens, typography, layout utilities.',
element: <StylesGuide />,
},
{
path: 'style-tests',
label: 'Style stress tests',
description: 'Long content, states and responsive layouts.',
element: <StyleTestSuite />,
},
];

function DevIndex() {
return (
<main className="container stack">
<h1>Design-system review</h1>
<p>Development-only pages. They are not included in production.</p>
<ul>
{pages.map((page) => (
<li key={page.path}>
<Link to={page.path}>{page.label}</Link> — {page.description}
</li>
))}
</ul>
</main>
);
}

export default function DevPages() {
return (
<Routes>
<Route index element={<DevIndex />} />
{pages.map((page) => (
<Route key={page.path} path={page.path} element={page.element} />
))}
</Routes>
);
}
14 changes: 14 additions & 0 deletions apps/web/src/dev/devPagesRoute.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { lazy, Suspense } from 'react';

/*
* import.meta.env.DEV is replaced with `false` in production builds, so the
* minifier drops this branch and Vite never emits the DevPages chunk.
*/
const DevPages = import.meta.env.DEV ? lazy(() => import('./DevPages')) : null;

/** Element for the /dev/* route, or null outside development. */
export const devPagesElement = DevPages ? (
<Suspense fallback={null}>
<DevPages />
</Suspense>
) : null;
1 change: 0 additions & 1 deletion apps/web/src/features/auth/AuthPages.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ describe('authentication pages', () => {
localStorage.clear();

useAppStore.setState({
search: '',
currentUser: null,
});
});
Expand Down
10 changes: 5 additions & 5 deletions apps/web/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ export type SessionStatus =
// Remove credentials left by the old token-based client during migration.
const LEGACY_TOKEN_KEY = 'recipe-platform-session-token';

/*
* Global client state: only the signed-in user and session status.
* Search, filters, sorting and paging live in the URL (see the
* *UrlState.ts modules), and server data in useRecipeQuery's cache.
*/
interface AppState {
search: string;
currentUser: User | null;
sessionStatus: SessionStatus;
setSearch: (search: string) => void;

login: (email: string, password: string) => Promise<void>;

Expand All @@ -35,12 +38,9 @@ interface AppState {
}

export const useAppStore = create<AppState>((set) => ({
search: '',
currentUser: null,
sessionStatus: 'restoring',

setSearch: (search) => set({ search }),

login: async (email, password) => {
const result = await loginUser(email, password);

Expand Down