@linagora/twake-mui 7.0.0 → 8.0.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/dist/components/Apptitle/index.js +9 -5
  3. package/dist/components/Avatar/Avatar.stories.js +58 -37
  4. package/dist/components/Avatar/helpers.d.ts +0 -28
  5. package/dist/components/Avatar/helpers.js +0 -28
  6. package/dist/components/Avatar/index.d.ts +4 -6
  7. package/dist/components/Avatar/index.js +24 -31
  8. package/dist/components/Button/index.d.ts +12 -0
  9. package/dist/components/Button/index.js +8 -0
  10. package/dist/components/Chip/index.js +3 -3
  11. package/dist/{stories → components/Dialog}/Dialog.stories.d.ts +2 -2
  12. package/dist/components/Dialog/Dialog.stories.js +81 -0
  13. package/dist/components/Dialog/index.d.ts +9 -0
  14. package/dist/components/Dialog/index.js +9 -0
  15. package/dist/components/Switch/Switch.stories.d.ts +7 -0
  16. package/dist/components/Switch/Switch.stories.js +58 -0
  17. package/dist/components/Switch/index.d.ts +9 -0
  18. package/dist/components/Switch/index.js +8 -0
  19. package/dist/components/Tabs/Tabs.stories.d.ts +7 -0
  20. package/dist/components/Tabs/Tabs.stories.js +52 -0
  21. package/dist/components/Tabs/index.d.ts +10 -0
  22. package/dist/components/Tabs/index.js +5 -0
  23. package/dist/components/ThemeProvider/index.js +9 -10
  24. package/dist/components/ThemeProvider/types.d.ts +6 -0
  25. package/dist/index.d.ts +10 -1
  26. package/dist/index.js +5 -1
  27. package/dist/lib/makePalette.d.ts +1 -1
  28. package/dist/lib/makePalette.js +3 -1
  29. package/dist/lib/makeShadows.d.ts +1 -1
  30. package/dist/lib/makeShadows.js +2 -2
  31. package/dist/lib/makeTheme.d.ts +3 -2
  32. package/dist/lib/makeTheme.js +15 -16
  33. package/dist/lib/overrides.d.ts +2 -0
  34. package/dist/lib/overrides.js +1027 -0
  35. package/dist/lib/types.d.ts +19 -0
  36. package/dist/stories/Alert.stories.js +57 -53
  37. package/dist/stories/Badge.stories.d.ts +7 -0
  38. package/dist/stories/Badge.stories.js +84 -0
  39. package/dist/stories/Button.stories.d.ts +3 -3
  40. package/dist/stories/Button.stories.js +67 -58
  41. package/dist/stories/{Selection.stories.d.ts → Checkbox.stories.d.ts} +1 -1
  42. package/dist/stories/Checkbox.stories.js +72 -0
  43. package/dist/stories/Chip.stories.js +2 -2
  44. package/dist/stories/Divider.stories.d.ts +7 -0
  45. package/dist/stories/Divider.stories.js +56 -0
  46. package/dist/stories/IconButton.stories.d.ts +7 -0
  47. package/dist/stories/IconButton.stories.js +59 -0
  48. package/dist/stories/Radio.stories.d.ts +7 -0
  49. package/dist/stories/Radio.stories.js +60 -0
  50. package/dist/stories/Snackbar.stories.d.ts +7 -0
  51. package/dist/stories/Snackbar.stories.js +60 -0
  52. package/dist/stories/{Input.stories.d.ts → TextField.stories.d.ts} +1 -1
  53. package/dist/stories/TextField.stories.js +86 -0
  54. package/dist/stories/ThemePlayground.stories.js +20 -113
  55. package/dist/stories/Typography.stories.d.ts +1 -1
  56. package/dist/stories/Typography.stories.js +48 -34
  57. package/package.json +2 -1
  58. package/dist/lib/darkOverrides.d.ts +0 -2
  59. package/dist/lib/darkOverrides.js +0 -3
  60. package/dist/lib/lightOverrides.d.ts +0 -2
  61. package/dist/lib/lightOverrides.js +0 -520
  62. package/dist/stories/Dialog.stories.js +0 -40
  63. package/dist/stories/Input.stories.js +0 -41
  64. package/dist/stories/Selection.stories.js +0 -37
