Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 11 additions & 1 deletion apps/web/src/components/ui/EmptyState/EmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ export type EmptyStateProps = {
action?: ReactNode;
variant?: EmptyStateVariant;
size?: EmptyStateSize;
/**
* Heading level for the title. Defaults to 3 for empty states inside a
* page section. Use 1 when the empty state is the whole page (for example
* "Recipe not found") so the page still has a top-level heading.
* The visual size comes from the size prop, not from the level.
*/
headingLevel?: 1 | 2 | 3 | 4;
};

function EmptyState({
Expand All @@ -25,7 +32,10 @@ function EmptyState({
action,
variant = 'surface',
size = 'md',
headingLevel = 3,
}: EmptyStateProps) {
const Heading = `h${headingLevel}` as const;

return (
<div
className={[
Expand All @@ -48,7 +58,7 @@ function EmptyState({
)}

<div className="empty-state__content">
<h3 className="empty-state__title">{title}</h3>
<Heading className="empty-state__title">{title}</Heading>
{description && (
<p className="empty-state__description">{description}</p>
)}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ The component chooses the matching semantic icon and live-region role.

**Sizes:** `sm | md`.

**Important props:** `icon`, `title`, `description`, `action`.
**Important props:** `icon`, `title`, `description`, `action`, `headingLevel` (default `3`; use `1` when the empty state is the whole page).

```tsx
<EmptyState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ it('treats inaccessible private recipes as unavailable', async () => {
mockRecipeFetch(() => ({ data: { recipe: null } }));
mount();
expect(
await screen.findByRole('heading', { name: 'Recipe not found' }),
await screen.findByRole('heading', { name: 'Recipe not found', level: 1 }),
).toBeTruthy();
});
it('offers owner editing and deletes only after confirmation', async () => {
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/features/recipe-detail/RecipeDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ function RecipeDetailPage() {
<section className="recipe-detail-page recipe-detail-page--not-found">
<EmptyState
icon={EmptyStateIcon}
headingLevel={1}
title="Recipe not found"
description="This recipe does not exist or is not available to you."
action={<LinkButton to="/">Back to Explore</LinkButton>}
Expand Down