|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
16 | 16 |
|
17 |
| -import { Typography } from '@mui/material'; |
18 | 17 | import { Meta, StoryFn } from '@storybook/react';
|
19 |
| -import React from 'react'; |
20 |
| -import { TestContext } from '../../test'; // Adjust path if necessary |
21 |
| -import EmptyContent from './EmptyContent'; // Assuming EmptyContentProps is exported if needed, or define locally |
22 |
| - |
23 |
| -// Define props if not directly exported from EmptyContent.tsx |
24 |
| -// For EmptyContent, it's simple enough that we might not need explicit props interface here. |
25 |
| -// type EmptyContentProps = React.ComponentProps<typeof EmptyContent>; |
| 18 | +import EmptyContent from './EmptyContent'; |
26 | 19 |
|
27 | 20 | export default {
|
28 |
| - title: 'common/EmptyContent', // How it will appear in the Storybook hierarchy |
| 21 | + title: 'Common/EmptyContent', |
29 | 22 | component: EmptyContent,
|
30 |
| - decorators: [ |
31 |
| - // Optional: Wrap with TestContext if your component or its children might need it |
32 |
| - // For EmptyContent, it's probably not strictly necessary but good practice for consistency. |
33 |
| - Story => ( |
34 |
| - <TestContext> |
35 |
| - <Story /> |
36 |
| - </TestContext> |
37 |
| - ), |
38 |
| - ], |
39 | 23 | argTypes: {
|
40 | 24 | color: {
|
41 | 25 | control: 'select',
|
42 |
| - options: [ |
43 |
| - 'textPrimary', |
44 |
| - 'textSecondary', |
45 |
| - 'primary', |
46 |
| - 'secondary', |
47 |
| - 'error', |
48 |
| - 'warning', |
49 |
| - 'info', |
50 |
| - 'success', |
51 |
| - ], |
52 |
| - description: 'The color of the text, using theme palette options.', |
53 |
| - }, |
54 |
| - children: { |
55 |
| - control: 'text', |
56 |
| - description: 'The content to display inside the Empty component.', |
| 26 | + options: ['textPrimary', 'textSecondary', 'error', 'warning', 'info', 'success'], |
57 | 27 | },
|
58 | 28 | },
|
59 |
| -} as Meta<typeof EmptyContent>; |
| 29 | +} as Meta; |
60 | 30 |
|
61 | 31 | const Template: StoryFn<typeof EmptyContent> = args => <EmptyContent {...args} />;
|
62 | 32 |
|
63 |
| -export const DefaultMessage = Template.bind({}); |
64 |
| -DefaultMessage.args = { |
65 |
| - children: 'No items to display.', |
66 |
| -}; |
67 |
| -DefaultMessage.storyName = 'Default Message (string child)'; |
68 |
| - |
69 |
| -export const CustomColor = Template.bind({}); |
70 |
| -CustomColor.args = { |
71 |
| - children: 'This message has a custom color.', |
72 |
| - color: 'primary.main', // Example of using theme palette path |
73 |
| -}; |
74 |
| -CustomColor.storyName = 'Custom Text Color'; |
75 |
| - |
76 |
| -export const ErrorColor = Template.bind({}); |
77 |
| -ErrorColor.args = { |
78 |
| - children: 'An error occurred, nothing to show!', |
79 |
| - color: 'error.main', |
| 33 | +export const Default = Template.bind({}); |
| 34 | +Default.args = { |
| 35 | + children: 'No data to be shown.', |
80 | 36 | };
|
81 |
| -ErrorColor.storyName = 'Error Message Color'; |
82 | 37 |
|
83 |
| -export const WithReactNodeChild = Template.bind({}); |
84 |
| -WithReactNodeChild.args = { |
85 |
| - children: ( |
86 |
| - <> |
87 |
| - <Typography variant="h6">No Data Available</Typography> |
88 |
| - <Typography variant="body2">Please try adjusting your filters or come back later.</Typography> |
89 |
| - </> |
90 |
| - ), |
| 38 | +export const WithCustomColor = Template.bind({}); |
| 39 | +WithCustomColor.args = { |
| 40 | + children: 'No data to be shown.', |
| 41 | + color: 'error', |
91 | 42 | };
|
92 |
| -WithReactNodeChild.storyName = 'With React Node Child'; |
93 | 43 |
|
94 |
| -export const EmptyChildren = Template.bind({}); |
95 |
| -EmptyChildren.args = { |
96 |
| - children: '', // Or simply omit children, as it will render nothing |
| 44 | +export const WithMultipleChildren = Template.bind({}); |
| 45 | +WithMultipleChildren.args = { |
| 46 | + children: ['No data to be shown.', <div key="custom-element">Custom element</div>], |
97 | 47 | };
|
98 |
| -EmptyChildren.storyName = 'Empty Children (renders nothing)'; |
99 | 48 |
|
100 |
| -export const MultipleStringChildren = Template.bind({}); |
101 |
| -MultipleStringChildren.args = { |
102 |
| - children: ( |
103 |
| - <> |
104 |
| - First line of message. |
105 |
| - <br /> |
106 |
| - Second line of message. |
107 |
| - </> |
108 |
| - ), |
| 49 | +export const Empty = Template.bind({}); |
| 50 | +Empty.args = { |
| 51 | + children: '', |
109 | 52 | };
|
110 |
| -MultipleStringChildren.storyName = 'Multiple String Children'; |
0 commit comments