cozy-ui 54.0.0 → 54.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/CHANGELOG.md +12 -0
- package/package.json +1 -1
- package/react/Badge/Readme.md +27 -5
- package/react/Badge/index.jsx +58 -67
- package/react/MuiCozyTheme/theme.jsx +9 -0
- package/react/__snapshots__/examples.spec.jsx.snap +261 -264
- package/transpiled/react/Badge/index.js +54 -52
- package/transpiled/react/MuiCozyTheme/theme.js +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# [54.1.0](https://github.com/cozy/cozy-ui/compare/v54.0.0...v54.1.0) (2021-09-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Allow badge class to be extended ([ec2f6d5](https://github.com/cozy/cozy-ui/commit/ec2f6d5))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add withBorder prop ([87339a2](https://github.com/cozy/cozy-ui/commit/87339a2))
|
|
12
|
+
|
|
1
13
|
# [54.0.0](https://github.com/cozy/cozy-ui/compare/v53.0.0...v54.0.0) (2021-09-28)
|
|
2
14
|
|
|
3
15
|
|
package/package.json
CHANGED
package/react/Badge/Readme.md
CHANGED
|
@@ -14,21 +14,43 @@ import Variants from 'cozy-ui/docs/components/Variants';
|
|
|
14
14
|
import CircleFilledIcon from "cozy-ui/transpiled/react/Icons/CircleFilled";
|
|
15
15
|
|
|
16
16
|
const initialVariants = [
|
|
17
|
-
{ error: false, dot: false, large: false, small: false },
|
|
18
|
-
{ error: true, dot: true, large: false, small: false },
|
|
19
|
-
{ error: false, dot: false, large: false, small: false },
|
|
17
|
+
{ error: false, dot: false, large: false, small: false, withBorder: false },
|
|
18
|
+
{ error: true, dot: true, large: false, small: false, withBorder: true },
|
|
19
|
+
{ error: false, dot: false, large: false, small: false, withBorder: false },
|
|
20
20
|
];
|
|
21
21
|
|
|
22
|
+
testingProps = [
|
|
23
|
+
{ color: 'primary', variant: 'standard', size: 'small', vertical: 'top', horizontal: 'left', withBorder: false},
|
|
24
|
+
{ color: 'secondary', variant: 'dot', size: 'medium', vertical: 'bottom', horizontal: 'right', withBorder: true},
|
|
25
|
+
{ color: 'error', variant: 'standard', size: 'large', vertical: 'top', horizontal: 'left', withBorder: false},
|
|
26
|
+
{ color: 'secondary', variant: 'dot', size: 'small', vertical: 'top', horizontal: 'right', withBorder: true},
|
|
27
|
+
{ color: 'error', variant: 'standard', size: 'medium', vertical: 'bottom', horizontal: 'left', withBorder: false},
|
|
28
|
+
{ color: 'primary', variant: 'dot', size: 'large', vertical: 'top', horizontal: 'right', withBorder: true}
|
|
29
|
+
];
|
|
22
30
|
|
|
23
|
-
|
|
31
|
+
<>
|
|
32
|
+
{isTesting()
|
|
33
|
+
? <>
|
|
34
|
+
{testingProps.map(({color, variant, size, vertical, horizontal, withBorder}) =>
|
|
35
|
+
<p>
|
|
36
|
+
<h5>color = {color}, variant = {variant}, size = {size}, vertical = {vertical}, horizontal = {horizontal}, withBorder = {withBorder.toString()}</h5>
|
|
37
|
+
<Badge badgeContent={4} color={color} variant={variant} size={size} anchorOrigin={{vertical, horizontal}} withBorder={withBorder}>
|
|
38
|
+
<Icon icon={CircleFilledIcon} size={size === 'large' ? '32' : size === 'small' ? '16' : '24'} color="var(--slateGrey)" />
|
|
39
|
+
</Badge>
|
|
40
|
+
</p>
|
|
41
|
+
)}
|
|
42
|
+
</>
|
|
43
|
+
: <Variants initialVariants={initialVariants}>{
|
|
24
44
|
variant => (
|
|
25
45
|
<p>
|
|
26
|
-
<Badge badgeContent={4} color={variant.error ? 'error' : variant.secondaryColor ? 'secondary' : 'primary'} variant={variant.dot ? 'dot' : 'standard'} size={variant.large ? 'large' : variant.small ? 'small' : 'medium'} anchorOrigin={{vertical: variant.bottom ? 'bottom' : 'top', 'horizontal': variant.left ? 'left' : 'right'}}>
|
|
46
|
+
<Badge badgeContent={4} color={variant.error ? 'error' : variant.secondaryColor ? 'secondary' : 'primary'} variant={variant.dot ? 'dot' : 'standard'} size={variant.large ? 'large' : variant.small ? 'small' : 'medium'} anchorOrigin={{vertical: variant.bottom ? 'bottom' : 'top', 'horizontal': variant.left ? 'left' : 'right'}} withBorder={variant.withBorder}>
|
|
27
47
|
<Icon icon={CircleFilledIcon} size={variant.large ? '32' : variant.small ? '16' : '24'} color="var(--slateGrey)" />
|
|
28
48
|
</Badge>
|
|
29
49
|
</p>
|
|
30
50
|
)
|
|
31
51
|
}</Variants>
|
|
52
|
+
}
|
|
53
|
+
</>
|
|
32
54
|
```
|
|
33
55
|
|
|
34
56
|
### Double badges
|
package/react/Badge/index.jsx
CHANGED
|
@@ -2,21 +2,22 @@ import React from 'react'
|
|
|
2
2
|
import cx from 'classnames'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
4
|
import MuiBadge from '@material-ui/core/Badge'
|
|
5
|
-
import {
|
|
5
|
+
import { makeStyles } from '@material-ui/core/styles'
|
|
6
6
|
|
|
7
7
|
const LARGE_BADGE = '1.25rem'
|
|
8
8
|
const MEDIUM_BADGE = '1.125rem'
|
|
9
9
|
const SMALL_BADGE = '1rem'
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
11
|
+
const useStyles = makeStyles(theme => ({
|
|
12
|
+
colorPrimary: ({ withBorder }) => ({
|
|
13
|
+
border: withBorder ? `2px solid ${theme.palette.background.paper}` : 'none'
|
|
14
|
+
}),
|
|
15
|
+
colorSecondary: ({ withBorder }) => ({
|
|
16
|
+
border: withBorder ? `2px solid ${theme.palette.background.paper}` : 'none'
|
|
17
|
+
}),
|
|
18
|
+
colorError: ({ withBorder }) => ({
|
|
19
|
+
border: withBorder ? `2px solid ${theme.palette.background.paper}` : 'none'
|
|
20
|
+
}),
|
|
20
21
|
top: {
|
|
21
22
|
top: '16%'
|
|
22
23
|
},
|
|
@@ -49,74 +50,62 @@ const customStyles = theme => ({
|
|
|
49
50
|
lineHeight: '0',
|
|
50
51
|
padding: '0 3px'
|
|
51
52
|
},
|
|
52
|
-
colorPrimary: {
|
|
53
|
-
border: `2px solid ${theme.palette.primary.contrastText}`
|
|
54
|
-
},
|
|
55
|
-
colorSecondary: {
|
|
56
|
-
border: `2px solid ${theme.palette.secondary.contrastText}`
|
|
57
|
-
},
|
|
58
|
-
colorError: {
|
|
59
|
-
border: `2px solid ${theme.palette.error.contrastText}`
|
|
60
|
-
},
|
|
61
53
|
dot: {
|
|
62
|
-
borderRadius: '100%',
|
|
63
|
-
padding: 0,
|
|
64
54
|
'&$large': {
|
|
65
|
-
height:
|
|
66
|
-
minWidth:
|
|
55
|
+
height: '.875rem',
|
|
56
|
+
minWidth: '.875rem'
|
|
67
57
|
},
|
|
68
58
|
'&$medium': {
|
|
69
|
-
height:
|
|
70
|
-
minWidth:
|
|
59
|
+
height: '.75rem',
|
|
60
|
+
minWidth: '.75rem'
|
|
71
61
|
},
|
|
72
62
|
'&$small': {
|
|
73
|
-
height:
|
|
74
|
-
minWidth:
|
|
63
|
+
height: '.625rem',
|
|
64
|
+
minWidth: '.625rem'
|
|
75
65
|
}
|
|
76
66
|
}
|
|
77
|
-
})
|
|
67
|
+
}))
|
|
68
|
+
|
|
69
|
+
const Badge = ({ classes = {}, anchorOrigin, size, ...props }) => {
|
|
70
|
+
const {
|
|
71
|
+
colorPrimary,
|
|
72
|
+
colorSecondary,
|
|
73
|
+
colorError,
|
|
74
|
+
top,
|
|
75
|
+
bottom,
|
|
76
|
+
left,
|
|
77
|
+
right,
|
|
78
|
+
large,
|
|
79
|
+
medium,
|
|
80
|
+
small,
|
|
81
|
+
dot
|
|
82
|
+
} = useStyles(props)
|
|
78
83
|
|
|
79
|
-
const
|
|
80
|
-
({ classes, anchorOrigin, size, ...props }) => {
|
|
81
|
-
const {
|
|
82
|
-
badge,
|
|
83
|
-
colorPrimary,
|
|
84
|
-
colorSecondary,
|
|
85
|
-
colorError,
|
|
86
|
-
dot,
|
|
87
|
-
top,
|
|
88
|
-
bottom,
|
|
89
|
-
left,
|
|
90
|
-
right,
|
|
91
|
-
large,
|
|
92
|
-
medium,
|
|
93
|
-
small,
|
|
94
|
-
...customClasses
|
|
95
|
-
} = classes
|
|
96
|
-
const verticalClasses = { top, bottom }
|
|
97
|
-
const horizontalClasses = { left, right }
|
|
98
|
-
const sizeClasses = { large, medium, small }
|
|
84
|
+
const { badge: customBadge, ...customClasses } = classes
|
|
99
85
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
86
|
+
const verticalClasses = { top, bottom }
|
|
87
|
+
const horizontalClasses = { left, right }
|
|
88
|
+
const sizeClasses = { large, medium, small }
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<MuiBadge
|
|
92
|
+
classes={{
|
|
93
|
+
dot,
|
|
94
|
+
badge: cx(
|
|
95
|
+
verticalClasses[anchorOrigin.vertical],
|
|
96
|
+
horizontalClasses[anchorOrigin.horizontal],
|
|
97
|
+
sizeClasses[size],
|
|
103
98
|
colorPrimary,
|
|
104
99
|
colorSecondary,
|
|
105
100
|
colorError,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}}
|
|
115
|
-
{...props}
|
|
116
|
-
/>
|
|
117
|
-
)
|
|
118
|
-
}
|
|
119
|
-
)
|
|
101
|
+
customBadge
|
|
102
|
+
),
|
|
103
|
+
...customClasses
|
|
104
|
+
}}
|
|
105
|
+
{...props}
|
|
106
|
+
/>
|
|
107
|
+
)
|
|
108
|
+
}
|
|
120
109
|
|
|
121
110
|
Badge.propTypes = {
|
|
122
111
|
anchorOrigin: PropTypes.shape({
|
|
@@ -125,13 +114,15 @@ Badge.propTypes = {
|
|
|
125
114
|
}),
|
|
126
115
|
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
127
116
|
showZero: PropTypes.bool,
|
|
128
|
-
variant: PropTypes.oneOf(['standard', 'dot'])
|
|
117
|
+
variant: PropTypes.oneOf(['standard', 'dot']),
|
|
118
|
+
withBorder: PropTypes.bool
|
|
129
119
|
}
|
|
130
120
|
|
|
131
121
|
Badge.defaultProps = {
|
|
132
122
|
anchorOrigin: { horizontal: 'right', vertical: 'top' },
|
|
133
123
|
size: 'medium',
|
|
134
|
-
showZero: true
|
|
124
|
+
showZero: true,
|
|
125
|
+
withBorder: true
|
|
135
126
|
}
|
|
136
127
|
|
|
137
128
|
export default Badge
|