@agregio-solutions/design-system 1.90.1 → 1.92.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/design-system.cjs +9 -5
- package/dist/design-system.js +14 -6
- package/dist/packages/components/Accordion/doc.md +342 -0
- package/dist/packages/components/Badge/doc.md +192 -0
- package/dist/packages/components/Breadcrumbs/doc.md +332 -0
- package/dist/packages/components/Button/doc.md +425 -0
- package/dist/packages/components/Calendar/doc.md +465 -0
- package/dist/packages/components/ChartLegend/doc.md +151 -0
- package/dist/packages/components/ChartTooltip/doc.md +124 -0
- package/dist/packages/components/Checkbox/doc.md +329 -0
- package/dist/packages/components/CheckboxGroup/doc.md +242 -0
- package/dist/packages/components/Chip/doc.md +99 -0
- package/dist/packages/components/Combobox/Combobox.d.ts +8 -0
- package/dist/packages/components/Combobox/doc.md +680 -0
- package/dist/packages/components/DataTable/doc.md +1124 -0
- package/dist/packages/components/DatePicker/doc.md +579 -0
- package/dist/packages/components/DateRangePicker/doc.md +638 -0
- package/dist/packages/components/Drawer/doc.md +338 -0
- package/dist/packages/components/Dropdown/Dropdown.d.ts +4 -0
- package/dist/packages/components/Dropdown/doc.md +205 -0
- package/dist/packages/components/EmptyState/doc.md +101 -0
- package/dist/packages/components/FileUpload/doc.md +449 -0
- package/dist/packages/components/Filter/doc.md +196 -0
- package/dist/packages/components/Header/doc.md +373 -0
- package/dist/packages/components/I18nProvider/doc.md +187 -0
- package/dist/packages/components/Icon/doc.md +63 -0
- package/dist/packages/components/Label/doc.md +60 -0
- package/dist/packages/components/LinearProgressBar/doc.md +148 -0
- package/dist/packages/components/Link/doc.md +206 -0
- package/dist/packages/components/List/doc.md +481 -0
- package/dist/packages/components/Loader/doc.md +53 -0
- package/dist/packages/components/Menu/Menu.d.ts +5 -1
- package/dist/packages/components/Menu/doc.md +231 -0
- package/dist/packages/components/Message/doc.md +166 -0
- package/dist/packages/components/Modal/doc.md +289 -0
- package/dist/packages/components/Navigation/doc.md +992 -0
- package/dist/packages/components/NavigationItem/doc.md +167 -0
- package/dist/packages/components/NotificationCard/doc.md +206 -0
- package/dist/packages/components/Notifications/doc.md +240 -0
- package/dist/packages/components/NumberField/doc.md +582 -0
- package/dist/packages/components/PageLayout/doc.md +651 -0
- package/dist/packages/components/Pagination/doc.md +227 -0
- package/dist/packages/components/Popover/doc.md +245 -0
- package/dist/packages/components/Radio/doc.md +370 -0
- package/dist/packages/components/RouterProvider/doc.md +64 -0
- package/dist/packages/components/SearchBar/doc.md +504 -0
- package/dist/packages/components/SegmentedControl/doc.md +398 -0
- package/dist/packages/components/Select/Select.d.ts +4 -0
- package/dist/packages/components/Select/doc.md +1133 -0
- package/dist/packages/components/Skeleton/doc.md +129 -0
- package/dist/packages/components/Slider/doc.md +362 -0
- package/dist/packages/components/Stepper/doc.md +104 -0
- package/dist/packages/components/Switch/doc.md +296 -0
- package/dist/packages/components/Tabs/doc.md +295 -0
- package/dist/packages/components/Tag/doc.md +81 -0
- package/dist/packages/components/TextInput/doc.md +490 -0
- package/dist/packages/components/TimeField/doc.md +353 -0
- package/dist/packages/components/Timeline/doc.md +1046 -0
- package/dist/packages/components/Toaster/doc.md +263 -0
- package/dist/packages/components/ToggleButton/doc.md +108 -0
- package/dist/packages/components/ToggleButtonGroup/doc.md +307 -0
- package/dist/packages/components/Tooltip/doc.md +206 -0
- package/dist/packages/components/YearMonthPicker/YearMonthPicker.d.ts +8 -0
- package/dist/packages/components/YearMonthPicker/doc.md +638 -0
- package/dist/public_docs/components.md +68 -0
- package/dist/public_docs/index.md +30 -0
- package/dist/public_docs/tokens.md +121 -0
- package/package.json +3 -2
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
# Button
|
|
2
|
+
|
|
3
|
+
## Props
|
|
4
|
+
|
|
5
|
+
The complete Props documentation with JS doc for this component is available at this path:
|
|
6
|
+
|
|
7
|
+
node_modules/@agregio-solutions/design-system/dist/packages/components/Button/Button.d.ts
|
|
8
|
+
|
|
9
|
+
## Example usage
|
|
10
|
+
|
|
11
|
+
Here are the Storybook Stories.
|
|
12
|
+
|
|
13
|
+
Base stories:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Fragment } from "react";
|
|
17
|
+
import { Meta, StoryObj } from "@storybook/react-vite";
|
|
18
|
+
import { userEvent, within, waitFor, expect, fn } from "storybook/test";
|
|
19
|
+
|
|
20
|
+
import Button, { Props } from "./Button";
|
|
21
|
+
import ErrorBoundary from "@packages/internal-components/ErrorBoundary/ErrorBoundary";
|
|
22
|
+
import { ICON_NAMES_ARRAY } from "@components/Icon/Icon";
|
|
23
|
+
|
|
24
|
+
const meta: Meta<typeof Button> = {
|
|
25
|
+
component: Button,
|
|
26
|
+
argTypes: {
|
|
27
|
+
text: { type: "string" },
|
|
28
|
+
iconLeft: {
|
|
29
|
+
options: ["", ...ICON_NAMES_ARRAY],
|
|
30
|
+
},
|
|
31
|
+
iconRight: {
|
|
32
|
+
options: ["", ...ICON_NAMES_ARRAY],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
parameters: {
|
|
36
|
+
layout: "centered",
|
|
37
|
+
},
|
|
38
|
+
decorators: [(story) => <ErrorBoundary>{story()}</ErrorBoundary>],
|
|
39
|
+
};
|
|
40
|
+
export default meta;
|
|
41
|
+
|
|
42
|
+
export const Playground: StoryObj<typeof Button> = {
|
|
43
|
+
args: {
|
|
44
|
+
text: "[Insert name]",
|
|
45
|
+
size: "medium",
|
|
46
|
+
mode: "primary",
|
|
47
|
+
nature: "action",
|
|
48
|
+
onClick: fn(),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const Clicked: StoryObj<typeof Button> = {
|
|
53
|
+
args: {
|
|
54
|
+
...Playground.args,
|
|
55
|
+
},
|
|
56
|
+
play: async ({ canvasElement, args }) => {
|
|
57
|
+
const canvas = within(canvasElement);
|
|
58
|
+
const user = userEvent.setup({ delay: 50 });
|
|
59
|
+
await user.click(canvas.getByText("[Insert name]"));
|
|
60
|
+
await waitFor(() => expect(args.onClick).toHaveBeenCalledTimes(1));
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const Primary: StoryObj<typeof Button> = {
|
|
65
|
+
args: {
|
|
66
|
+
...Playground.args,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const Hover: StoryObj<typeof Button> = {
|
|
71
|
+
args: {
|
|
72
|
+
...Playground.args,
|
|
73
|
+
// @ts-ignore
|
|
74
|
+
"data-force-hovered": true,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const Focus: StoryObj<typeof Button> = {
|
|
79
|
+
args: {
|
|
80
|
+
...Playground.args,
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
"data-force-focus-visible": true,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const Active: StoryObj<typeof Button> = {
|
|
87
|
+
args: {
|
|
88
|
+
...Playground.args,
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
"data-force-pressed": true,
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const Disabled: StoryObj<typeof Button> = {
|
|
95
|
+
args: {
|
|
96
|
+
...Playground.args,
|
|
97
|
+
disabled: true,
|
|
98
|
+
mode: "primary",
|
|
99
|
+
},
|
|
100
|
+
play: async ({ canvasElement, args }) => {
|
|
101
|
+
const canvas = within(canvasElement);
|
|
102
|
+
const user = userEvent.setup({ delay: 50 });
|
|
103
|
+
await user.click(canvas.getByText("[Insert name]"));
|
|
104
|
+
await waitFor(() => expect(args.onClick).toHaveBeenCalledTimes(0));
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const Loading: StoryObj<typeof Button> = {
|
|
109
|
+
args: {
|
|
110
|
+
...Playground.args,
|
|
111
|
+
isLoading: true,
|
|
112
|
+
mode: "primary",
|
|
113
|
+
},
|
|
114
|
+
play: async ({ canvasElement, args }) => {
|
|
115
|
+
const canvas = within(canvasElement);
|
|
116
|
+
const user = userEvent.setup({ delay: 50 });
|
|
117
|
+
await user.click(canvas.getByText("[Insert name]"));
|
|
118
|
+
await waitFor(() => expect(args.onClick).toHaveBeenCalledTimes(0));
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const Informative: StoryObj<typeof Button> = {
|
|
123
|
+
args: {
|
|
124
|
+
...Playground.args,
|
|
125
|
+
nature: "informative",
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export const Negative: StoryObj<typeof Button> = {
|
|
130
|
+
args: {
|
|
131
|
+
...Playground.args,
|
|
132
|
+
nature: "negative",
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const Positive: StoryObj<typeof Button> = {
|
|
137
|
+
args: {
|
|
138
|
+
...Playground.args,
|
|
139
|
+
nature: "positive",
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const Warning: StoryObj<typeof Button> = {
|
|
144
|
+
args: {
|
|
145
|
+
...Playground.args,
|
|
146
|
+
nature: "warning",
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const FullWidth: StoryObj<typeof Button> = {
|
|
151
|
+
args: {
|
|
152
|
+
...Playground.args,
|
|
153
|
+
fullWidth: true,
|
|
154
|
+
},
|
|
155
|
+
decorators: [
|
|
156
|
+
(Story) => (
|
|
157
|
+
<div style={{ width: "400px" }}>
|
|
158
|
+
<Story />
|
|
159
|
+
</div>
|
|
160
|
+
),
|
|
161
|
+
],
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export const WithIconLeft: StoryObj<typeof Button> = {
|
|
165
|
+
args: {
|
|
166
|
+
...Playground.args,
|
|
167
|
+
iconLeft: "access_time",
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export const WithIconRight: StoryObj<typeof Button> = {
|
|
172
|
+
args: {
|
|
173
|
+
...Playground.args,
|
|
174
|
+
iconRight: "access_time",
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export const WithOnlyIcon: StoryObj<typeof Button> = {
|
|
179
|
+
args: {
|
|
180
|
+
...Playground.args,
|
|
181
|
+
text: undefined,
|
|
182
|
+
iconRight: "access_time",
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export const WithTooltip: StoryObj<typeof Button> = {
|
|
187
|
+
args: {
|
|
188
|
+
...Playground.args,
|
|
189
|
+
tooltip: "Tooltip",
|
|
190
|
+
tooltipProps: {
|
|
191
|
+
defaultOpen: true,
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export const WithBadge: StoryObj<typeof Button> = {
|
|
197
|
+
args: {
|
|
198
|
+
...Playground.args,
|
|
199
|
+
text: undefined,
|
|
200
|
+
iconLeft: "notifications_none",
|
|
201
|
+
mode: "tertiary",
|
|
202
|
+
badgeProps: {
|
|
203
|
+
nature: "negative",
|
|
204
|
+
variant: "dot",
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export const All: StoryObj<typeof Button> = {
|
|
210
|
+
parameters: {
|
|
211
|
+
a11y: { disable: true },
|
|
212
|
+
},
|
|
213
|
+
decorators: [
|
|
214
|
+
() => (
|
|
215
|
+
<ShowcaseAllVariationsGrid
|
|
216
|
+
renderContent={(props) => (
|
|
217
|
+
<>
|
|
218
|
+
<Button {...props} />
|
|
219
|
+
<Button {...props} data-force-hovered />
|
|
220
|
+
<Button {...props} data-force-focus-visible />
|
|
221
|
+
<Button {...props} data-force-pressed />
|
|
222
|
+
<Button {...props} disabled />
|
|
223
|
+
<Button {...props} isLoading />
|
|
224
|
+
</>
|
|
225
|
+
)}
|
|
226
|
+
/>
|
|
227
|
+
),
|
|
228
|
+
],
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export const AllAsLink: StoryObj<typeof Button> = {
|
|
232
|
+
parameters: {
|
|
233
|
+
a11y: { disable: true },
|
|
234
|
+
},
|
|
235
|
+
decorators: [
|
|
236
|
+
() => (
|
|
237
|
+
<ShowcaseAllVariationsGrid
|
|
238
|
+
renderContent={(props) => (
|
|
239
|
+
<>
|
|
240
|
+
<Button {...props} href="/link" />
|
|
241
|
+
<Button {...props} href="/link" target="_blank" />
|
|
242
|
+
<Button {...props} href="/link" data-force-hovered />
|
|
243
|
+
<Button {...props} href="/link" data-force-focus-visible />
|
|
244
|
+
<Button {...props} href="/link" data-force-pressed />
|
|
245
|
+
<Button {...props} href="/link" disabled />
|
|
246
|
+
<Button {...props} href="/link" isLoading />
|
|
247
|
+
</>
|
|
248
|
+
)}
|
|
249
|
+
/>
|
|
250
|
+
),
|
|
251
|
+
],
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
const ShowcaseAllVariationsGrid = ({
|
|
255
|
+
renderContent,
|
|
256
|
+
}: {
|
|
257
|
+
renderContent: (props: Props) => React.ReactNode;
|
|
258
|
+
}) => {
|
|
259
|
+
return (
|
|
260
|
+
<div>
|
|
261
|
+
{["action", "informative", "negative", "positive", "warning"].map(
|
|
262
|
+
(nature) => (
|
|
263
|
+
<div key={nature} style={{ marginTop: 16 }}>
|
|
264
|
+
<h1>{nature}</h1>
|
|
265
|
+
{["primary", "secondary", "tertiary"].map((mode) => (
|
|
266
|
+
<Fragment key={mode}>
|
|
267
|
+
<h2>{mode}</h2>
|
|
268
|
+
<div key={mode}>
|
|
269
|
+
{["text", "iconLeft", "iconRight", "icon"].map(
|
|
270
|
+
(textOrIcon) => {
|
|
271
|
+
return (
|
|
272
|
+
<div
|
|
273
|
+
key={textOrIcon}
|
|
274
|
+
style={{
|
|
275
|
+
display: "grid",
|
|
276
|
+
gridTemplateColumns: "repeat(3, minmax(0, 1fr))",
|
|
277
|
+
columnGap: 8,
|
|
278
|
+
marginTop: 16,
|
|
279
|
+
}}
|
|
280
|
+
>
|
|
281
|
+
{["small", "medium", "large"].map((size) => {
|
|
282
|
+
const props: Props = {
|
|
283
|
+
mode: mode as Props["mode"],
|
|
284
|
+
size: size as Props["size"],
|
|
285
|
+
nature: nature as Props["nature"],
|
|
286
|
+
text:
|
|
287
|
+
textOrIcon !== "icon"
|
|
288
|
+
? "[Insert name]"
|
|
289
|
+
: undefined,
|
|
290
|
+
iconLeft:
|
|
291
|
+
textOrIcon === "iconLeft"
|
|
292
|
+
? "access_time"
|
|
293
|
+
: undefined,
|
|
294
|
+
iconRight:
|
|
295
|
+
textOrIcon === "iconRight" ||
|
|
296
|
+
textOrIcon === "icon"
|
|
297
|
+
? "access_time"
|
|
298
|
+
: undefined,
|
|
299
|
+
};
|
|
300
|
+
return (
|
|
301
|
+
<div
|
|
302
|
+
key={size}
|
|
303
|
+
style={{
|
|
304
|
+
display: "flex",
|
|
305
|
+
flexDirection: "column",
|
|
306
|
+
alignItems: "center",
|
|
307
|
+
gap: 12,
|
|
308
|
+
}}
|
|
309
|
+
>
|
|
310
|
+
{renderContent(props)}
|
|
311
|
+
</div>
|
|
312
|
+
);
|
|
313
|
+
})}
|
|
314
|
+
</div>
|
|
315
|
+
);
|
|
316
|
+
},
|
|
317
|
+
)}
|
|
318
|
+
</div>
|
|
319
|
+
</Fragment>
|
|
320
|
+
))}
|
|
321
|
+
</div>
|
|
322
|
+
),
|
|
323
|
+
)}
|
|
324
|
+
</div>
|
|
325
|
+
);
|
|
326
|
+
};
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## How to test this component
|
|
330
|
+
|
|
331
|
+
Here are some more advanced stories with more testing coverage and examples that you can read to understand how to test this component.
|
|
332
|
+
|
|
333
|
+
```tsx
|
|
334
|
+
import { Meta, StoryObj } from "@storybook/react-vite";
|
|
335
|
+
import { within, expect } from "storybook/test";
|
|
336
|
+
|
|
337
|
+
import Button from "../Button";
|
|
338
|
+
import ErrorBoundary from "@packages/internal-components/ErrorBoundary/ErrorBoundary";
|
|
339
|
+
import { ICON_NAMES_ARRAY } from "@components/Icon/Icon";
|
|
340
|
+
import { Playground } from "../Button.stories";
|
|
341
|
+
|
|
342
|
+
const meta: Meta<typeof Button> = {
|
|
343
|
+
component: Button,
|
|
344
|
+
argTypes: {
|
|
345
|
+
text: { type: "string" },
|
|
346
|
+
iconLeft: {
|
|
347
|
+
options: ["", ...ICON_NAMES_ARRAY],
|
|
348
|
+
},
|
|
349
|
+
iconRight: {
|
|
350
|
+
options: ["", ...ICON_NAMES_ARRAY],
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
parameters: {
|
|
354
|
+
layout: "centered",
|
|
355
|
+
chromatic: { disableSnapshot: true },
|
|
356
|
+
},
|
|
357
|
+
decorators: [(story) => <ErrorBoundary>{story()}</ErrorBoundary>],
|
|
358
|
+
};
|
|
359
|
+
export default meta;
|
|
360
|
+
|
|
361
|
+
export const NoTextNorIcon: StoryObj<typeof Button> = {
|
|
362
|
+
args: {
|
|
363
|
+
...Playground.args,
|
|
364
|
+
text: undefined,
|
|
365
|
+
},
|
|
366
|
+
play: async ({ canvasElement }) => {
|
|
367
|
+
const canvas = within(canvasElement);
|
|
368
|
+
await canvas.findByText("Error: You must provide a text or an icon");
|
|
369
|
+
},
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
export const NoDoubleIcons: StoryObj<typeof Button> = {
|
|
373
|
+
args: {
|
|
374
|
+
...Playground.args,
|
|
375
|
+
iconLeft: "access_time",
|
|
376
|
+
iconRight: "access_time",
|
|
377
|
+
},
|
|
378
|
+
play: async ({ canvasElement }) => {
|
|
379
|
+
const canvas = within(canvasElement);
|
|
380
|
+
await canvas.findByText(
|
|
381
|
+
"Error: You can't provide both an iconLeft and an iconRight",
|
|
382
|
+
);
|
|
383
|
+
},
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
export const LinkWithTarget: StoryObj<typeof Button> = {
|
|
387
|
+
args: {
|
|
388
|
+
...Playground.args,
|
|
389
|
+
href: "/link",
|
|
390
|
+
target: "_blank",
|
|
391
|
+
},
|
|
392
|
+
play: async ({ canvasElement }) => {
|
|
393
|
+
const canvas = within(canvasElement);
|
|
394
|
+
const linkElement = (await canvas.findByText("[Insert name]")).closest("a");
|
|
395
|
+
await expect(linkElement).toHaveAttribute("href", "/link");
|
|
396
|
+
await expect(linkElement).toHaveAttribute("target", "_blank");
|
|
397
|
+
},
|
|
398
|
+
};
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
## Developer notes
|
|
402
|
+
|
|
403
|
+
Here are the notes available for the developer on the built Storybook, you can read them to understand the component and how to use it.
|
|
404
|
+
|
|
405
|
+
```mdx
|
|
406
|
+
import {
|
|
407
|
+
Canvas,
|
|
408
|
+
Controls,
|
|
409
|
+
Meta,
|
|
410
|
+
Source,
|
|
411
|
+
Stories,
|
|
412
|
+
} from "@storybook/addon-docs/blocks";
|
|
413
|
+
|
|
414
|
+
import * as Button from "./Button.stories";
|
|
415
|
+
|
|
416
|
+
<Meta of={Button} />
|
|
417
|
+
|
|
418
|
+
# Button
|
|
419
|
+
|
|
420
|
+
<Canvas of={Button.Playground} />
|
|
421
|
+
|
|
422
|
+
## Button props
|
|
423
|
+
|
|
424
|
+
<Controls of={Button.Playground} />
|
|
425
|
+
```
|