Skip to content

Commit 6e574c2

Browse files
committed
docs: add stories for NoResults component
1 parent 30c245b commit 6e574c2

File tree

1 file changed

+170
-0
lines changed

1 file changed

+170
-0
lines changed
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
import * as icons from "@phosphor-icons/react/dist/ssr";
2+
import type { Meta, StoryObj } from "@storybook/react";
3+
import { fn } from "@storybook/test";
4+
5+
import { iconControl } from "../icon-control.jsx";
6+
import { NoResults as NoResultsComponent } from "./index.jsx";
7+
8+
const meta = {
9+
component: NoResultsComponent,
10+
parameters: {
11+
layout: "fullscreen",
12+
docs: {
13+
description: {
14+
component: `The NoResults component has two modes:
15+
16+
1. **Query Mode**: Pass a \`query\` prop to show search-related no results message
17+
2. **Custom Content Mode**: Pass \`icon\`, \`header\`, and \`body\` props together for custom messaging
18+
19+
You cannot mix props from both modes.`,
20+
},
21+
},
22+
},
23+
argTypes: {
24+
query: {
25+
control: "text",
26+
description: "Search query to display (use this OR custom content props)",
27+
table: {
28+
category: "Query Mode",
29+
type: { summary: "string" },
30+
},
31+
},
32+
icon: {
33+
...iconControl,
34+
description: "Custom icon to display (requires header and body)",
35+
table: {
36+
category: "Custom Content Mode",
37+
},
38+
},
39+
header: {
40+
control: "text",
41+
description: "Custom header text (requires icon and body)",
42+
table: {
43+
category: "Custom Content Mode",
44+
type: { summary: "ReactNode" },
45+
},
46+
},
47+
body: {
48+
control: "text",
49+
description: "Custom body text (requires icon and header)",
50+
table: {
51+
category: "Custom Content Mode",
52+
type: { summary: "ReactNode" },
53+
},
54+
},
55+
variant: {
56+
control: "select",
57+
options: ["success", "error", "warning", "info", "data"],
58+
description: "Visual variant (only applies in custom content mode)",
59+
table: {
60+
category: "Custom Content Mode",
61+
defaultValue: { summary: "info" },
62+
},
63+
},
64+
onClearSearch: {
65+
description: "Callback when clear search button is clicked",
66+
table: {
67+
category: "Common",
68+
},
69+
},
70+
className: {
71+
control: "text",
72+
description: "Additional CSS class name",
73+
table: {
74+
category: "Common",
75+
},
76+
},
77+
},
78+
tags: ["autodocs"],
79+
} satisfies Meta<typeof NoResultsComponent>;
80+
export default meta;
81+
82+
type Story = StoryObj<typeof NoResultsComponent>;
83+
84+
export const WithQuery: Story = {
85+
args: {
86+
query: "bitcoin price feed",
87+
onClearSearch: fn(),
88+
},
89+
};
90+
91+
export const EmptyQuery: Story = {
92+
args: {
93+
query: "",
94+
onClearSearch: fn(),
95+
},
96+
};
97+
98+
export const WithoutClearButton: Story = {
99+
args: {
100+
query: "ethereum",
101+
},
102+
};
103+
104+
export const CustomContent: Story = {
105+
args: {
106+
icon: <icons.Package />,
107+
header: "No products found",
108+
body: "Try adjusting your filters or search terms to find what you're looking for.",
109+
onClearSearch: fn(),
110+
},
111+
};
112+
113+
export const ErrorVariant: Story = {
114+
args: {
115+
icon: <icons.XCircle />,
116+
header: "Failed to load results",
117+
body: "Something went wrong while fetching your data. Please try again later.",
118+
variant: "error",
119+
},
120+
};
121+
122+
export const SuccessVariant: Story = {
123+
args: {
124+
icon: <icons.CheckCircle />,
125+
header: "All tasks completed!",
126+
body: "You've finished all your tasks. Take a break or add new ones.",
127+
variant: "success",
128+
},
129+
};
130+
131+
export const WarningVariant: Story = {
132+
args: {
133+
icon: <icons.Warning />,
134+
header: "No active feeds",
135+
body: "There are currently no active price feeds matching your criteria.",
136+
variant: "warning",
137+
},
138+
};
139+
140+
export const DataVariant: Story = {
141+
args: {
142+
icon: <icons.Database />,
143+
header: "No data available",
144+
body: "Historical data for this time period is not available.",
145+
variant: "data",
146+
},
147+
};
148+
149+
export const EmptyInbox: Story = {
150+
args: {
151+
icon: <icons.Envelope />,
152+
header: "Your inbox is empty",
153+
body: "When you receive messages, they'll appear here.",
154+
},
155+
};
156+
157+
export const NoFavorites: Story = {
158+
args: {
159+
icon: <icons.Star />,
160+
header: "No favorites yet",
161+
body: "Star your favorite items to quickly access them here.",
162+
},
163+
};
164+
165+
export const LongQuery: Story = {
166+
args: {
167+
query: "This is a very long search query that someone might type when looking for something very specific in the application",
168+
onClearSearch: fn(),
169+
},
170+
};

0 commit comments

Comments
 (0)