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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
import type { ComponentMeta, ComponentStory } from '@storybook/react';
import { List, type ListProps } from './list';
import { ListItem } from './list-item';
/**
* List - Storybook Meta
*/
export default {
title: 'Atoms/Lists',
component: List,
args: {},
argTypes: {
className: {
control: {
type: 'text',
},
description: 'Set additional classnames to the list wrapper',
table: {
category: 'Styles',
},
type: {
name: 'string',
required: false,
},
},
},
} as ComponentMeta<typeof List>;
const Template: ComponentStory<typeof List> = <
O extends boolean,
H extends boolean,
>(
args: ListProps<O, H>
) => <List {...args} />;
/**
* List Stories - Hierarchical list
*/
export const Hierarchical = Template.bind({});
Hierarchical.args = {
children: [
<ListItem key="item-1">
Item 1
<List isHierarchical isOrdered>
<ListItem>Subitem 1</ListItem>
<ListItem>Subitem 2</ListItem>
</List>
</ListItem>,
<ListItem key="item-2">
Item 2
<List isHierarchical isOrdered>
<ListItem>Subitem 1</ListItem>
<ListItem>
Subitem 2
<List isHierarchical isOrdered>
<ListItem>Nested item 1</ListItem>
<ListItem>Nested item 2</ListItem>
</List>
</ListItem>
<ListItem>Subitem 3</ListItem>
</List>
</ListItem>,
<ListItem key="item-3">Item 3</ListItem>,
],
isHierarchical: true,
};
/**
* List Stories - Ordered list
*/
export const Ordered = Template.bind({});
Ordered.args = {
children: [
<ListItem key="item-1">
Item 1
<List isOrdered>
<ListItem>Subitem 1</ListItem>
<ListItem>Subitem 2</ListItem>
</List>
</ListItem>,
<ListItem key="item-2">
Item 2
<List isOrdered>
<ListItem>Subitem 1</ListItem>
<ListItem>
Subitem 2
<List isOrdered>
<ListItem>Nested item 1</ListItem>
<ListItem>Nested item 2</ListItem>
</List>
</ListItem>
<ListItem>Subitem 3</ListItem>
</List>
</ListItem>,
<ListItem key="item-3">Item 3</ListItem>,
],
isOrdered: true,
};
/**
* List Stories - Unordered list
*/
export const Unordered = Template.bind({});
Unordered.args = {
children: [
<ListItem key="item-1">
Item 1
<List>
<ListItem>Subitem 1</ListItem>
<ListItem>Subitem 2</ListItem>
</List>
</ListItem>,
<ListItem key="item-2">
Item 2
<List isOrdered>
<ListItem>Subitem 1</ListItem>
<ListItem>
Subitem 2
<List>
<ListItem>Nested item 1</ListItem>
<ListItem>Nested item 2</ListItem>
</List>
</ListItem>
<ListItem>Subitem 3</ListItem>
</List>
</ListItem>,
<ListItem key="item-3">Item 3</ListItem>,
],
};
const items = [
{ id: 'item-1', label: 'Item 1' },
{ id: 'item-2', label: 'Item 2' },
{
id: 'item-3',
label: (
<>
Item 3
<List>
<ListItem>Subitem 1</ListItem>
<ListItem>Subitem 2</ListItem>
</List>
</>
),
},
{ id: 'item-4', label: 'Item 4' },
{ id: 'item-5', label: 'Item 5' },
];
/**
* List Stories - Inline and ordered list
*/
export const InlineOrdered = Template.bind({});
InlineOrdered.args = {
children: items.map((item) => (
<ListItem key={item.id}>{item.label}</ListItem>
)),
isInline: true,
isOrdered: true,
spacing: 'sm',
};
/**
* List Stories - Inline and unordered list
*/
export const InlineUnordered = Template.bind({});
InlineUnordered.args = {
children: items.map((item) => (
<ListItem key={item.id}>{item.label}</ListItem>
)),
isInline: true,
spacing: 'sm',
};
/**
* List Stories - Ordered list without marker
*/
export const OrderedHideMarker = Template.bind({});
OrderedHideMarker.args = {
children: items.map((item) => (
<ListItem key={item.id}>{item.label}</ListItem>
)),
hideMarker: true,
isOrdered: true,
};
/**
* List Stories - Unordered list without marker
*/
export const UnorderedHideMarker = Template.bind({});
UnorderedHideMarker.args = {
children: items.map((item) => (
<ListItem key={item.id}>{item.label}</ListItem>
)),
hideMarker: true,
};
|