@@ -0,0 +1,1027 @@
1
+ import { Bottom, CheckCircle, CheckSquare, Icon, Info, RadioChecked, RadioUnchecked, Spinner, Warning, WarningCircle } from '@linagora/twake-icons';
2
+ import { alertClasses } from '@mui/material/Alert';
3
+ import { buttonClasses } from '@mui/material/Button';
4
+ import { checkboxClasses } from '@mui/material/Checkbox';
5
+ import { dialogTitleClasses } from '@mui/material/DialogTitle';
6
+ import { formHelperTextClasses } from '@mui/material/FormHelperText';
7
+ import { formLabelClasses } from '@mui/material/FormLabel';
8
+ import { menuItemClasses } from '@mui/material/MenuItem';
9
+ import { outlinedInputClasses } from '@mui/material/OutlinedInput';
10
+ import { radioClasses } from '@mui/material/Radio';
11
+ import { selectClasses } from '@mui/material/Select';
12
+ import { switchClasses } from '@mui/material/Switch';
13
+ import { tabClasses } from '@mui/material/Tab';
14
+ import { tabsClasses } from '@mui/material/Tabs';
15
+ import { alpha, darken } from '@mui/material/styles';
16
+ import React from 'react';
17
+ import { radius } from './radius';
18
+ import AccordionExpandIcon from '../components/AccordionExpandIcon';
19
+ const alertSeverities = [
20
+ 'primary',
21
+ 'secondary',
22
+ 'success',
23
+ 'error',
24
+ 'warning',
25
+ 'info'
26
+ ];
27
+ const alertIconColor = (severity, theme) => {
28
+ if (severity === 'primary')
29
+ return theme.vars.palette.primary.main;
30
+ if (severity === 'secondary')
31
+ return theme.vars.palette.text.primary;
32
+ return undefined;
33
+ };
34
+ const alertSeverityVariants = alertSeverities.flatMap(severity => [
35
+ {
36
+ props: { colorSeverity: severity, variant: 'standard' },
37
+ style: ({ theme }) => ({
38
+ color: theme.vars.palette.text.primary,
39
+ backgroundColor: theme.alpha(theme.vars.palette[severity].main, 0.12),
40
+ ...theme.applyStyles('dark', {
41
+ backgroundColor: theme.alpha(theme.vars.palette[severity].main, 0.24)
42
+ }),
43
+ [`& .${alertClasses.icon}`]: { color: alertIconColor(severity, theme) },
44
+ [`& .${alertClasses.action} button[title="Close"]`]: {
45
+ color: theme.vars.palette.text.secondary
46
+ }
47
+ })
48
+ },
49
+ {
50
+ props: { colorSeverity: severity, variant: 'outlined' },
51
+ style: ({ theme }) => ({
52
+ color: theme.vars.palette.text.primary,
53
+ border: `1px solid ${theme.vars.palette[severity].main}`,
54
+ [`& .${alertClasses.icon}`]: { color: alertIconColor(severity, theme) }
55
+ })
56
+ },
57
+ {
58
+ props: { colorSeverity: severity, variant: 'filled' },
59
+ style: ({ theme }) => ({
60
+ color: theme.vars.palette[severity].contrastText,
61
+ backgroundColor: theme.vars.palette[severity].main
62
+ })
63
+ }
64
+ ]);
65
+ const avatarSizes = {
66
+ xs: [16, 8, 10],
67
+ s: [24, 11, 16],
68
+ m: [32, 16, 20],
69
+ l: [48, 24, 28],
70
+ xl: [64, 32, 36]
71
+ };
72
+ const makeAvatarSizes = (theme) => Object.fromEntries(Object.entries(avatarSizes).map(([size, [box, font, icon]]) => [
73
+ `&.size-${size}`,
74
+ {
75
+ width: box,
76
+ height: box,
77
+ fontSize: theme.typography.pxToRem(font),
78
+ '& svg': { width: icon, height: icon }
79
+ }
80
+ ]));
81
+ // cozy-ui tints every colour but primary at 8%, primary at 25%
82
+ const buttonGhostColors = [
83
+ 'secondary',
84
+ 'success',
85
+ 'error',
86
+ 'warning',
87
+ 'info'
88
+ ];
89
+ // cozy-ui's select caret, at the 16px twake icons render
90
+ const SelectIcon = props => (React.createElement(Icon, { icon: Bottom, ...props }));
91
+ const radioColors = [
92
+ 'primary',
93
+ 'secondary',
94
+ 'success',
95
+ 'error',
96
+ 'warning',
97
+ 'info'
98
+ ];
99
+ export const overrides = {
100
+ MuiButton: {
101
+ defaultProps: {
102
+ variant: 'contained',
103
+ disableElevation: true,
104
+ loadingPosition: 'end',
105
+ loadingIndicator: (React.createElement(Icon, { icon: Spinner, spin: true, "aria-hidden": true, focusable: "false" }))
106
+ },
107
+ styleOverrides: {
108
+ root: ({ theme }) => ({
109
+ borderRadius: radius.pill,
110
+ lineHeight: 'normal',
111
+ minHeight: 40,
112
+ padding: '10px 24px',
113
+ variants: [
114
+ {
115
+ props: { variant: 'outlined' },
116
+ style: { padding: '5px 15px', borderColor: 'currentColor' }
117
+ },
118
+ {
119
+ props: { variant: 'text' },
120
+ style: { minWidth: 'auto', padding: '10px 8px' }
121
+ },
122
+ {
123
+ props: { variant: 'ghost' },
124
+ style: {
125
+ padding: '5px 15px',
126
+ color: theme.vars.palette.text.primary,
127
+ backgroundColor: theme.alpha(theme.vars.palette.primary.main, 0.25),
128
+ '@media (hover: hover)': {
129
+ '&:hover': {
130
+ backgroundColor: theme.alpha(theme.vars.palette.primary.main, 0.32)
131
+ }
132
+ },
133
+ [`&.${buttonClasses.disabled}`]: {
134
+ backgroundColor: 'transparent',
135
+ border: `1px solid ${theme.vars.palette.action.disabledBackground}`
136
+ }
137
+ }
138
+ },
139
+ ...buttonGhostColors.map(color => ({
140
+ props: { variant: 'ghost', color },
141
+ style: {
142
+ color: theme.vars.palette[color].main,
143
+ backgroundColor: theme.alpha(theme.vars.palette[color].main, 0.08),
144
+ '@media (hover: hover)': {
145
+ '&:hover': {
146
+ backgroundColor: theme.alpha(theme.vars.palette[color].main, 0.16)
147
+ }
148
+ }
149
+ }
150
+ })),
151
+ // Vertical paddings sit 1px under cozy-ui's so the outlined border
152
+ // still fits the fixed heights cozy-ui forces (36, 40, 48).
153
+ {
154
+ props: { size: 'small' },
155
+ style: {
156
+ minHeight: 36,
157
+ padding: '9px 16px',
158
+ fontSize: theme.typography.pxToRem(13)
159
+ }
160
+ },
161
+ {
162
+ props: { size: 'small', variant: 'text' },
163
+ style: { padding: '8px 16px' }
164
+ },
165
+ {
166
+ props: { size: 'large' },
167
+ style: {
168
+ minHeight: 48,
169
+ padding: '13px 32px',
170
+ fontSize: theme.typography.pxToRem(15)
171
+ }
172
+ },
173
+ {
174
+ props: { size: 'large', variant: 'text' },
175
+ style: { padding: '14px 10px' }
176
+ }
177
+ ]
178
+ }),
179
+ // Keep the end spinner where cozy-ui's inline endIcon sat, i.e. at the
180
+ // horizontal padding of each variant and size.
181
+ loadingIndicator: {
182
+ variants: [
183
+ { props: { loadingPosition: 'end' }, style: { right: 24 } },
184
+ {
185
+ props: { loadingPosition: 'end', variant: 'outlined' },
186
+ style: { right: 15 }
187
+ },
188
+ {
189
+ props: { loadingPosition: 'end', variant: 'ghost' },
190
+ style: { right: 15 }
191
+ },
192
+ {
193
+ props: { loadingPosition: 'end', variant: 'text' },
194
+ style: { right: 8 }
195
+ },
196
+ {
197
+ props: { loadingPosition: 'end', size: 'small' },
198
+ style: { right: 16 }
199
+ },
200
+ {
201
+ props: { loadingPosition: 'end', size: 'large' },
202
+ style: { right: 32 }
203
+ },
204
+ {
205
+ props: { loadingPosition: 'end', size: 'large', variant: 'text' },
206
+ style: { right: 10 }
207
+ }
208
+ ]
209
+ }
210
+ }
211
+ },
212
+ MuiOutlinedInput: {
213
+ styleOverrides: {
214
+ root: ({ theme }) => ({
215
+ borderRadius: radius.sm,
216
+ [`&.${outlinedInputClasses.disabled}`]: {
217
+ background: theme.vars.palette.background.contrast
218
+ },
219
+ [`&:hover .${outlinedInputClasses.notchedOutline}`]: {
220
+ borderColor: theme.vars.palette.text.disabled
221
+ },
222
+ [`&.${outlinedInputClasses.focused} .${outlinedInputClasses.notchedOutline}`]: {
223
+ borderWidth: 1
224
+ },
225
+ [`&.${outlinedInputClasses.error} .${outlinedInputClasses.notchedOutline}`]: {
226
+ borderColor: theme.alpha(theme.vars.palette.error.main, theme.vars.palette.border.opacity)
227
+ },
228
+ [`&.${outlinedInputClasses.error}:hover .${outlinedInputClasses.notchedOutline}, &.${outlinedInputClasses.error}.${outlinedInputClasses.focused} .${outlinedInputClasses.notchedOutline}`]: {
229
+ borderColor: theme.vars.palette.error.main
230
+ },
231
+ variants: [
232
+ {
233
+ props: ({ ownerState }) => !!ownerState.startAdornment,
234
+ style: { paddingLeft: 16 }
235
+ },
236
+ {
237
+ props: ({ ownerState }) => !!ownerState.endAdornment,
238
+ style: { paddingRight: 16 }
239
+ },
240
+ {
241
+ props: ({ ownerState }) => !!ownerState.multiline,
242
+ style: { padding: '16.5px 16px' }
243
+ },
244
+ {
245
+ props: ({ ownerState }) => !!ownerState.multiline && ownerState.size === 'small',
246
+ style: { padding: '12.5px 16px' }
247
+ }
248
+ ]
249
+ }),
250
+ notchedOutline: ({ theme }) => ({
251
+ borderColor: theme.vars.palette.border.main,
252
+ transition: theme.transitions.create('border-color', {
253
+ duration: theme.transitions.duration.shorter
254
+ })
255
+ }),
256
+ // 16px gutters, and a 48px small field where MUI has 40px
257
+ input: {
258
+ variants: [
259
+ {
260
+ props: ({ ownerState }) => !ownerState.multiline && !ownerState.startAdornment,
261
+ style: { paddingLeft: 16 }
262
+ },
263
+ {
264
+ props: ({ ownerState }) => !ownerState.multiline && !ownerState.endAdornment,
265
+ style: { paddingRight: 16 }
266
+ },
267
+ {
268
+ props: ({ ownerState }) => !ownerState.multiline && ownerState.size === 'small',
269
+ style: { paddingTop: 12.5, paddingBottom: 12.5 }
270
+ }
271
+ ]
272
+ }
273
+ }
274
+ },
275
+ MuiInputLabel: {
276
+ styleOverrides: {
277
+ root: ({ theme }) => ({
278
+ variants: [
279
+ {
280
+ props: ({ ownerState }) => ownerState.variant === 'outlined' &&
281
+ ownerState.size === 'small' &&
282
+ !ownerState.shrink,
283
+ style: { transform: 'translate(14px, 12px) scale(1)' }
284
+ },
285
+ {
286
+ // cozy-ui keeps the resting label grey even in error
287
+ props: ({ ownerState }) => ownerState.variant === 'outlined' && !ownerState.shrink,
288
+ style: {
289
+ [`&.${formLabelClasses.error}`]: {
290
+ color: theme.vars.palette.text.secondary
291
+ }
292
+ }
293
+ }
294
+ ]
295
+ })
296
+ }
297
+ },
298
+ MuiFormLabel: {
299
+ styleOverrides: {
300
+ root: ({ theme }) => ({
301
+ [`&.${formLabelClasses.disabled}.${formLabelClasses.error}`]: {
302
+ color: theme.vars.palette.text.disabled
303
+ }
304
+ })
305
+ }
306
+ },
307
+ MuiFormHelperText: {
308
+ styleOverrides: {
309
+ root: ({ theme }) => ({
310
+ fontStyle: 'italic',
311
+ fontSize: theme.typography.pxToRem(14),
312
+ marginTop: 4,
313
+ [`&.${formHelperTextClasses.disabled}.${formHelperTextClasses.error}`]: {
314
+ color: theme.vars.palette.text.disabled
315
+ }
316
+ })
317
+ }
318
+ },
319
+ MuiSelect: {
320
+ defaultProps: { IconComponent: SelectIcon },
321
+ styleOverrides: {
322
+ icon: ({ theme }) => ({
323
+ right: 14,
324
+ top: 'calc(50% - 8px)',
325
+ color: theme.vars.palette.text.icon,
326
+ [`&.${selectClasses.disabled}`]: {
327
+ color: theme.vars.palette.text.disabled
328
+ }
329
+ }),
330
+ outlined: {
331
+ '&&': { paddingRight: 39 }
332
+ }
333
+ }
334
+ },
335
+ MuiAutocomplete: {
336
+ styleOverrides: {
337
+ root: {
338
+ // Using "&&" to increase CSS specificity
339
+ '&&': {
340
+ '& .MuiOutlinedInput-root': {
341
+ paddingLeft: '16px',
342
+ borderRadius: radius.sm,
343
+ '& fieldset.MuiOutlinedInput-notchedOutline': {
344
+ borderRadius: radius.sm
345
+ },
346
+ '&.MuiInputBase-sizeSmall': {
347
+ paddingTop: '8px',
348
+ paddingBottom: '8px',
349
+ paddingLeft: '16px',
350
+ '& .MuiAutocomplete-input': {
351
+ padding: '0px 4px 0px 8px'
352
+ }
353
+ }
354
+ }
355
+ }
356
+ },
357
+ // Styling for chips in Autocomplete
358
+ tag: {
359
+ margin: '2px'
360
+ }
361
+ }
362
+ },
363
+ MuiDialog: {
364
+ defaultProps: { disableEnforceFocus: true },
365
+ styleOverrides: {
366
+ paper: ({ theme }) => ({
367
+ width: '100%',
368
+ '&.small': {
369
+ maxWidth: 480,
370
+ [theme.breakpoints.down('lg')]: {
371
+ margin: 16,
372
+ padding: '0 8px 8px',
373
+ height: 'auto',
374
+ maxHeight: 'calc(100% - 32px)',
375
+ borderRadius: 6
376
+ }
377
+ },
378
+ '&.medium': { maxWidth: 544 },
379
+ '&.large': { maxWidth: 800 },
380
+ '&.full': { maxWidth: '100%' }
381
+ }),
382
+ paperFullScreen: {
383
+ '&.small, &.medium, &.large': { maxWidth: '100%' }
384
+ }
385
+ }
386
+ },
387
+ MuiDialogTitle: {
388
+ styleOverrides: {
389
+ root: ({ theme }) => ({
390
+ ...theme.typography.h3,
391
+ boxSizing: 'border-box',
392
+ width: '100%',
393
+ padding: '1.5rem 2rem',
394
+ [theme.breakpoints.down('md')]: {
395
+ ...theme.typography.h4,
396
+ padding: '0.75rem 1rem'
397
+ },
398
+ // padding base + button width + button margin
399
+ '&.dialogTitleWithBack': {
400
+ paddingLeft: '4rem',
401
+ [theme.breakpoints.down('md')]: { paddingLeft: '3rem' }
402
+ },
403
+ '&.dialogTitleWithClose': {
404
+ paddingRight: '4rem',
405
+ [theme.breakpoints.down('md')]: { paddingRight: '3rem' }
406
+ }
407
+ })
408
+ }
409
+ },
410
+ MuiDialogContent: {
411
+ styleOverrides: {
412
+ root: ({ theme }) => ({
413
+ padding: '24px 32px 0',
414
+ [theme.breakpoints.down('md')]: { padding: '24px 16px 0' },
415
+ // MUI drops the top padding after a title, cozy-ui keeps it
416
+ [`.${dialogTitleClasses.root} + &`]: { paddingTop: 24 }
417
+ })
418
+ }
419
+ },
420
+ MuiDialogActions: {
421
+ styleOverrides: {
422
+ root: ({ theme }) => ({
423
+ margin: '16px 32px',
424
+ padding: 0,
425
+ [theme.breakpoints.down('md')]: {
426
+ margin: '8px 16px',
427
+ '& button': { flexGrow: 1 }
428
+ },
429
+ '& > :not(style) ~ :not(style)': { marginLeft: 4 }
430
+ })
431
+ }
432
+ },
433
+ MuiDivider: {
434
+ defaultProps: { textAlign: 'left' },
435
+ styleOverrides: {
436
+ root: {
437
+ variants: [
438
+ {
439
+ props: { variant: 'inset' },
440
+ style: { marginLeft: 64 }
441
+ },
442
+ {
443
+ props: ({ ownerState }) => !!ownerState.children &&
444
+ ownerState.textAlign === 'left' &&
445
+ ownerState.orientation !== 'vertical',
446
+ style: {
447
+ '&::before': { width: 0 },
448
+ '&::after': { width: '100%' }
449
+ }
450
+ }
451
+ ]
452
+ },
453
+ wrapper: ({ theme }) => ({
454
+ ...theme.typography.body2,
455
+ paddingLeft: 8,
456
+ paddingRight: 8,
457
+ variants: [
458
+ {
459
+ props: { textAlign: 'left', orientation: 'horizontal' },
460
+ style: { paddingLeft: 0 }
461
+ }
462
+ ]
463
+ })
464
+ }
465
+ },
466
+ MuiChip: {
467
+ styleOverrides: {
468
+ root: {
469
+ '&.square': {
470
+ borderRadius: radius.md
471
+ }
472
+ }
473
+ }
474
+ },
475
+ MuiBadge: {
476
+ defaultProps: {
477
+ overlap: 'circular',
478
+ showZero: true
479
+ },
480
+ styleOverrides: {
481
+ badge: ({ theme }) => ({
482
+ boxSizing: 'content-box',
483
+ height: 14,
484
+ minWidth: 14,
485
+ padding: 0,
486
+ border: `2px solid ${theme.palette.background.paper}`,
487
+ borderRadius: '100%',
488
+ fontSize: theme.typography.pxToRem(10)
489
+ }),
490
+ dot: {
491
+ height: 8,
492
+ minWidth: 8
493
+ },
494
+ anchorOriginTopRightRectangular: {
495
+ transform: 'scale(1) translate(37%, -37%)'
496
+ },
497
+ anchorOriginBottomRightRectangular: {
498
+ transform: 'scale(1) translate(37%, 37%)'
499
+ },
500
+ anchorOriginBottomLeftRectangular: {
501
+ transform: 'scale(1) translate(-37%, 37%)'
502
+ },
503
+ anchorOriginTopLeftRectangular: {
504
+ transform: 'scale(1) translate(-37%, -37%)'
505
+ }
506
+ }
507
+ },
508
+ MuiAvatar: {
509
+ styleOverrides: {
510
+ root: ({ theme }) => ({
511
+ fontWeight: 600,
512
+ ...makeAvatarSizes(theme),
513
+ '&.disabled': {
514
+ color: theme.vars.palette.primary.contrastText,
515
+ // cozy-ui's legacy `silver`, the same in both modes
516
+ background: '#d6d8da',
517
+ '& img': {
518
+ filter: 'grayscale(1) brightness(2)',
519
+ opacity: 0.5
520
+ }
521
+ },
522
+ '&.displayInline': {
523
+ display: 'inline-flex'
524
+ },
525
+ '&.border': {
526
+ border: `2px solid ${theme.vars.palette.background.paper}`
527
+ },
528
+ '&.innerBorder': {
529
+ boxShadow: `inset 0 0 0 1px ${theme.vars.palette.border.main}`
530
+ }
531
+ }),
532
+ colorDefault: ({ theme }) => ({
533
+ backgroundColor: theme.vars.palette.background.paper,
534
+ color: theme.vars.palette.text.secondary
535
+ })
536
+ }
537
+ },
538
+ MuiAvatarGroup: {
539
+ styleOverrides: {
540
+ root: ({ theme }) => ({
541
+ '& > div:last-child': {
542
+ boxShadow: `inset 0 0 0 1px ${theme.vars.palette.border.main}`
543
+ }
544
+ }),
545
+ avatar: ({ theme }) => ({
546
+ border: `2px solid ${theme.vars.palette.background.paper}`
547
+ })
548
+ }
549
+ },
550
+ MuiToggleButtonGroup: {
551
+ styleOverrides: {
552
+ root: ({ theme }) => ({
553
+ borderColor: theme.palette.secondary.dark,
554
+ '& .MuiToggleButton-root:not(.Mui-selected)': {
555
+ color: theme.palette.text.secondary,
556
+ backgroundColor: alpha(theme.palette.text.secondary, 0.08),
557
+ '& svg, & .MuiSvgIcon-root': {
558
+ color: theme.palette.text.secondary
559
+ }
560
+ }
561
+ })
562
+ }
563
+ },
564
+ MuiToggleButton: {
565
+ styleOverrides: {
566
+ root: ({ theme }) => ({
567
+ color: theme.palette.text.primary,
568
+ '&.Mui-selected': {
569
+ color: theme.palette.text.primary,
570
+ backgroundColor: 'transparent',
571
+ '&:hover': {
572
+ backgroundColor: 'transparent'
573
+ },
574
+ '& svg, & .MuiSvgIcon-root': {
575
+ color: theme.palette.primary.main
576
+ }
577
+ },
578
+ variants: [
579
+ {
580
+ props: { size: 'medium' },
581
+ style: {
582
+ padding: '9px 24px'
583
+ }
584
+ }
585
+ ]
586
+ })
587
+ }
588
+ },
589
+ MuiIconButton: {
590
+ defaultProps: { size: 'large' },
591
+ styleOverrides: {
592
+ root: ({ theme }) => ({
593
+ variants: [
594
+ {
595
+ props: { color: 'default' },
596
+ style: {
597
+ color: theme.palette.text.secondary
598
+ }
599
+ },
600
+ {
601
+ props: { size: 'xsmall' },
602
+ style: {
603
+ padding: '5px'
604
+ }
605
+ },
606
+ {
607
+ props: { size: 'small' },
608
+ style: {
609
+ padding: '8px'
610
+ }
611
+ },
612
+ {
613
+ props: { size: 'medium' },
614
+ style: {
615
+ padding: '12px'
616
+ }
617
+ },
618
+ {
619
+ props: { size: 'large' },
620
+ style: {
621
+ padding: '16px'
622
+ }
623
+ }
624
+ ]
625
+ })
626
+ }
627
+ },
628
+ MuiCheckbox: {
629
+ defaultProps: { checkedIcon: React.createElement(Icon, { icon: CheckSquare }) },
630
+ styleOverrides: {
631
+ root: ({ theme }) => ({
632
+ padding: 8,
633
+ // MUI colours an indeterminate box on its own, cozy-ui only once it is
634
+ // also checked
635
+ [`&.${checkboxClasses.indeterminate}:not(.${checkboxClasses.checked}):not(.${checkboxClasses.disabled})`]: {
636
+ color: theme.vars.palette.text.secondary
637
+ },
638
+ '& svg.twake-icon': {
639
+ boxSizing: 'content-box',
640
+ width: 18,
641
+ height: 18,
642
+ padding: 3
643
+ },
644
+ variants: [
645
+ {
646
+ props: { size: 'small' },
647
+ style: {
648
+ padding: 6,
649
+ '& svg.twake-icon': { width: 16, height: 16, padding: 2 }
650
+ }
651
+ }
652
+ ]
653
+ })
654
+ }
655
+ },
656
+ MuiRadio: {
657
+ defaultProps: {
658
+ icon: React.createElement(Icon, { icon: RadioUnchecked }),
659
+ checkedIcon: React.createElement(Icon, { icon: RadioChecked })
660
+ },
661
+ styleOverrides: {
662
+ root: ({ theme }) => ({
663
+ padding: 12,
664
+ '& svg': { fill: theme.vars.palette.border.main },
665
+ variants: [
666
+ ...radioColors.map(color => ({
667
+ props: { color },
668
+ style: {
669
+ [`&.${radioClasses.checked} svg`]: {
670
+ fill: theme.vars.palette[color].main
671
+ }
672
+ }
673
+ })),
674
+ {
675
+ props: { disabled: true },
676
+ style: {
677
+ '& svg': {
678
+ borderRadius: '50%',
679
+ backgroundColor: theme.vars.palette.background.contrast
680
+ },
681
+ [`&.${radioClasses.checked} svg`]: {
682
+ fill: theme.vars.palette.text.disabled
683
+ }
684
+ }
685
+ }
686
+ ]
687
+ })
688
+ }
689
+ },
690
+ MuiSnackbar: {
691
+ defaultProps: {
692
+ anchorOrigin: { vertical: 'bottom', horizontal: 'center' },
693
+ autoHideDuration: 2000
694
+ }
695
+ },
696
+ MuiSnackbarContent: {
697
+ styleOverrides: {
698
+ root: ({ theme }) => ({
699
+ padding: '4px 12px',
700
+ backgroundColor: theme.vars.palette.grey[600]
701
+ })
702
+ }
703
+ },
704
+ MuiSwitch: {
705
+ styleOverrides: {
706
+ root: {
707
+ width: 56,
708
+ height: 40,
709
+ padding: '6px 1px',
710
+ justifyContent: 'center'
711
+ },
712
+ switchBase: ({ theme }) => ({
713
+ padding: 5,
714
+ top: 5,
715
+ left: 5,
716
+ color: theme.vars.palette.text.icon,
717
+ [`&.${switchClasses.checked}`]: { transform: 'translateX(15px)' },
718
+ [`&.${switchClasses.checked} + .${switchClasses.track}`]: {
719
+ opacity: 1
720
+ },
721
+ [`&.${switchClasses.disabled}, &.${switchClasses.checked}.${switchClasses.disabled}`]: {
722
+ color: theme.vars.palette.grey[400]
723
+ },
724
+ [`&.${switchClasses.disabled} + .${switchClasses.track}, &.${switchClasses.checked}.${switchClasses.disabled} + .${switchClasses.track}`]: {
725
+ opacity: 1,
726
+ backgroundColor: theme.vars.palette.action.disabledBackground
727
+ },
728
+ // The Switch wrapper draws its own thumb so it can hold an icon
729
+ '& .switchThumb': {
730
+ display: 'flex',
731
+ alignItems: 'center',
732
+ justifyContent: 'center',
733
+ width: 20,
734
+ height: 20,
735
+ borderRadius: '50%',
736
+ boxShadow: theme.vars.shadows[1],
737
+ backgroundColor: theme.vars.palette.common.white
738
+ },
739
+ [`&.${switchClasses.disabled} .switchThumb, &.${switchClasses.disabled} .${switchClasses.thumb}`]: {
740
+ backgroundColor: theme.vars.palette.background.default
741
+ },
742
+ variants: [
743
+ {
744
+ // cozy-ui draws the secondary colour as success
745
+ props: { color: 'secondary' },
746
+ style: {
747
+ [`&.${switchClasses.checked}`]: {
748
+ color: theme.vars.palette.success.main
749
+ },
750
+ [`&.${switchClasses.checked} + .${switchClasses.track}`]: {
751
+ backgroundColor: theme.vars.palette.success.main
752
+ }
753
+ }
754
+ }
755
+ ]
756
+ }),
757
+ thumb: ({ theme }) => ({
758
+ backgroundColor: theme.vars.palette.common.white
759
+ }),
760
+ track: ({ theme }) => ({
761
+ width: 44,
762
+ height: '100%',
763
+ borderRadius: 100,
764
+ opacity: 1,
765
+ backgroundColor: theme.vars.palette.text.disabled
766
+ })
767
+ }
768
+ },
769
+ MuiTabs: {
770
+ styleOverrides: {
771
+ root: ({ theme }) => ({
772
+ '&.segmented': {
773
+ borderRadius: 99,
774
+ backgroundColor: theme.vars.palette.background.contrast,
775
+ overflow: 'visible',
776
+ minHeight: 40,
777
+ [`& .${tabsClasses.indicator}`]: {
778
+ top: 1,
779
+ height: 'calc(100% - 2px)',
780
+ transform: 'scale(0.99)',
781
+ borderRadius: 99,
782
+ zIndex: 0,
783
+ boxShadow: theme.vars.shadows[1],
784
+ backgroundColor: theme.vars.palette.background.paper
785
+ },
786
+ [`& .${tabsClasses.fixed}`]: { overflow: 'visible !important' },
787
+ [`& .${tabsClasses.scrollButtons}`]: { borderRadius: 99 },
788
+ [`& .${tabClasses.root}`]: {
789
+ ...theme.typography.body2,
790
+ textTransform: 'initial',
791
+ zIndex: 1,
792
+ borderRadius: 99,
793
+ minHeight: 40,
794
+ [`&.${tabClasses.selected}`]: {
795
+ color: theme.vars.palette.text.primary
796
+ }
797
+ }
798
+ },
799
+ [`&.narrowed .${tabClasses.root}`]: { minWidth: 'auto' },
800
+ variants: [
801
+ {
802
+ // cozy-ui stretches standard tabs across the width on mobile
803
+ props: { variant: 'standard' },
804
+ style: {
805
+ [theme.breakpoints.down('md')]: {
806
+ [`& .${tabClasses.root}`]: {
807
+ flexShrink: 1,
808
+ flexGrow: 1,
809
+ flexBasis: 0,
810
+ maxWidth: 'none'
811
+ }
812
+ }
813
+ }
814
+ }
815
+ ]
816
+ })
817
+ }
818
+ },
819
+ MuiTab: {
820
+ styleOverrides: {
821
+ root: ({ theme }) => ({
822
+ ...theme.typography.subtitle2,
823
+ minWidth: 72,
824
+ padding: '6px 12px',
825
+ [theme.breakpoints.up('sm')]: { minWidth: 160 },
826
+ [`&:hover:not(.${tabClasses.selected}):not(.${tabClasses.disabled})`]: {
827
+ color: theme.vars.palette.text.primary,
828
+ opacity: 1
829
+ },
830
+ [`&:focus:not(.${tabClasses.selected}):not(.${tabClasses.disabled})`]: {
831
+ color: theme.vars.palette.text.primary
832
+ }
833
+ })
834
+ }
835
+ },
836
+ MuiTypography: {
837
+ styleOverrides: {
838
+ root: ({ theme }) => ({
839
+ variants: [
840
+ {
841
+ // cozy-ui greys captions unless a colour is asked for
842
+ props: ({ ownerState }) => ownerState.variant === 'caption' && !ownerState.color,
843
+ style: { color: theme.vars.palette.text.secondary }
844
+ }
845
+ ]
846
+ })
847
+ }
848
+ },
849
+ MuiAlert: {
850
+ // cozy-ui's 16px icons; the icon padding below centres them on the first
851
+ // line of the message.
852
+ defaultProps: {
853
+ iconMapping: {
854
+ primary: React.createElement(Icon, { icon: Info }),
855
+ secondary: React.createElement(Icon, { icon: Info }),
856
+ success: React.createElement(Icon, { icon: CheckCircle }),
857
+ warning: React.createElement(Icon, { icon: Warning }),
858
+ error: React.createElement(Icon, { icon: WarningCircle }),
859
+ info: React.createElement(Icon, { icon: Info })
860
+ }
861
+ },
862
+ styleOverrides: {
863
+ root: {
864
+ padding: '8px 16px',
865
+ variants: alertSeverityVariants
866
+ },
867
+ icon: {
868
+ paddingTop: '9px'
869
+ },
870
+ message: {
871
+ flex: 'auto',
872
+ display: 'flex',
873
+ alignItems: 'center',
874
+ flexWrap: 'wrap'
875
+ },
876
+ action: {
877
+ alignItems: 'center',
878
+ paddingTop: 0
879
+ }
880
+ }
881
+ },
882
+ MuiAlertTitle: {
883
+ styleOverrides: {
884
+ root: {
885
+ width: '100%',
886
+ fontWeight: 'bold'
887
+ }
888
+ }
889
+ },
890
+ MuiAccordion: {
891
+ styleOverrides: {
892
+ root: {
893
+ '&::before': {
894
+ display: 'none'
895
+ }
896
+ }
897
+ }
898
+ },
899
+ MuiAccordionSummary: {
900
+ defaultProps: { expandIcon: React.createElement(AccordionExpandIcon, null) },
901
+ styleOverrides: {
902
+ root: ({ theme }) => ({
903
+ backgroundColor: theme.palette.grey[100],
904
+ textTransform: 'uppercase',
905
+ fontWeight: 'bold',
906
+ fontSize: '0.875rem',
907
+ minHeight: '3.5rem',
908
+ padding: 0,
909
+ color: theme.palette.text.primary,
910
+ '&.Mui-expanded': {
911
+ minHeight: '3.5rem'
912
+ }
913
+ }),
914
+ expandIconWrapper: {
915
+ order: 0,
916
+ '&&': {
917
+ marginLeft: '0.3125rem'
918
+ },
919
+ transform: 'rotate(-90deg)',
920
+ '&.Mui-expanded': {
921
+ marginLeft: '0.3125rem',
922
+ transform: 'rotate(0deg)'
923
+ }
924
+ },
925
+ content: {
926
+ margin: '0.75rem 0',
927
+ paddingLeft: '0.5rem',
928
+ paddingRight: '0.25rem',
929
+ order: 1,
930
+ '& > :last-child': {
931
+ paddingRight: 0
932
+ },
933
+ '&.Mui-expanded': {
934
+ margin: '0.75rem 0'
935
+ }
936
+ }
937
+ }
938
+ },
939
+ MuiFab: {
940
+ defaultProps: { size: 'medium' },
941
+ styleOverrides: {
942
+ root: ({ theme }) => ({
943
+ borderRadius: 28,
944
+ width: 96,
945
+ height: 96,
946
+ color: theme.palette.text.primary,
947
+ backgroundColor: theme.palette.background.paper,
948
+ '&:hover': {
949
+ backgroundColor: darken(theme.palette.background.paper, 0.05)
950
+ },
951
+ '@media (hover: none)': {
952
+ backgroundColor: theme.palette.background.paper
953
+ }
954
+ }),
955
+ primary: ({ theme }) => ({
956
+ color: theme.palette.primary.dark,
957
+ backgroundColor: theme.palette.primary.light,
958
+ '&:hover': {
959
+ backgroundColor: darken(theme.palette.primary.light, 0.05)
960
+ },
961
+ '@media (hover: none)': {
962
+ backgroundColor: theme.palette.primary.light
963
+ }
964
+ }),
965
+ extended: {
966
+ borderRadius: 16,
967
+ width: 'auto',
968
+ height: 56,
969
+ minWidth: 56,
970
+ padding: '0 20px',
971
+ '&.MuiFab-sizeSmall': {
972
+ borderRadius: 16,
973
+ width: 'auto',
974
+ height: 42,
975
+ minWidth: 42,
976
+ padding: '0 12px'
977
+ },
978
+ '&.MuiFab-sizeMedium': {
979
+ borderRadius: 16,
980
+ width: 'auto',
981
+ height: 48,
982
+ minWidth: 48,
983
+ padding: '0 16px'
984
+ }
985
+ },
986
+ sizeSmall: {
987
+ borderRadius: 12,
988
+ width: 40,
989
+ height: 40
990
+ },
991
+ sizeMedium: {
992
+ borderRadius: 16,
993
+ width: 56,
994
+ height: 56
995
+ }
996
+ }
997
+ },
998
+ MuiTooltip: {
999
+ defaultProps: { arrow: true },
1000
+ styleOverrides: {
1001
+ tooltip: ({ theme }) => ({
1002
+ backgroundColor: alpha(theme.palette.grey[800], 0.9),
1003
+ fontSize: '1rem',
1004
+ lineHeight: 1.3,
1005
+ borderRadius: '4px',
1006
+ padding: '8px 12px'
1007
+ })
1008
+ }
1009
+ },
1010
+ MuiMenuItem: {
1011
+ styleOverrides: {
1012
+ root: ({ theme }) => ({
1013
+ borderRadius: radius.md,
1014
+ '&&&:hover': {
1015
+ backgroundColor: `${alpha(theme.palette.primary.main, theme.palette.action.hoverOpacity)}`
1016
+ },
1017
+ [`&.${menuItemClasses.selected}`]: {
1018
+ backgroundColor: alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity),
1019
+ '&:hover': {
1020
+ backgroundColor: alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity +
1021
+ theme.palette.action.hoverOpacity)
1022
+ }
1023
+ }
1024
+ })
1025
+ }
1026
+ }
1027
+ };