cozy-ui 70.2.2 → 70.3.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/.bundlemonrc +1 -2
- package/CHANGELOG.md +24 -0
- package/package.json +2 -1
- package/react/Alert/Readme.md +132 -0
- package/react/Alert/index.jsx +115 -0
- package/react/AlertTitle/Readme.md +1 -0
- package/react/AlertTitle/index.jsx +3 -0
- package/react/BottomSheet/BackdropOrFragment.jsx +6 -2
- package/react/BottomSheet/BottomSheet.jsx +61 -62
- package/react/BottomSheet/constants.js +1 -0
- package/react/BottomSheet/helpers.js +17 -0
- package/react/BottomSheet/helpers.spec.js +50 -1
- package/react/CozyDialogs/styles.styl +2 -2
- package/react/MuiCozyTheme/makeOverrides.js +128 -1
- package/react/Snackbar/Readme.md +81 -1
- package/react/Snackbar/index.js +19 -1
- package/react/__snapshots__/examples.spec.jsx.snap +557 -303
- package/react/examples.spec.jsx +1 -0
- package/react/index.js +2 -0
- package/transpiled/react/Alert/index.js +106 -0
- package/transpiled/react/AlertTitle/index.js +2 -0
- package/transpiled/react/BottomSheet/BackdropOrFragment.js +3 -1
- package/transpiled/react/BottomSheet/BottomSheet.js +18 -18
- package/transpiled/react/BottomSheet/constants.js +1 -0
- package/transpiled/react/BottomSheet/helpers.js +15 -0
- package/transpiled/react/MuiCozyTheme/makeOverrides.js +118 -2
- package/transpiled/react/Snackbar/index.js +20 -1
- package/transpiled/react/index.js +3 -1
- package/transpiled/react/stylesheet.css +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { alpha } from '@material-ui/core/styles'
|
|
1
|
+
import { alpha, lighten, darken } from '@material-ui/core/styles'
|
|
2
2
|
|
|
3
3
|
const SWITCH_BAR_WIDTH = 25
|
|
4
4
|
|
|
@@ -9,6 +9,71 @@ export const makeThemeOverrides = theme => {
|
|
|
9
9
|
return createOverrides(theme)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
const makeAlertColor = (theme, color) => {
|
|
13
|
+
const themeColorByColor = {
|
|
14
|
+
primary: theme.palette[color].main,
|
|
15
|
+
secondary: theme.palette.text.primary
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// same approach as Mui, see https://github.com/mui/material-ui/blob/v4.x/packages/material-ui-lab/src/Alert/Alert.js#L28
|
|
19
|
+
return {
|
|
20
|
+
'&-standard': {
|
|
21
|
+
color: darken(themeColorByColor[color], 0.6),
|
|
22
|
+
backgroundColor: lighten(themeColorByColor[color], 0.9),
|
|
23
|
+
'& $icon': {
|
|
24
|
+
color: themeColorByColor[color]
|
|
25
|
+
},
|
|
26
|
+
'& $action': {
|
|
27
|
+
'& button[title="Close"]': {
|
|
28
|
+
color: theme.palette.text.secondary
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
'&-outlined': {
|
|
33
|
+
color: darken(themeColorByColor[color], 0.6),
|
|
34
|
+
border: `1px solid ${themeColorByColor[color]}`,
|
|
35
|
+
'& $icon': {
|
|
36
|
+
color: themeColorByColor[color]
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
'&-filled': {
|
|
40
|
+
backgroundColor:
|
|
41
|
+
color === 'secondary'
|
|
42
|
+
? theme.palette.grey[600]
|
|
43
|
+
: themeColorByColor[color]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const makeAlertInvertedColor = (theme, color) => {
|
|
49
|
+
return {
|
|
50
|
+
'&-standard': {
|
|
51
|
+
color: theme.palette.primary.main,
|
|
52
|
+
backgroundColor: theme.palette.background.default,
|
|
53
|
+
'& $icon': {
|
|
54
|
+
color: theme.palette[color].main
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
'&-outlined': {
|
|
58
|
+
color: theme.palette.primary.main,
|
|
59
|
+
border: `1px solid ${theme.palette.primary.main}`,
|
|
60
|
+
'& $icon': {
|
|
61
|
+
color: theme.palette[color].main
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
'&-filled': {
|
|
65
|
+
color: theme.palette[color].contrastText,
|
|
66
|
+
backgroundColor:
|
|
67
|
+
color === 'secondary'
|
|
68
|
+
? theme.palette.grey[200]
|
|
69
|
+
: theme.palette[color].main,
|
|
70
|
+
'& $icon': {
|
|
71
|
+
color: theme.palette[color].contrastText
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
12
77
|
const makeChipStyleByColor = (theme, color) => ({
|
|
13
78
|
color: theme.palette.text[color] || theme.palette[color].main,
|
|
14
79
|
borderColor:
|
|
@@ -822,6 +887,47 @@ const makeOverrides = theme => ({
|
|
|
822
887
|
'&-info': makeChipStyleByColor(theme, 'info')
|
|
823
888
|
}
|
|
824
889
|
}
|
|
890
|
+
},
|
|
891
|
+
MuiAlert: {
|
|
892
|
+
root: {
|
|
893
|
+
padding: '8px 16px',
|
|
894
|
+
'&.cozyAlert': {
|
|
895
|
+
'&-primary': makeAlertColor(theme, 'primary'),
|
|
896
|
+
'&-secondary': makeAlertColor(theme, 'secondary')
|
|
897
|
+
},
|
|
898
|
+
'& $icon': {
|
|
899
|
+
paddingTop: '9px'
|
|
900
|
+
},
|
|
901
|
+
'&.block': {
|
|
902
|
+
flexWrap: 'wrap',
|
|
903
|
+
'& $action': {
|
|
904
|
+
display: 'block',
|
|
905
|
+
width: '100%',
|
|
906
|
+
paddingLeft: 0,
|
|
907
|
+
textAlign: 'right'
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
},
|
|
911
|
+
message: {
|
|
912
|
+
display: 'flex',
|
|
913
|
+
alignItems: 'center',
|
|
914
|
+
flexWrap: 'wrap'
|
|
915
|
+
},
|
|
916
|
+
action: {
|
|
917
|
+
marginRight: '-6px'
|
|
918
|
+
}
|
|
919
|
+
},
|
|
920
|
+
MuiAlertTitle: {
|
|
921
|
+
root: {
|
|
922
|
+
width: '100%',
|
|
923
|
+
fontWeight: 'bold'
|
|
924
|
+
}
|
|
925
|
+
},
|
|
926
|
+
MuiSnackbarContent: {
|
|
927
|
+
root: {
|
|
928
|
+
padding: '4px 12px',
|
|
929
|
+
backgroundColor: theme.palette.grey[600]
|
|
930
|
+
}
|
|
825
931
|
}
|
|
826
932
|
})
|
|
827
933
|
|
|
@@ -883,6 +989,27 @@ const makeInvertedOverrides = invertedTheme => {
|
|
|
883
989
|
color: invertedTheme.palette.error.main
|
|
884
990
|
}
|
|
885
991
|
}
|
|
992
|
+
},
|
|
993
|
+
MuiAlert: {
|
|
994
|
+
...makeOverrides(invertedTheme).MuiAlert,
|
|
995
|
+
root: {
|
|
996
|
+
...makeOverrides(invertedTheme).MuiAlert.root,
|
|
997
|
+
'&.cozyAlert': {
|
|
998
|
+
'&-primary': makeAlertInvertedColor(invertedTheme, 'primary'),
|
|
999
|
+
'&-secondary': makeAlertInvertedColor(invertedTheme, 'secondary'),
|
|
1000
|
+
'&-success': makeAlertInvertedColor(invertedTheme, 'success'),
|
|
1001
|
+
'&-error': makeAlertInvertedColor(invertedTheme, 'error'),
|
|
1002
|
+
'&-warning': makeAlertInvertedColor(invertedTheme, 'warning'),
|
|
1003
|
+
'&-info': makeAlertInvertedColor(invertedTheme, 'info')
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
},
|
|
1007
|
+
MuiSnackbarContent: {
|
|
1008
|
+
...makeOverrides(invertedTheme).MuiSnackbarContent,
|
|
1009
|
+
root: {
|
|
1010
|
+
...makeOverrides(invertedTheme).MuiSnackbarContent.root,
|
|
1011
|
+
backgroundColor: invertedTheme.palette.grey[200]
|
|
1012
|
+
}
|
|
886
1013
|
}
|
|
887
1014
|
}
|
|
888
1015
|
|
package/react/Snackbar/Readme.md
CHANGED
|
@@ -1 +1,81 @@
|
|
|
1
|
-
|
|
1
|
+
```jsx
|
|
2
|
+
import Snackbar from 'cozy-ui/transpiled/react/Snackbar'
|
|
3
|
+
import Alert from 'cozy-ui/transpiled/react/Alert'
|
|
4
|
+
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
5
|
+
import CrossIcon from 'cozy-ui/transpiled/react/Icons/Cross'
|
|
6
|
+
import IconButton from 'cozy-ui/transpiled/react/IconButton'
|
|
7
|
+
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
8
|
+
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
9
|
+
import InfoIcon from 'cozy-ui/transpiled/react/Icons/Info'
|
|
10
|
+
|
|
11
|
+
initialState = { open: false }
|
|
12
|
+
|
|
13
|
+
const handleToggle = () => {setState(state => ({ open: !state.open }))}
|
|
14
|
+
|
|
15
|
+
;
|
|
16
|
+
|
|
17
|
+
<>
|
|
18
|
+
<Button
|
|
19
|
+
variant="ghost"
|
|
20
|
+
size="small"
|
|
21
|
+
label="Open snackbar"
|
|
22
|
+
onClick={handleToggle}
|
|
23
|
+
/>
|
|
24
|
+
<Snackbar
|
|
25
|
+
open={state.open}
|
|
26
|
+
message="This is a simple snackbar."
|
|
27
|
+
action={
|
|
28
|
+
<>
|
|
29
|
+
<Button variant="text" color="error" size="small" label="UNDO" onClick={handleToggle} />
|
|
30
|
+
<IconButton aria-label="close" color="inherit" onClick={handleToggle}>
|
|
31
|
+
<Icon icon={CrossIcon} size={14} />
|
|
32
|
+
</IconButton>
|
|
33
|
+
</>
|
|
34
|
+
}
|
|
35
|
+
onClose={handleToggle}
|
|
36
|
+
/>
|
|
37
|
+
</>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### With `Alert` inside the `Snackbar`
|
|
41
|
+
|
|
42
|
+
```jsx
|
|
43
|
+
import Snackbar from 'cozy-ui/transpiled/react/Snackbar'
|
|
44
|
+
import Alert from 'cozy-ui/transpiled/react/Alert'
|
|
45
|
+
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
46
|
+
import Variants from 'cozy-ui/docs/components/Variants'
|
|
47
|
+
|
|
48
|
+
initialState = { open: isTesting() }
|
|
49
|
+
|
|
50
|
+
const handleToggle = () => {setState(state => ({ open: !state.open }))}
|
|
51
|
+
|
|
52
|
+
const colors = ['primary', 'secondary', 'success', 'error', 'warning', 'info']
|
|
53
|
+
const initialVariants = [{ primary: true, secondary: true, success: false, error: false, warning: false, info: false }]
|
|
54
|
+
|
|
55
|
+
;
|
|
56
|
+
|
|
57
|
+
<>
|
|
58
|
+
<Variants initialVariants={initialVariants} radio>
|
|
59
|
+
{variant => (
|
|
60
|
+
<>
|
|
61
|
+
<Snackbar open={state.open} onClose={handleToggle}>
|
|
62
|
+
<Alert
|
|
63
|
+
variant="filled"
|
|
64
|
+
elevation={6}
|
|
65
|
+
severity={Object.keys(variant).find(key => variant[key])}
|
|
66
|
+
onClose={handleToggle}
|
|
67
|
+
>
|
|
68
|
+
This is a {Object.keys(variant).find(key => variant[key])} message!
|
|
69
|
+
</Alert>
|
|
70
|
+
</Snackbar>
|
|
71
|
+
</>
|
|
72
|
+
)}
|
|
73
|
+
</Variants>
|
|
74
|
+
<Button
|
|
75
|
+
variant="ghost"
|
|
76
|
+
size="small"
|
|
77
|
+
label="Open snackbar"
|
|
78
|
+
onClick={handleToggle}
|
|
79
|
+
/>
|
|
80
|
+
</>
|
|
81
|
+
```
|
package/react/Snackbar/index.js
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
1
2
|
import MuiSnackbar from '@material-ui/core/Snackbar'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
const Snackbar = forwardRef(({ children, ...props }, ref) => {
|
|
5
|
+
return (
|
|
6
|
+
<MuiSnackbar ref={ref} {...props}>
|
|
7
|
+
{children}
|
|
8
|
+
</MuiSnackbar>
|
|
9
|
+
)
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
Snackbar.displayName = 'Snackbar'
|
|
13
|
+
|
|
14
|
+
Snackbar.defaultProps = {
|
|
15
|
+
anchorOrigin: {
|
|
16
|
+
vertical: 'top',
|
|
17
|
+
horizontal: 'center'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default Snackbar
|