86 lines
2.0 KiB
TypeScript
86 lines
2.0 KiB
TypeScript
import type { Meta, StoryObj } from "@storybook/react";
|
|
import { DemoButton } from "./_demo-primitives.js";
|
|
|
|
const meta: Meta = {
|
|
title: "UI / Feedback / EmptyState",
|
|
};
|
|
|
|
export default meta;
|
|
|
|
type Story = StoryObj;
|
|
|
|
function EmptyState({
|
|
title,
|
|
body,
|
|
action,
|
|
illustration,
|
|
}: {
|
|
title: string;
|
|
body: string;
|
|
action?: React.ReactNode;
|
|
illustration?: React.ReactNode;
|
|
}) {
|
|
return (
|
|
<div
|
|
role="status"
|
|
style={{
|
|
border: "1px dashed var(--color-border)",
|
|
borderRadius: 8,
|
|
padding: 32,
|
|
textAlign: "center",
|
|
display: "flex",
|
|
flexDirection: "column",
|
|
alignItems: "center",
|
|
gap: 12,
|
|
maxWidth: 420,
|
|
color: "var(--color-muted)",
|
|
}}
|
|
>
|
|
{illustration}
|
|
<h3 style={{ margin: 0, fontSize: 18, color: "var(--color-fg)" }}>{title}</h3>
|
|
<p style={{ margin: 0, fontSize: 14 }}>{body}</p>
|
|
{action}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const Inbox = () => (
|
|
<svg width="56" height="56" viewBox="0 0 56 56" aria-hidden focusable="false">
|
|
<rect x="6" y="14" width="44" height="32" rx="4" fill="var(--color-accent)" />
|
|
<path d="M6 28 H20 L24 34 H32 L36 28 H50" stroke="var(--color-fg)" strokeWidth="2" fill="none" />
|
|
</svg>
|
|
);
|
|
|
|
export const NoData: Story = {
|
|
name: "No data",
|
|
render: () => (
|
|
<EmptyState
|
|
illustration={<Inbox />}
|
|
title="No projects yet"
|
|
body="Create your first project to start collaborating with your team."
|
|
action={<DemoButton>Create project</DemoButton>}
|
|
/>
|
|
),
|
|
};
|
|
|
|
export const NoResults: Story = {
|
|
name: "No search results",
|
|
render: () => (
|
|
<EmptyState
|
|
title="No matches for your search"
|
|
body="Try a different keyword or clear the filters to see all items."
|
|
/>
|
|
),
|
|
};
|
|
|
|
export const ErrorState: Story = {
|
|
name: "Error state",
|
|
render: () => (
|
|
<EmptyState
|
|
title="Something went wrong"
|
|
body="We could not load the dashboard. Please try again in a moment."
|
|
action={<DemoButton variant="outline">Retry</DemoButton>}
|
|
/>
|
|
),
|
|
};
|