@registrucentras/rc-ses-react-components 2.0.0-rc.9 → 2.1.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/README.md +4 -0
- package/dist/assets/icons/ShoppingCartIcon.d.ts +3 -0
- package/dist/components/common/CardShell/index.d.ts +1 -1
- package/dist/components/common/CardShell/types.d.ts +10 -0
- package/dist/components/common/ListWithIcons/ListWithIcons.types.d.ts +4 -1
- package/dist/components/common/StepCard/StepCardFooter/index.d.ts +34 -0
- package/dist/components/common/StepCard/index.d.ts +3 -0
- package/dist/components/common/StepCard/types.d.ts +39 -0
- package/dist/components/common/TitleBlock/types.d.ts +1 -1
- package/dist/components/layout/ServiceFormContainer/CardFormContainer/index.d.ts +3 -0
- package/dist/components/loaders/LoadingSpinner/index.d.ts +1 -4
- package/dist/library/icons.d.ts +2 -1
- package/dist/library/index.d.ts +2 -1
- package/dist/library/types.d.ts +4 -3
- package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
- package/dist/registrucentras-rc-ses-react-components.js +2091 -1888
- package/dist/theme/cards.d.ts +12 -12
- package/dist/theme/light/MuiTypography.d.ts +14 -0
- package/dist/theme/palette.d.ts +124 -124
- package/dist/theme/spacing.d.ts +4 -0
- package/package.json +2 -1
- package/src/assets/icons/ShoppingCartIcon.tsx +16 -0
- package/src/components/common/Button/index.test.tsx +20 -11
- package/src/components/common/Button/index.tsx +8 -44
- package/src/components/common/CardShell/index.tsx +6 -2
- package/src/components/common/CardShell/types.ts +10 -0
- package/src/components/common/ListWithIcons/ListWithIcons.types.ts +22 -1
- package/src/components/common/ListWithIcons/components/ListWithIconsItem.tsx +13 -4
- package/src/components/common/ListWithIcons/index.test.tsx +42 -0
- package/src/components/common/StepCard/StepCardFooter/index.test.tsx +162 -0
- package/src/components/common/StepCard/StepCardFooter/index.tsx +120 -0
- package/src/components/common/StepCard/index.test.tsx +120 -0
- package/src/components/common/StepCard/index.tsx +74 -0
- package/src/components/common/StepCard/types.ts +45 -0
- package/src/components/common/TitleBlock/types.ts +1 -1
- package/src/components/form/inputs/SearchableField.test.tsx +1 -1
- package/src/components/layout/ServiceFormContainer/CardFormContainer/index.tsx +3 -0
- package/src/components/loaders/LoadingSpinner/index.tsx +3 -26
- package/src/examples/ListWithPagination/index.tsx +2 -1
- package/src/i18n/namespaces/common/en.json +7 -0
- package/src/i18n/namespaces/common/lt.json +7 -0
- package/src/library/icons.ts +2 -0
- package/src/library/index.ts +2 -0
- package/src/library/types.ts +17 -2
- package/src/stories/atoms/Button.stories.tsx +202 -497
- package/src/stories/foundations/ThemedMuiComponents.stories.tsx +2 -2
- package/src/stories/molecules/CardShell.stories.tsx +36 -2
- package/src/stories/molecules/DatePicker.stories.tsx +1 -2
- package/src/stories/molecules/ListWithIcons.stories.tsx +26 -0
- package/src/stories/molecules/Popover.stories.tsx +1 -1
- package/src/stories/molecules/StepCard.stories.tsx +181 -0
- package/src/stories/molecules/TitleBlock.stories.tsx +2 -2
- package/src/stories/organisms/AdvancedListItem.stories.tsx +80 -0
- package/src/stories/organisms/CardFormContainer.stories.tsx +1 -1
- package/src/stories/organisms/Dialog.stories.tsx +1 -2
- package/src/theme/light/MuiButton.tsx +54 -0
- package/src/theme/light/MuiCard.tsx +9 -7
- package/src/theme/light/MuiTypography.tsx +17 -0
- package/src/theme/palette.tsx +7 -7
- package/src/theme/spacing.ts +5 -0
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { Box, Typography } from '@mui/material'
|
|
1
2
|
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
3
|
+
import { Fragment } from 'react'
|
|
2
4
|
import { fn } from 'storybook/test'
|
|
3
5
|
|
|
4
6
|
import PlusBoldIcon from '@/assets/icons/PlusBoldIcon'
|
|
5
7
|
import Button from '@/components/common/Button'
|
|
8
|
+
import PreviewTitle from '@/components/storybook/PreviewTitle'
|
|
6
9
|
import { grey } from '@/theme/palette'
|
|
7
10
|
import { ButtonProps } from '@/types/buttons/ButtonProps'
|
|
8
11
|
|
|
@@ -30,533 +33,235 @@ const meta = {
|
|
|
30
33
|
argTypes: {
|
|
31
34
|
variant: {
|
|
32
35
|
options: variantOptions,
|
|
33
|
-
|
|
34
|
-
control: {
|
|
35
|
-
type: 'select',
|
|
36
|
-
labels: variantOptions,
|
|
37
|
-
},
|
|
38
|
-
table: {
|
|
39
|
-
defaultValue: {},
|
|
40
|
-
},
|
|
36
|
+
control: { type: 'select' },
|
|
41
37
|
},
|
|
42
38
|
color: {
|
|
43
39
|
options: colorOptions,
|
|
44
|
-
|
|
45
|
-
control: {
|
|
46
|
-
type: 'select',
|
|
47
|
-
labels: colorOptions,
|
|
48
|
-
},
|
|
49
|
-
table: {
|
|
50
|
-
defaultValue: {},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
disabled: {
|
|
54
|
-
control: {
|
|
55
|
-
type: 'boolean',
|
|
56
|
-
},
|
|
57
|
-
table: {
|
|
58
|
-
defaultValue: {},
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
iconOnly: {
|
|
62
|
-
control: {
|
|
63
|
-
type: 'boolean',
|
|
64
|
-
},
|
|
65
|
-
table: {
|
|
66
|
-
defaultValue: {},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
loading: {
|
|
70
|
-
control: {
|
|
71
|
-
type: 'boolean',
|
|
72
|
-
},
|
|
73
|
-
table: {
|
|
74
|
-
defaultValue: { summary: 'false' },
|
|
75
|
-
},
|
|
40
|
+
control: { type: 'select' },
|
|
76
41
|
},
|
|
42
|
+
disabled: { control: 'boolean' },
|
|
43
|
+
iconOnly: { control: 'boolean' },
|
|
44
|
+
loading: { control: 'boolean' },
|
|
45
|
+
children: { control: 'text' },
|
|
77
46
|
},
|
|
78
|
-
tags: ['autodocs'],
|
|
79
47
|
args: {
|
|
80
48
|
children: 'Button',
|
|
81
49
|
onClick: fn(),
|
|
82
50
|
},
|
|
51
|
+
tags: ['autodocs'],
|
|
83
52
|
} satisfies Meta<typeof Button>
|
|
84
53
|
|
|
85
54
|
export default meta
|
|
86
55
|
type Story = StoryObj<typeof meta>
|
|
87
56
|
|
|
88
|
-
const disableColorContrast = {
|
|
89
|
-
a11y: {
|
|
90
|
-
config: {
|
|
91
|
-
rules: [{ id: 'color-contrast', enabled: false }],
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
}
|
|
95
|
-
|
|
96
57
|
export const PrimaryContained: Story = {
|
|
97
58
|
args: {
|
|
98
59
|
variant: 'contained',
|
|
99
60
|
color: 'primary',
|
|
100
61
|
disabled: false,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const canvas = within(canvasElement)
|
|
104
|
-
|
|
105
|
-
// See https://storybook.js.org/docs/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
|
|
106
|
-
await userEvent.click(canvas.getByRole('button'))
|
|
107
|
-
|
|
108
|
-
// 👇 Assert DOM structure
|
|
109
|
-
await expect(
|
|
110
|
-
canvas.getByText(
|
|
111
|
-
'Everything is perfect. Your account is ready and we should probably get you started!',
|
|
112
|
-
),
|
|
113
|
-
).toBeInTheDocument()
|
|
114
|
-
}, */
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export const PrimaryContainedWithPrefixIcon: Story = {
|
|
118
|
-
args: {
|
|
119
|
-
variant: 'contained',
|
|
120
|
-
color: 'primary',
|
|
121
|
-
disabled: false,
|
|
122
|
-
startIcon: <PlusBoldIcon />,
|
|
123
|
-
},
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export const PrimaryContainedWithSuffixIcon: Story = {
|
|
127
|
-
args: {
|
|
128
|
-
variant: 'contained',
|
|
129
|
-
color: 'primary',
|
|
130
|
-
disabled: false,
|
|
131
|
-
endIcon: <PlusBoldIcon />,
|
|
132
|
-
},
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export const PrimaryContainedIconOnly: Story = {
|
|
136
|
-
args: {
|
|
137
|
-
'aria-label': 'Add',
|
|
138
|
-
children: <PlusBoldIcon />,
|
|
139
|
-
color: 'primary',
|
|
140
|
-
iconOnly: true,
|
|
141
|
-
variant: 'contained',
|
|
142
|
-
},
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export const PrimaryOutlined: Story = {
|
|
146
|
-
parameters: disableColorContrast,
|
|
147
|
-
args: {
|
|
148
|
-
color: 'primary',
|
|
149
|
-
variant: 'outlined',
|
|
150
|
-
},
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export const PrimaryOutlinedWithPrefixIcon: Story = {
|
|
154
|
-
parameters: disableColorContrast,
|
|
155
|
-
args: {
|
|
156
|
-
color: 'primary',
|
|
157
|
-
variant: 'outlined',
|
|
158
|
-
startIcon: <PlusBoldIcon />,
|
|
159
|
-
},
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export const PrimaryOutlinedWithSuffixIcon: Story = {
|
|
163
|
-
parameters: disableColorContrast,
|
|
164
|
-
args: {
|
|
165
|
-
color: 'primary',
|
|
166
|
-
variant: 'outlined',
|
|
167
|
-
endIcon: <PlusBoldIcon />,
|
|
168
|
-
},
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export const PrimaryOutlinedIconOnly: Story = {
|
|
172
|
-
parameters: disableColorContrast,
|
|
173
|
-
args: {
|
|
174
|
-
'aria-label': 'Add',
|
|
175
|
-
children: <PlusBoldIcon />,
|
|
176
|
-
color: 'primary',
|
|
177
|
-
iconOnly: true,
|
|
178
|
-
variant: 'outlined',
|
|
179
|
-
},
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export const SecondaryContained: Story = {
|
|
183
|
-
args: {
|
|
184
|
-
color: 'secondary',
|
|
185
|
-
variant: 'contained',
|
|
186
|
-
},
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export const SecondaryOutlined: Story = {
|
|
190
|
-
parameters: disableColorContrast,
|
|
191
|
-
args: {
|
|
192
|
-
color: 'secondary',
|
|
193
|
-
variant: 'outlined',
|
|
194
|
-
},
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export const GreyContained: Story = {
|
|
198
|
-
args: {
|
|
199
|
-
color: 'grey',
|
|
200
|
-
variant: 'contained',
|
|
201
|
-
},
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export const GreyOutlined: Story = {
|
|
205
|
-
parameters: disableColorContrast,
|
|
206
|
-
args: {
|
|
207
|
-
color: 'grey',
|
|
208
|
-
variant: 'outlined',
|
|
209
|
-
},
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export const WarningContained: Story = {
|
|
213
|
-
args: {
|
|
214
|
-
variant: 'contained',
|
|
215
|
-
children: 'Button',
|
|
216
|
-
color: 'warning',
|
|
217
|
-
},
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export const WarningOutlined: Story = {
|
|
221
|
-
parameters: disableColorContrast,
|
|
222
|
-
args: {
|
|
223
|
-
variant: 'outlined',
|
|
224
|
-
children: 'Button',
|
|
225
|
-
color: 'warning',
|
|
226
|
-
},
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export const ErrorContained: Story = {
|
|
230
|
-
args: {
|
|
231
|
-
color: 'error',
|
|
232
|
-
variant: 'contained',
|
|
233
|
-
},
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export const ErrorOutlined: Story = {
|
|
237
|
-
parameters: disableColorContrast,
|
|
238
|
-
args: {
|
|
239
|
-
color: 'error',
|
|
240
|
-
variant: 'outlined',
|
|
241
|
-
},
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
export const LightOutlined: Story = {
|
|
245
|
-
args: {
|
|
246
|
-
variant: 'outlined',
|
|
247
|
-
color: 'light',
|
|
248
|
-
children: 'Light Button',
|
|
249
|
-
},
|
|
250
|
-
decorators: [
|
|
251
|
-
(Story) => (
|
|
252
|
-
<div
|
|
253
|
-
style={{
|
|
254
|
-
backgroundColor: grey[900],
|
|
255
|
-
padding: '0.5rem',
|
|
256
|
-
borderRadius: '0.5rem',
|
|
257
|
-
display: 'inline-flex',
|
|
258
|
-
alignItems: 'center',
|
|
259
|
-
justifyContent: 'center',
|
|
260
|
-
}}
|
|
261
|
-
>
|
|
262
|
-
<Story />
|
|
263
|
-
</div>
|
|
264
|
-
),
|
|
265
|
-
],
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
export const LightOutlinedWithIcon: Story = {
|
|
269
|
-
args: {
|
|
270
|
-
variant: 'outlined',
|
|
271
|
-
color: 'light',
|
|
272
|
-
startIcon: <PlusBoldIcon />,
|
|
273
|
-
children: 'Light Button with Icon',
|
|
274
|
-
},
|
|
275
|
-
decorators: [
|
|
276
|
-
(Story) => (
|
|
277
|
-
<div
|
|
278
|
-
style={{
|
|
279
|
-
backgroundColor: grey[900],
|
|
280
|
-
padding: '0.5rem',
|
|
281
|
-
borderRadius: '0.5rem',
|
|
282
|
-
display: 'inline-flex',
|
|
283
|
-
alignItems: 'center',
|
|
284
|
-
justifyContent: 'center',
|
|
285
|
-
}}
|
|
286
|
-
>
|
|
287
|
-
<Story />
|
|
288
|
-
</div>
|
|
289
|
-
),
|
|
290
|
-
],
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
export const LightOutlinedDisabled: Story = {
|
|
294
|
-
args: {
|
|
295
|
-
variant: 'outlined',
|
|
296
|
-
color: 'light',
|
|
297
|
-
children: 'Light Button Disabled',
|
|
298
|
-
disabled: true,
|
|
299
|
-
},
|
|
300
|
-
decorators: [
|
|
301
|
-
(Story) => (
|
|
302
|
-
<div
|
|
303
|
-
style={{
|
|
304
|
-
backgroundColor: grey[900],
|
|
305
|
-
padding: '0.5rem',
|
|
306
|
-
borderRadius: '0.5rem',
|
|
307
|
-
display: 'inline-flex',
|
|
308
|
-
alignItems: 'center',
|
|
309
|
-
justifyContent: 'center',
|
|
310
|
-
}}
|
|
311
|
-
>
|
|
312
|
-
<Story />
|
|
313
|
-
</div>
|
|
314
|
-
),
|
|
315
|
-
],
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
export const GhostOutlinedIconOnly: Story = {
|
|
319
|
-
args: {
|
|
320
|
-
'aria-label': 'Close',
|
|
321
|
-
children: <PlusBoldIcon />,
|
|
322
|
-
color: 'ghost',
|
|
323
|
-
iconOnly: true,
|
|
324
|
-
variant: 'outlined',
|
|
325
|
-
},
|
|
326
|
-
decorators: [
|
|
327
|
-
(Story) => (
|
|
328
|
-
<div
|
|
329
|
-
style={{
|
|
330
|
-
backgroundColor: grey[900],
|
|
331
|
-
padding: '0.5rem',
|
|
332
|
-
borderRadius: '0.5rem',
|
|
333
|
-
display: 'inline-flex',
|
|
334
|
-
alignItems: 'center',
|
|
335
|
-
justifyContent: 'center',
|
|
336
|
-
}}
|
|
337
|
-
>
|
|
338
|
-
<Story />
|
|
339
|
-
</div>
|
|
340
|
-
),
|
|
341
|
-
],
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
export const GhostOutlinedIconOnlyDisabled: Story = {
|
|
345
|
-
args: {
|
|
346
|
-
'aria-label': 'Close',
|
|
347
|
-
children: <PlusBoldIcon />,
|
|
348
|
-
color: 'ghost',
|
|
349
|
-
disabled: true,
|
|
350
|
-
iconOnly: true,
|
|
351
|
-
variant: 'outlined',
|
|
352
|
-
},
|
|
353
|
-
decorators: [
|
|
354
|
-
(Story) => (
|
|
355
|
-
<div
|
|
356
|
-
style={{
|
|
357
|
-
backgroundColor: grey[900],
|
|
358
|
-
padding: '0.5rem',
|
|
359
|
-
borderRadius: '0.5rem',
|
|
360
|
-
display: 'inline-flex',
|
|
361
|
-
alignItems: 'center',
|
|
362
|
-
justifyContent: 'center',
|
|
363
|
-
}}
|
|
364
|
-
>
|
|
365
|
-
<Story />
|
|
366
|
-
</div>
|
|
367
|
-
),
|
|
368
|
-
],
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
// Loading states
|
|
372
|
-
export const PrimaryContainedLoading: Story = {
|
|
373
|
-
args: {
|
|
374
|
-
variant: 'contained',
|
|
375
|
-
color: 'primary',
|
|
376
|
-
loading: true,
|
|
377
|
-
},
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
export const PrimaryContainedLoadingWithIcon: Story = {
|
|
381
|
-
args: {
|
|
382
|
-
variant: 'contained',
|
|
383
|
-
color: 'primary',
|
|
384
|
-
loading: true,
|
|
385
|
-
startIcon: <PlusBoldIcon />,
|
|
386
|
-
},
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
export const PrimaryContainedLoadingWithEndIcon: Story = {
|
|
390
|
-
args: {
|
|
391
|
-
variant: 'contained',
|
|
392
|
-
color: 'primary',
|
|
393
|
-
loading: true,
|
|
394
|
-
endIcon: <PlusBoldIcon />,
|
|
395
|
-
},
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
export const PrimaryContainedIconOnlyLoading: Story = {
|
|
399
|
-
args: {
|
|
400
|
-
'aria-label': 'Add',
|
|
401
|
-
children: <PlusBoldIcon />,
|
|
402
|
-
color: 'primary',
|
|
403
|
-
iconOnly: true,
|
|
404
|
-
variant: 'contained',
|
|
405
|
-
loading: true,
|
|
406
|
-
},
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
export const PrimaryOutlinedLoading: Story = {
|
|
410
|
-
parameters: disableColorContrast,
|
|
411
|
-
args: {
|
|
412
|
-
color: 'primary',
|
|
413
|
-
variant: 'outlined',
|
|
414
|
-
loading: true,
|
|
415
|
-
},
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
export const SecondaryContainedLoading: Story = {
|
|
419
|
-
args: {
|
|
420
|
-
color: 'secondary',
|
|
421
|
-
variant: 'contained',
|
|
422
|
-
loading: true,
|
|
423
|
-
},
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
export const SecondaryOutlinedLoading: Story = {
|
|
427
|
-
parameters: disableColorContrast,
|
|
428
|
-
args: {
|
|
429
|
-
color: 'secondary',
|
|
430
|
-
variant: 'outlined',
|
|
431
|
-
loading: true,
|
|
432
|
-
},
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
export const GreyContainedLoading: Story = {
|
|
436
|
-
args: {
|
|
437
|
-
color: 'grey',
|
|
438
|
-
variant: 'contained',
|
|
439
|
-
loading: true,
|
|
440
|
-
},
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
export const GreyOutlinedLoading: Story = {
|
|
444
|
-
parameters: disableColorContrast,
|
|
445
|
-
args: {
|
|
446
|
-
color: 'grey',
|
|
447
|
-
variant: 'outlined',
|
|
448
|
-
loading: true,
|
|
449
|
-
},
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
export const WarningContainedLoading: Story = {
|
|
453
|
-
args: {
|
|
454
|
-
variant: 'contained',
|
|
455
|
-
color: 'warning',
|
|
456
|
-
loading: true,
|
|
62
|
+
iconOnly: false,
|
|
63
|
+
loading: false,
|
|
457
64
|
},
|
|
458
65
|
}
|
|
459
66
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
loading: true,
|
|
67
|
+
const disableColorContrast = {
|
|
68
|
+
a11y: {
|
|
69
|
+
config: {
|
|
70
|
+
rules: [{ id: 'color-contrast', enabled: false }],
|
|
71
|
+
},
|
|
466
72
|
},
|
|
467
73
|
}
|
|
468
74
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
75
|
+
interface VariantColorCombo {
|
|
76
|
+
variant: Exclude<ButtonProps['variant'], undefined>
|
|
77
|
+
color: ButtonProps['color']
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Split so axe color-contrast stays enforced on light-surface combos and is
|
|
81
|
+
// only disabled for the dark-surface grid, where light/ghost intentionally
|
|
82
|
+
// render on top of a dark backdrop that axe cannot see through the DOM.
|
|
83
|
+
const lightSurfaceCombos: VariantColorCombo[] = [
|
|
84
|
+
{ variant: 'contained', color: 'primary' },
|
|
85
|
+
{ variant: 'contained', color: 'secondary' },
|
|
86
|
+
{ variant: 'contained', color: 'grey' },
|
|
87
|
+
{ variant: 'contained', color: 'warning' },
|
|
88
|
+
{ variant: 'contained', color: 'error' },
|
|
89
|
+
{ variant: 'outlined', color: 'primary' },
|
|
90
|
+
{ variant: 'outlined', color: 'secondary' },
|
|
91
|
+
{ variant: 'outlined', color: 'grey' },
|
|
92
|
+
{ variant: 'outlined', color: 'warning' },
|
|
93
|
+
{ variant: 'outlined', color: 'error' },
|
|
94
|
+
// link/text carry their own loading baseline - link disabled ships with
|
|
95
|
+
// opacity: 0.4 so its centered indicator is fainter than the theme's
|
|
96
|
+
// grey[600] measurement suggests. Keep primary + grey rows to cover both
|
|
97
|
+
// the tinted and the neutral disabled paths.
|
|
98
|
+
{ variant: 'link', color: 'primary' },
|
|
99
|
+
{ variant: 'link', color: 'grey' },
|
|
100
|
+
{ variant: 'text', color: 'primary' },
|
|
101
|
+
{ variant: 'text', color: 'grey' },
|
|
102
|
+
]
|
|
476
103
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
variant: 'outlined',
|
|
482
|
-
loading: true,
|
|
483
|
-
},
|
|
484
|
-
}
|
|
104
|
+
const darkSurfaceCombos: VariantColorCombo[] = [
|
|
105
|
+
{ variant: 'outlined', color: 'light' },
|
|
106
|
+
{ variant: 'outlined', color: 'ghost' },
|
|
107
|
+
]
|
|
485
108
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
variant
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
109
|
+
const rowSpansFor = (combos: VariantColorCombo[]) =>
|
|
110
|
+
combos.reduce<Record<string, number>>((acc, { variant }) => {
|
|
111
|
+
acc[variant] = (acc[variant] ?? 0) + 1
|
|
112
|
+
return acc
|
|
113
|
+
}, {})
|
|
114
|
+
|
|
115
|
+
const iconOnlyArgs: Partial<ButtonProps> = {
|
|
116
|
+
iconOnly: true,
|
|
117
|
+
'aria-label': 'Add',
|
|
118
|
+
children: <PlusBoldIcon />,
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const states: {
|
|
122
|
+
key: string
|
|
123
|
+
label: string
|
|
124
|
+
args: Partial<ButtonProps>
|
|
125
|
+
}[] = [
|
|
126
|
+
{ key: 'default', label: 'Default', args: {} },
|
|
127
|
+
{
|
|
128
|
+
key: 'prefixIcon',
|
|
129
|
+
label: 'Prefix Icon',
|
|
130
|
+
args: { startIcon: <PlusBoldIcon /> },
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
key: 'suffixIcon',
|
|
134
|
+
label: 'Suffix Icon',
|
|
135
|
+
args: { endIcon: <PlusBoldIcon /> },
|
|
136
|
+
},
|
|
137
|
+
{ key: 'iconOnly', label: 'Icon Only', args: iconOnlyArgs },
|
|
138
|
+
{ key: 'disabled', label: 'Disabled', args: { disabled: true } },
|
|
139
|
+
{ key: 'loading', label: 'Loading', args: { loading: true } },
|
|
140
|
+
{
|
|
141
|
+
key: 'loadingStart',
|
|
142
|
+
label: 'Loading Position Start',
|
|
143
|
+
args: { loading: true, loadingPosition: 'start', startIcon: <PlusBoldIcon /> },
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
key: 'loadingEnd',
|
|
147
|
+
label: 'Loading Position End',
|
|
148
|
+
args: { loading: true, loadingPosition: 'end', endIcon: <PlusBoldIcon /> },
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
key: 'loadingIconOnly',
|
|
152
|
+
label: 'Loading Icon Only',
|
|
153
|
+
args: { ...iconOnlyArgs, loading: true },
|
|
492
154
|
},
|
|
493
|
-
|
|
494
|
-
(Story) => (
|
|
495
|
-
<div
|
|
496
|
-
style={{
|
|
497
|
-
backgroundColor: grey[900],
|
|
498
|
-
padding: '0.5rem',
|
|
499
|
-
borderRadius: '0.5rem',
|
|
500
|
-
display: 'inline-flex',
|
|
501
|
-
alignItems: 'center',
|
|
502
|
-
justifyContent: 'center',
|
|
503
|
-
}}
|
|
504
|
-
>
|
|
505
|
-
<Story />
|
|
506
|
-
</div>
|
|
507
|
-
),
|
|
508
|
-
],
|
|
509
|
-
}
|
|
155
|
+
]
|
|
510
156
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
157
|
+
const CombinationsGrid = ({
|
|
158
|
+
combos,
|
|
159
|
+
onDark = false,
|
|
160
|
+
}: {
|
|
161
|
+
combos: VariantColorCombo[]
|
|
162
|
+
onDark?: boolean
|
|
163
|
+
}) => {
|
|
164
|
+
const rowSpans = rowSpansFor(combos)
|
|
165
|
+
const labelColor = onDark ? grey[50] : 'text.secondary'
|
|
166
|
+
return (
|
|
167
|
+
<Box
|
|
168
|
+
sx={{
|
|
169
|
+
display: 'grid',
|
|
170
|
+
gridTemplateColumns: `110px 90px repeat(${states.length}, minmax(140px, 1fr))`,
|
|
171
|
+
rowGap: 1.5,
|
|
172
|
+
columnGap: 1.5,
|
|
173
|
+
alignItems: 'center',
|
|
174
|
+
}}
|
|
175
|
+
>
|
|
176
|
+
{/* header row: two empty cells for the variant/color labels, then state labels */}
|
|
177
|
+
<Box />
|
|
178
|
+
<Box />
|
|
179
|
+
{states.map((state) => (
|
|
180
|
+
<Typography
|
|
181
|
+
key={state.key}
|
|
182
|
+
align='center'
|
|
183
|
+
variant='body2'
|
|
184
|
+
sx={{ color: labelColor }}
|
|
185
|
+
>
|
|
186
|
+
{state.label}
|
|
187
|
+
</Typography>
|
|
188
|
+
))}
|
|
189
|
+
{combos.map(({ variant, color }, rowIndex) => {
|
|
190
|
+
const prevVariant = combos[rowIndex - 1]?.variant
|
|
191
|
+
const isFirstOfVariant = variant !== prevVariant
|
|
192
|
+
const rowSpan = rowSpans[variant]
|
|
193
|
+
return (
|
|
194
|
+
<Fragment key={`${variant}-${color}`}>
|
|
195
|
+
{isFirstOfVariant ? (
|
|
196
|
+
<Typography
|
|
197
|
+
variant='body2'
|
|
198
|
+
sx={{
|
|
199
|
+
color: onDark ? grey[50] : undefined,
|
|
200
|
+
fontWeight: 600,
|
|
201
|
+
gridRow: `span ${rowSpan}`,
|
|
202
|
+
}}
|
|
203
|
+
>
|
|
204
|
+
{variant}
|
|
205
|
+
</Typography>
|
|
206
|
+
) : null}
|
|
207
|
+
<Typography variant='body2' sx={{ color: labelColor }}>
|
|
208
|
+
{color}
|
|
209
|
+
</Typography>
|
|
210
|
+
{states.map((state) => {
|
|
211
|
+
const { children, ...restArgs } = state.args
|
|
212
|
+
return (
|
|
213
|
+
<Box key={state.key} sx={{ display: 'flex', justifyContent: 'center' }}>
|
|
214
|
+
<Button variant={variant} color={color} {...restArgs}>
|
|
215
|
+
{children ?? 'Button'}
|
|
216
|
+
</Button>
|
|
217
|
+
</Box>
|
|
218
|
+
)
|
|
219
|
+
})}
|
|
220
|
+
</Fragment>
|
|
221
|
+
)
|
|
222
|
+
})}
|
|
223
|
+
</Box>
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export const CoreCombinations: Story = {
|
|
228
|
+
parameters: {
|
|
229
|
+
layout: 'padded',
|
|
518
230
|
},
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
<
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
}}
|
|
530
|
-
>
|
|
531
|
-
<Story />
|
|
532
|
-
</div>
|
|
533
|
-
),
|
|
534
|
-
],
|
|
231
|
+
render: () => (
|
|
232
|
+
<>
|
|
233
|
+
<PreviewTitle>
|
|
234
|
+
Light surface: {lightSurfaceCombos.length} variant+color rows x {states.length}{' '}
|
|
235
|
+
states = {lightSurfaceCombos.length * states.length} buttons. Axe color-contrast
|
|
236
|
+
stays enforced here.
|
|
237
|
+
</PreviewTitle>
|
|
238
|
+
<CombinationsGrid combos={lightSurfaceCombos} />
|
|
239
|
+
</>
|
|
240
|
+
),
|
|
535
241
|
}
|
|
536
242
|
|
|
537
|
-
export const
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
>
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
],
|
|
243
|
+
export const DarkSurfaceCombinations: Story = {
|
|
244
|
+
parameters: {
|
|
245
|
+
...disableColorContrast,
|
|
246
|
+
layout: 'padded',
|
|
247
|
+
},
|
|
248
|
+
render: () => (
|
|
249
|
+
<Box
|
|
250
|
+
sx={{
|
|
251
|
+
backgroundColor: grey[900],
|
|
252
|
+
borderRadius: 1,
|
|
253
|
+
p: 3,
|
|
254
|
+
color: grey[50],
|
|
255
|
+
width: 'fit-content',
|
|
256
|
+
minWidth: '100%',
|
|
257
|
+
}}
|
|
258
|
+
>
|
|
259
|
+
<PreviewTitle>
|
|
260
|
+
Dark surface: {darkSurfaceCombos.length} variant+color rows x {states.length}{' '}
|
|
261
|
+
states = {darkSurfaceCombos.length * states.length} buttons. Axe color-contrast is
|
|
262
|
+
disabled - light/ghost render on top of this dark backdrop.
|
|
263
|
+
</PreviewTitle>
|
|
264
|
+
<CombinationsGrid combos={darkSurfaceCombos} onDark />
|
|
265
|
+
</Box>
|
|
266
|
+
),
|
|
562
267
|
}
|