-
Notifications
You must be signed in to change notification settings - Fork 382
Expand file tree
/
Copy pathToolbar.figma.tsx
More file actions
368 lines (364 loc) · 12.5 KB
/
Toolbar.figma.tsx
File metadata and controls
368 lines (364 loc) · 12.5 KB
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
import figma from '@figma/code-connect';
import {
Badge,
Button,
ButtonVariant,
Divider,
Dropdown,
DropdownItem,
DropdownList,
MenuToggle,
MenuToggleCheckbox,
MenuToggleElement,
OverflowMenu,
OverflowMenuContent,
OverflowMenuControl,
OverflowMenuGroup,
OverflowMenuItem,
Pagination,
SearchInput,
Select,
SelectList,
SelectOption,
Toolbar,
ToolbarItem,
ToolbarContent,
ToolbarFilter,
ToolbarGroup
} from '@patternfly/react-core';
import CloneIcon from '@patternfly/react-icons/dist/esm/icons/clone-icon';
import EditIcon from '@patternfly/react-icons/dist/esm/icons/edit-icon';
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
import SyncIcon from '@patternfly/react-icons/dist/esm/icons/sync-icon';
// Documentation for Toolbar can be found at https://www.patternfly.org/components/toolbar
figma.connect(
Toolbar,
'https://www.figma.com/design/VMEX8Xg2nzhBX8rfBx53jp/PatternFly-6--Components?node-id=8062-17157',
{
props: {
colorVariant: figma.boolean('Transparent Background', {
true: 'no-background',
false: undefined
}),
bulkSelector: figma.boolean('Bulk Selector', {
true: (
<ToolbarItem>
<Dropdown
onSelect={() => {}}
isOpen={false}
onOpenChange={() => {}}
toggle={(toggleRef) => (
<MenuToggle
ref={toggleRef}
isExpanded={false}
onClick={() => {}}
aria-label="Toolbar stacked example split toggle"
splitButtonItems={[
<MenuToggleCheckbox
key="toolbar-stacked-split-button-checkbox-1"
id="toolbar-stacked-split-button-checkbox-1"
aria-label="Select all"
/>
]}
/>
)}
>
<DropdownList>
<DropdownItem value={0} key="action">
Action
</DropdownItem>
<DropdownItem
value={1}
key="link"
to="#default-link2"
// Prevent the default onClick functionality for example purposes
onClick={() => {}}
>
Link
</DropdownItem>
<DropdownItem value={2} isDisabled key="disabled action">
Disabled Action
</DropdownItem>
<DropdownItem value={3} isDisabled key="disabled link" to="#default-link4">
Disabled Link
</DropdownItem>
</DropdownList>
</Dropdown>
</ToolbarItem>
),
false: undefined
}),
filterGroup: figma.boolean('Filter group', {
true: (
<>
<ToolbarFilter
labels={['New', 'Pending', 'Running', 'Cancelled']}
deleteLabel={() => {}}
deleteLabelGroup={() => {}}
categoryName="Status"
>
<Select
aria-label="Status"
role="menu"
toggle={(toggleRef) => (
<MenuToggle
ref={toggleRef}
onClick={() => {}}
isExpanded={false}
style={
{
width: '140px'
} as React.CSSProperties
}
>
Status
{['New', 'Pending'].length > 0 && <Badge isRead>{['New', 'Pending'].length}</Badge>}
</MenuToggle>
)}
onSelect={() => {}}
selected={false}
isOpen={false}
onOpenChange={() => {}}
>
<SelectList>
<SelectOption hasCheckbox key="statusNew" value="New" isSelected={false}>
New
</SelectOption>
<SelectOption hasCheckbox key="statusPending" value="Pending" isSelected={false}>
Pending
</SelectOption>
<SelectOption hasCheckbox key="statusRunning" value="Running" isSelected={false}>
Running
</SelectOption>
<SelectOption hasCheckbox key="statusCancelled" value="Cancelled" isSelected={false}>
Cancelled
</SelectOption>
</SelectList>
</Select>
</ToolbarFilter>
<ToolbarFilter labels={['Low', 'Medium', 'High']} deleteLabel={() => {}} categoryName="Risk">
<Select
aria-label="Risk Filter"
role="menu"
toggle={(toggleRef) => (
<MenuToggle ref={toggleRef} onClick={() => {}} isExpanded={false}>
Risk
</MenuToggle>
)}
onSelect={() => {}}
selected={false}
isOpen={false}
onOpenChange={() => {}}
>
<SelectList>
<SelectOption value="Low">Low</SelectOption>
<SelectOption value="Medium">Medium</SelectOption>
<SelectOption value="High">High</SelectOption>
</SelectList>
</Select>
</ToolbarFilter>
</>
),
false: undefined
}),
searchFilter: figma.boolean('Search filter', {
true: (
<ToolbarItem>
<SearchInput aria-label="Search filter input" onChange={() => {}} value={''} onClear={() => {}} />
</ToolbarItem>
),
false: undefined
}),
iconButtonGroup: figma.boolean('Icon button group', {
true: (
<ToolbarGroup variant="action-group-plain">
<ToolbarItem>
<Button variant="plain" aria-label="edit" icon={<EditIcon />} />
</ToolbarItem>
<ToolbarItem>
<Button variant="plain" aria-label="clone" icon={<CloneIcon />} />
</ToolbarItem>
<ToolbarItem>
<Button variant="plain" aria-label="sync" icon={<SyncIcon />} />
</ToolbarItem>
</ToolbarGroup>
),
false: undefined
}),
verticalDivider: figma.boolean('Vertical divider', {
true: <ToolbarItem variant="separator" />,
false: undefined
}),
buttonGroup: figma.boolean('Button group', {
true: (
<>
<ToolbarItem>
<Button variant="primary">Button</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Button</Button>
</ToolbarItem>
</>
),
false: undefined
}),
linkButtons: figma.boolean('Link buttons', {
true: (
<>
<ToolbarItem>
<Button icon={<PlusCircleIcon />} variant="link">
Button
</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="link">Button</Button>
</ToolbarItem>
</>
),
false: undefined
}),
overflowMenu: figma.boolean('Overflow menu', {
true: (
<ToolbarItem>
<OverflowMenu breakpoint="2xl">
<OverflowMenuContent>
<OverflowMenuGroup groupType="button">
<OverflowMenuItem>
<Button variant={ButtonVariant.primary}>Primary</Button>
</OverflowMenuItem>
<OverflowMenuItem>
<Button variant={ButtonVariant.secondary}>Secondary</Button>
</OverflowMenuItem>
</OverflowMenuGroup>
</OverflowMenuContent>
<OverflowMenuControl hasAdditionalOptions>
<Dropdown
onSelect={() => {}}
onOpenChange={() => {}}
toggle={(toggleRef) => (
<MenuToggle
ref={toggleRef}
aria-label="Kebab overflow menu"
variant="plain"
onClick={() => {}}
isExpanded={false}
icon={<EllipsisVIcon />}
/>
)}
isOpen={false}
>
<DropdownList>
<DropdownItem>Action</DropdownItem>
<DropdownItem
to="#link"
// Prevent the default onClick functionality for example purposes
onClick={() => {}}
>
Link
</DropdownItem>
<DropdownItem isDisabled>Disabled Action</DropdownItem>
<DropdownItem isDisabled to="#link">
Disabled Link
</DropdownItem>
</DropdownList>
</Dropdown>
</OverflowMenuControl>
</OverflowMenu>
</ToolbarItem>
),
false: undefined
}),
pagination: figma.boolean('Pagination', {
true: (
<ToolbarItem variant="pagination" align={{ default: 'alignEnd' }}>
<Pagination itemCount={523} perPage={20} page={1} onSetPage={() => {}} onPerPageSelect={() => {}} />
</ToolbarItem>
),
false: undefined
}),
filterChips: figma.boolean('Filter chips', {
true: (
<>
<Divider />
<ToolbarContent>
<ToolbarGroup variant="filter-group">
<ToolbarFilter
labels={['New', 'Pending']}
deleteLabel={() => {}}
deleteLabelGroup={() => {}}
categoryName="Status"
>
<Select
aria-label="Status"
role="menu"
toggle={(toggleRef) => (
<MenuToggle ref={toggleRef} onClick={() => {}} isExpanded={false}>
Status
{['New', 'Pending'].length > 0 && <Badge isRead>{['New', 'Pending'].length}</Badge>}
</MenuToggle>
)}
onSelect={() => {}}
selected={['New', 'Pending']}
isOpen={false}
onOpenChange={() => {}}
>
{statusMenuItems}
</Select>
</ToolbarFilter>
<ToolbarFilter
labels={filters.risk}
deleteLabel={(category, label) => onDelete(category as string, label as string)}
categoryName="Risk"
>
<Select
aria-label="Risk"
role="menu"
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
<MenuToggle
ref={toggleRef}
onClick={onRiskToggle}
isExpanded={isRiskExpanded}
style={
{
width: '140px'
} as React.CSSProperties
}
>
Risk
{filters.risk.length > 0 && <Badge isRead>{filters.risk.length}</Badge>}
</MenuToggle>
)}
onSelect={onRiskSelect}
selected={filters.risk}
isOpen={isRiskExpanded}
onOpenChange={(isOpen) => setIsRiskExpanded(isOpen)}
>
{riskMenuItems}
</Select>
</ToolbarFilter>
</ToolbarGroup>
</ToolbarContent>
</>
),
false: undefined
})
},
example: (props) => (
<Toolbar colorVariant={props.colorVariant}>
<ToolbarContent>
{props.bulkSelector}
{props.filterGroup}
{props.searchFilter}
{props.iconButtonGroup}
{props.verticalDivider}
{props.buttonGroup}
{props.linkButtons}
{props.overflowMenu}
{props.pagination}
</ToolbarContent>
{props.filterChips}
</Toolbar>
)
}
);