generated from morewings/react-library-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFigure.stories.tsx
123 lines (115 loc) · 3.78 KB
/
Figure.stories.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import type {Meta, StoryObj} from '@storybook/react';
import {Picture} from '@/lib/Picture';
import {Text, Table} from '@/lib/Text';
import {Figure} from './Figure.tsx';
const TableElement = (
<Table>
<thead>
<tr>
<th>Header content 1</th>
<th>Header content 2</th>
<th>Header content 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Body content 1</td>
<td>Body content 2</td>
<td>Body content 3</td>
</tr>
<tr>
<td>Body content 1</td>
<td>Body content 2</td>
<td>Body content 3</td>
</tr>
<tr>
<td>Body content 1</td>
<td>Body content 2</td>
<td>Body content 3</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Footer content 1</td>
<td>Footer content 2</td>
<td>Footer content 3</td>
</tr>
</tfoot>
</Table>
);
const PictureComponent = <Picture width={666} height={332} src="https://picsum.photos/666/333" />;
const meta = {
title: 'Components/Figure',
component: Figure,
parameters: {
// More on how to position stories at: https://storybook.js.org/docs/react/configure/story-layout
layout: 'centered',
},
args: {
caption: 'This is caption!',
position: 'center',
children: PictureComponent,
},
argTypes: {
className: {
table: {
disable: true,
},
},
id: {
table: {
disable: true,
},
},
role: {
table: {
disable: true,
},
},
children: {
options: ['picture', 'table'], // An array of serializable values
mapping: {
picture: PictureComponent,
table: TableElement,
}, // Maps serializable option values to complex arg values
control: {
type: 'radio', // Type 'select' is automatically inferred when 'options' is defined
labels: {
// 'labels' maps option values to string labels
picture: 'With Picture component',
table: 'With Table component',
},
},
},
},
} as Meta<typeof Figure>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Primary: Story = {
render: ({children, ...args}) => {
return <Figure {...args}>{children}</Figure>;
},
args: {},
};
export const WrappedWithText: Story = {
render: ({children, ...args}) => {
return (
<Text>
<p>
It has survived not only five centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets
containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus
PageMaker including versions of Lorem Ipsum.
</p>
<Figure {...args}>{children}</Figure>
<p>
It has survived not only five centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets
containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus
PageMaker including versions of Lorem Ipsum.
</p>
</Text>
);
},
args: {},
};