cozy-ui 121.0.0 → 121.1.1
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 +15 -0
- package/dist/cozy-ui.min.css +1 -1
- package/dist/cozy-ui.utils.min.css +1 -1
- package/package.json +1 -1
- package/react/Avatar/Readme.md +41 -21
- package/react/Avatar/helpers.js +13 -2
- package/react/Avatar/index.jsx +26 -5
- package/react/Buttons/Readme.md +1 -0
- package/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +156 -0
- package/react/MuiCozyTheme/overrides/twake/makeLightNormalOverrides.js +7 -19
- package/react/ToggleButton/Readme.md +60 -0
- package/react/ToggleButton/index.js +24 -1
- package/react/ToggleButtonGroup/Readme.md +79 -17
- package/stylus/cozy-ui/build.styl +2 -0
- package/stylus/utilities/border.styl +8 -0
- package/transpiled/react/Avatar/helpers.d.ts +1 -1
- package/transpiled/react/Avatar/helpers.js +16 -2
- package/transpiled/react/Avatar/index.js +11 -5
- package/transpiled/react/MuiCozyTheme/overrides/makeDarkInvertedOverrides.d.ts +150 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeDarkNormalOverrides.d.ts +150 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightInvertedOverrides.d.ts +150 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.d.ts +150 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +151 -0
- package/transpiled/react/MuiCozyTheme/overrides/twake/makeDarkInvertedOverrides.d.ts +157 -19
- package/transpiled/react/MuiCozyTheme/overrides/twake/makeDarkNormalOverrides.d.ts +157 -19
- package/transpiled/react/MuiCozyTheme/overrides/twake/makeLightInvertedOverrides.d.ts +157 -19
- package/transpiled/react/MuiCozyTheme/overrides/twake/makeLightNormalOverrides.d.ts +157 -19
- package/transpiled/react/MuiCozyTheme/overrides/twake/makeLightNormalOverrides.js +7 -19
- package/transpiled/react/ToggleButton/index.js +26 -1
package/react/Avatar/Readme.md
CHANGED
|
@@ -8,24 +8,41 @@ import { supportedColors } from 'cozy-ui/transpiled/react/Avatar/helpers'
|
|
|
8
8
|
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
9
9
|
import LinkIcon from "cozy-ui/transpiled/react/Icons/Link"
|
|
10
10
|
import cozyLogo from '../../docs/cozy-logo_white_128.png'
|
|
11
|
+
import Variants from 'cozy-ui/docs/components/Variants'
|
|
11
12
|
|
|
12
13
|
const sizes = ['xs', 's', 'm', 'l', 'xl']
|
|
14
|
+
const initialVariants = [{ disabled: false }]
|
|
13
15
|
|
|
14
16
|
;
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
<Variants initialVariants={initialVariants} screenshotAllVariants>
|
|
19
|
+
{variant => (
|
|
20
|
+
sizes.map(size => (
|
|
21
|
+
<div className="u-mb-half u-flex u-flex-items-center" key={size}>
|
|
22
|
+
<AvatarGroup style={{ zIndex: 2 }} max={4} size={size}>
|
|
23
|
+
<Avatar size={size} color={supportedColors[0]} disabled={variant.disabled}>AB</Avatar>
|
|
24
|
+
<Avatar size={size} color={supportedColors[1]} disabled={variant.disabled}>BC</Avatar>
|
|
25
|
+
<Avatar size={size} src={cozyLogo} disabled={variant.disabled} />
|
|
26
|
+
<Avatar size={size} color={supportedColors[4]} disabled={variant.disabled}>EF</Avatar>
|
|
27
|
+
<Avatar size={size} color={supportedColors[5]} disabled={variant.disabled}>FG</Avatar>
|
|
28
|
+
</AvatarGroup>
|
|
29
|
+
<Avatar
|
|
30
|
+
style={{ marginLeft: `-${spacingByAvatarSize[size]}px`, zIndex: 1 }}
|
|
31
|
+
size={size} color={supportedColors[2]}
|
|
32
|
+
color="none"
|
|
33
|
+
border
|
|
34
|
+
innerBorder
|
|
35
|
+
disabled={variant.disabled}
|
|
36
|
+
>
|
|
37
|
+
<Icon icon={LinkIcon} />
|
|
38
|
+
</Avatar>
|
|
39
|
+
</div>
|
|
40
|
+
))
|
|
41
|
+
)}
|
|
42
|
+
</Variants>
|
|
26
43
|
```
|
|
27
44
|
|
|
28
|
-
###
|
|
45
|
+
### Solo
|
|
29
46
|
|
|
30
47
|
```jsx
|
|
31
48
|
import cozyLogo from '../../docs/cozy-logo_white_128.png'
|
|
@@ -40,7 +57,7 @@ import Variants from 'cozy-ui/docs/components/Variants'
|
|
|
40
57
|
|
|
41
58
|
const sizes = ['xs', 's', 'm', 'l', 'xl']
|
|
42
59
|
|
|
43
|
-
const initialVariants = [{ disabled: false }]
|
|
60
|
+
const initialVariants = [{ disabled: false, border: false, innerBorder: false }]
|
|
44
61
|
|
|
45
62
|
;
|
|
46
63
|
|
|
@@ -51,20 +68,23 @@ const initialVariants = [{ disabled: false }]
|
|
|
51
68
|
<div key={color} className="u-flex u-flex-items-center u-mb-half" style={{ gap: '0.5rem' }}>
|
|
52
69
|
{sizes.map(size => (
|
|
53
70
|
<React.Fragment key={size}>
|
|
54
|
-
<Avatar size={size} color={color} disabled={variant.disabled} />
|
|
55
|
-
<Avatar size={size} color={color} disabled={variant.disabled}>AB</Avatar>
|
|
56
|
-
<Avatar size={size} color={color} disabled={variant.disabled}><Icon icon={LinkIcon} /></Avatar>
|
|
71
|
+
<Avatar size={size} color={color} disabled={variant.disabled} border={variant.border} innerBorder={variant.innerBorder} />
|
|
72
|
+
<Avatar size={size} color={color} disabled={variant.disabled} border={variant.border} innerBorder={variant.innerBorder}>AB</Avatar>
|
|
73
|
+
<Avatar size={size} color={color} disabled={variant.disabled} border={variant.border} innerBorder={variant.innerBorder}><Icon icon={LinkIcon} /></Avatar>
|
|
57
74
|
</React.Fragment>
|
|
58
75
|
))}
|
|
59
76
|
</div>
|
|
60
77
|
))}
|
|
61
78
|
<div className="u-flex u-flex-items-center u-mb-half" style={{ gap: '0.5rem' }}>
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
79
|
+
<Avatar src={cozyLogo} disabled={variant.disabled} border={variant.border} innerBorder={variant.innerBorder} />
|
|
80
|
+
<Avatar color="none" src={cozyLogo} disabled={variant.disabled} border={variant.border} innerBorder={variant.innerBorder} />
|
|
81
|
+
<Avatar color="sunrise" src={cozyLogo} disabled={variant.disabled} border={variant.border} innerBorder={variant.innerBorder} />
|
|
82
|
+
<Avatar disabled={variant.disabled} border={variant.border} innerBorder={variant.innerBorder} />
|
|
83
|
+
<Avatar color="none" disabled={variant.disabled} border={variant.border} innerBorder={variant.innerBorder} />
|
|
84
|
+
<Avatar color="sunrise" disabled={variant.disabled} border={variant.border} innerBorder={variant.innerBorder} />
|
|
85
|
+
<Avatar disabled={variant.disabled} border={variant.border} innerBorder={variant.innerBorder}>AB</Avatar>
|
|
86
|
+
<Avatar color="none" disabled={variant.disabled} border={variant.border} innerBorder={variant.innerBorder}>BC</Avatar>
|
|
87
|
+
<Avatar color="sunrise" disabled={variant.disabled} border={variant.border} innerBorder={variant.innerBorder}>CD</Avatar>
|
|
68
88
|
</div>
|
|
69
89
|
</>
|
|
70
90
|
)}
|
package/react/Avatar/helpers.js
CHANGED
|
@@ -40,6 +40,17 @@ export const colorMapping = {
|
|
|
40
40
|
pluviophile: 'linear-gradient(136deg, #A1D6F4 14.84%, #52CEC2 96.03%)',
|
|
41
41
|
cornflower: 'linear-gradient(135deg, #86D9D3 0%, #1CCFB4 100%)',
|
|
42
42
|
paleGreen: 'linear-gradient(135deg, #E2FA17 0%, #75D8CB 100%)',
|
|
43
|
-
moonBlue: 'linear-gradient(136deg, #6DCFFF 14.84%, #3D88F8 96.03%)'
|
|
44
|
-
|
|
43
|
+
moonBlue: 'linear-gradient(136deg, #6DCFFF 14.84%, #3D88F8 96.03%)'
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const colors = Object.values(supportedColors).filter(Boolean)
|
|
47
|
+
|
|
48
|
+
const makeKey = (colors, name) =>
|
|
49
|
+
Array.from(name.toUpperCase())
|
|
50
|
+
.map(letter => letter.charCodeAt(0))
|
|
51
|
+
.reduce((sum, number) => sum + number, 0) % colors.length
|
|
52
|
+
|
|
53
|
+
export const nameToColor = (name = '') => {
|
|
54
|
+
const key = makeKey(colors, name)
|
|
55
|
+
return colors[key]
|
|
45
56
|
}
|
package/react/Avatar/index.jsx
CHANGED
|
@@ -3,7 +3,7 @@ import cx from 'classnames'
|
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
4
|
import React from 'react'
|
|
5
5
|
|
|
6
|
-
import { colorMapping } from './helpers'
|
|
6
|
+
import { colorMapping, supportedColors, nameToColor } from './helpers'
|
|
7
7
|
import { makeStyles } from '../styles'
|
|
8
8
|
|
|
9
9
|
const useStyles = makeStyles(theme => ({
|
|
@@ -13,13 +13,34 @@ const useStyles = makeStyles(theme => ({
|
|
|
13
13
|
}
|
|
14
14
|
}))
|
|
15
15
|
|
|
16
|
-
const Avatar = ({
|
|
17
|
-
|
|
16
|
+
const Avatar = ({
|
|
17
|
+
className,
|
|
18
|
+
color,
|
|
19
|
+
size,
|
|
20
|
+
border,
|
|
21
|
+
innerBorder,
|
|
22
|
+
disabled,
|
|
23
|
+
...props
|
|
24
|
+
}) => {
|
|
25
|
+
const defaultColor =
|
|
26
|
+
typeof props.children === 'string' ? nameToColor(props.children) : undefined
|
|
27
|
+
const classes = useStyles({
|
|
28
|
+
color:
|
|
29
|
+
color === 'none'
|
|
30
|
+
? undefined
|
|
31
|
+
: supportedColors.includes(color)
|
|
32
|
+
? color
|
|
33
|
+
: defaultColor
|
|
34
|
+
})
|
|
18
35
|
|
|
19
36
|
return (
|
|
20
37
|
<AvatarMui
|
|
21
38
|
classes={classes}
|
|
22
|
-
className={cx(className, `size-${size}`, {
|
|
39
|
+
className={cx(className, `size-${size}`, {
|
|
40
|
+
disabled: !!disabled,
|
|
41
|
+
border: !!border,
|
|
42
|
+
innerBorder: !!innerBorder
|
|
43
|
+
})}
|
|
23
44
|
{...props}
|
|
24
45
|
/>
|
|
25
46
|
)
|
|
@@ -31,7 +52,7 @@ Avatar.propTypes = {
|
|
|
31
52
|
PropTypes.oneOf(['xs', 's', 'm', 'l', 'xl']),
|
|
32
53
|
PropTypes.number
|
|
33
54
|
]),
|
|
34
|
-
color: PropTypes.
|
|
55
|
+
color: PropTypes.oneOf([...supportedColors, 'none']),
|
|
35
56
|
disabled: PropTypes.bool
|
|
36
57
|
}
|
|
37
58
|
|
package/react/Buttons/Readme.md
CHANGED
|
@@ -72,6 +72,91 @@ export const makeLightNormalOverrides = theme => ({
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
|
+
MuiToggleButtonGroup: {
|
|
76
|
+
groupedHorizontal: {
|
|
77
|
+
'&.rounded': {
|
|
78
|
+
marginRight: 12,
|
|
79
|
+
'&:last-child': {
|
|
80
|
+
marginRight: 0
|
|
81
|
+
},
|
|
82
|
+
'&:not(:first-child)': {
|
|
83
|
+
borderTopLeftRadius: 'inherit',
|
|
84
|
+
borderBottomLeftRadius: 'inherit',
|
|
85
|
+
marginLeft: 'inherit',
|
|
86
|
+
borderLeft: 'inherit'
|
|
87
|
+
},
|
|
88
|
+
'&:not(:last-child)': {
|
|
89
|
+
'&.rounded': {
|
|
90
|
+
borderTopRightRadius: 'inherit',
|
|
91
|
+
borderBottomRightRadius: 'inherit'
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
MuiToggleButton: {
|
|
98
|
+
root: {
|
|
99
|
+
borderRadius: 0,
|
|
100
|
+
color: theme.palette.text.secondary,
|
|
101
|
+
border: `1px solid ${theme.palette.border.main}`,
|
|
102
|
+
padding: 15,
|
|
103
|
+
'&$selected': {
|
|
104
|
+
color: theme.palette.text.primary,
|
|
105
|
+
backgroundColor: 'transparent',
|
|
106
|
+
'&:not($disabled)': {
|
|
107
|
+
'&.customColor': {
|
|
108
|
+
'&-primary': {
|
|
109
|
+
color: theme.palette.primary.main
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
'&$disabled': {
|
|
115
|
+
color: theme.palette.text.disabled
|
|
116
|
+
},
|
|
117
|
+
'&.rounded': {
|
|
118
|
+
border: 0,
|
|
119
|
+
borderRadius: theme.shape.borderRadius,
|
|
120
|
+
padding: '10px 12px',
|
|
121
|
+
'&$selected': {
|
|
122
|
+
backgroundColor: theme.palette.action.selected,
|
|
123
|
+
'&:not($disabled)': {
|
|
124
|
+
'&.customColor': {
|
|
125
|
+
'&-primary': {
|
|
126
|
+
color: theme.palette.text.primary,
|
|
127
|
+
backgroundColor: alpha(
|
|
128
|
+
theme.palette.primary.main,
|
|
129
|
+
theme.palette.action.selectedOpacity
|
|
130
|
+
),
|
|
131
|
+
'&:hover': {
|
|
132
|
+
textDecoration: 'none',
|
|
133
|
+
backgroundColor: alpha(
|
|
134
|
+
theme.palette.primary.main,
|
|
135
|
+
theme.palette.action.activatedOpacity
|
|
136
|
+
),
|
|
137
|
+
'@media (hover: none)': {
|
|
138
|
+
backgroundColor: 'transparent'
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
sizeSmall: {
|
|
148
|
+
padding: 11,
|
|
149
|
+
'&.rounded': {
|
|
150
|
+
padding: '7px 10px'
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
sizeLarge: {
|
|
154
|
+
padding: 19,
|
|
155
|
+
'&.rounded': {
|
|
156
|
+
padding: 12
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
75
160
|
MuiButton: {
|
|
76
161
|
root: {
|
|
77
162
|
borderRadius: 2,
|
|
@@ -616,6 +701,77 @@ export const makeLightNormalOverrides = theme => ({
|
|
|
616
701
|
}
|
|
617
702
|
}
|
|
618
703
|
},
|
|
704
|
+
MuiAvatarGroup: {
|
|
705
|
+
avatar: {
|
|
706
|
+
border: `2px solid ${theme.palette.background.paper}`
|
|
707
|
+
}
|
|
708
|
+
},
|
|
709
|
+
MuiAvatar: {
|
|
710
|
+
root: {
|
|
711
|
+
fontWeight: 600,
|
|
712
|
+
'&.size': {
|
|
713
|
+
'&-xs': {
|
|
714
|
+
width: 16,
|
|
715
|
+
height: 16,
|
|
716
|
+
fontSize: 8,
|
|
717
|
+
'& svg': {
|
|
718
|
+
width: 8,
|
|
719
|
+
height: 8
|
|
720
|
+
}
|
|
721
|
+
},
|
|
722
|
+
'&-s': {
|
|
723
|
+
width: 24,
|
|
724
|
+
height: 24,
|
|
725
|
+
fontSize: 12,
|
|
726
|
+
'& svg': {
|
|
727
|
+
width: 12,
|
|
728
|
+
height: 12
|
|
729
|
+
}
|
|
730
|
+
},
|
|
731
|
+
'&-m': {
|
|
732
|
+
width: 32,
|
|
733
|
+
height: 32,
|
|
734
|
+
fontSize: 16,
|
|
735
|
+
'& svg': {
|
|
736
|
+
width: 16,
|
|
737
|
+
height: 16
|
|
738
|
+
}
|
|
739
|
+
},
|
|
740
|
+
'&-l': {
|
|
741
|
+
width: 48,
|
|
742
|
+
height: 48,
|
|
743
|
+
fontSize: 24,
|
|
744
|
+
'& svg': {
|
|
745
|
+
width: 24,
|
|
746
|
+
height: 24
|
|
747
|
+
}
|
|
748
|
+
},
|
|
749
|
+
'&-xl': {
|
|
750
|
+
width: 64,
|
|
751
|
+
height: 64,
|
|
752
|
+
fontSize: 32,
|
|
753
|
+
'& svg': {
|
|
754
|
+
width: 32,
|
|
755
|
+
height: 32
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
},
|
|
759
|
+
'&.disabled': {
|
|
760
|
+
color: theme.palette.primary.contrastText,
|
|
761
|
+
background: 'var(--silver)', // should be semantic but used legacy component color for now
|
|
762
|
+
'& img': {
|
|
763
|
+
filter: 'grayscale(1) brightness(2)',
|
|
764
|
+
opacity: 0.5
|
|
765
|
+
}
|
|
766
|
+
},
|
|
767
|
+
'&.border': {
|
|
768
|
+
border: `2px solid ${theme.palette.background.paper}`
|
|
769
|
+
},
|
|
770
|
+
'&.innerBorder': {
|
|
771
|
+
boxShadow: `inset 0px 0px 0px 1px ${theme.palette.border.main}`
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
},
|
|
619
775
|
MuiCheckbox: {
|
|
620
776
|
colorSecondary: {
|
|
621
777
|
'&$checked': {
|
|
@@ -171,22 +171,23 @@ export const makeLightNormalTwakeOverrides = theme => {
|
|
|
171
171
|
height: 56
|
|
172
172
|
}
|
|
173
173
|
},
|
|
174
|
+
MuiAvatarGroup: {
|
|
175
|
+
root: {
|
|
176
|
+
'& > div:last-child': {
|
|
177
|
+
boxShadow: `inset 0px 0px 0px 1px ${theme.palette.border.main}`
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
174
181
|
MuiAvatar: {
|
|
175
182
|
root: {
|
|
176
|
-
fontWeight: 600,
|
|
177
183
|
'&.size': {
|
|
178
184
|
'&-xs': {
|
|
179
|
-
width: 16,
|
|
180
|
-
height: 16,
|
|
181
|
-
fontSize: 8,
|
|
182
185
|
'& svg': {
|
|
183
186
|
width: 10,
|
|
184
187
|
height: 10
|
|
185
188
|
}
|
|
186
189
|
},
|
|
187
190
|
'&-s': {
|
|
188
|
-
width: 24,
|
|
189
|
-
height: 24,
|
|
190
191
|
fontSize: 11,
|
|
191
192
|
'& svg': {
|
|
192
193
|
width: 16,
|
|
@@ -194,36 +195,23 @@ export const makeLightNormalTwakeOverrides = theme => {
|
|
|
194
195
|
}
|
|
195
196
|
},
|
|
196
197
|
'&-m': {
|
|
197
|
-
width: 32,
|
|
198
|
-
height: 32,
|
|
199
|
-
fontSize: 16,
|
|
200
198
|
'& svg': {
|
|
201
199
|
width: 20,
|
|
202
200
|
height: 20
|
|
203
201
|
}
|
|
204
202
|
},
|
|
205
203
|
'&-l': {
|
|
206
|
-
width: 48,
|
|
207
|
-
height: 48,
|
|
208
|
-
fontSize: 24,
|
|
209
204
|
'& svg': {
|
|
210
205
|
width: 28,
|
|
211
206
|
height: 28
|
|
212
207
|
}
|
|
213
208
|
},
|
|
214
209
|
'&-xl': {
|
|
215
|
-
width: 64,
|
|
216
|
-
height: 64,
|
|
217
|
-
fontSize: 32,
|
|
218
210
|
'& svg': {
|
|
219
211
|
width: 36,
|
|
220
212
|
height: 36
|
|
221
213
|
}
|
|
222
214
|
}
|
|
223
|
-
},
|
|
224
|
-
'&.disabled': {
|
|
225
|
-
color: theme.palette.primary.contrastText,
|
|
226
|
-
background: theme.palette.action.disabledBackground
|
|
227
215
|
}
|
|
228
216
|
},
|
|
229
217
|
colorDefault: {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
```jsx
|
|
2
|
+
import { useState } from 'react'
|
|
3
|
+
import ToggleButton from 'cozy-ui/transpiled/react/ToggleButton'
|
|
4
|
+
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
5
|
+
import HeartIcon from 'cozy-ui/transpiled/react/Icons/Heart'
|
|
6
|
+
import Stack from 'cozy-ui/transpiled/react/Stack'
|
|
7
|
+
import Grid from 'cozy-ui/transpiled/react/Grid'
|
|
8
|
+
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
9
|
+
import Variants from 'cozy-ui/docs/components/Variants'
|
|
10
|
+
|
|
11
|
+
initialVariants = [{ small: false, large: false }]
|
|
12
|
+
const cols = ['default', 'default-disabled', 'primary', 'primary-disabled']
|
|
13
|
+
const rows = ['square', 'rounded']
|
|
14
|
+
|
|
15
|
+
const makeSize = variant => Object.keys(variant).filter(key => variant[key])[0]
|
|
16
|
+
|
|
17
|
+
;
|
|
18
|
+
|
|
19
|
+
<Variants initialVariants={initialVariants} screenshotAllVariants>
|
|
20
|
+
{variant => (
|
|
21
|
+
<Grid container>
|
|
22
|
+
{cols.map(col =>
|
|
23
|
+
<Grid item xs={12} sm={12 / cols.length} className="u-mb-1" key={JSON.stringify(col)}>
|
|
24
|
+
<Stack spacing="s">
|
|
25
|
+
<Typography variant="h5">{col}</Typography>
|
|
26
|
+
{rows.map(row =>
|
|
27
|
+
<div key={row + JSON.stringify(col)}>
|
|
28
|
+
<Typography gutterBottom>{row}</Typography>
|
|
29
|
+
<div style={{ display: "flex", gap: "0.5rem" }}>
|
|
30
|
+
<ToggleButton
|
|
31
|
+
value="list"
|
|
32
|
+
aria-label="list"
|
|
33
|
+
rounded={row.includes('rounded')}
|
|
34
|
+
color={col.replace('-disabled','')}
|
|
35
|
+
size={makeSize(variant)}
|
|
36
|
+
disabled={col.includes('disabled')}
|
|
37
|
+
>
|
|
38
|
+
<Icon icon={HeartIcon} />
|
|
39
|
+
</ToggleButton>
|
|
40
|
+
<ToggleButton
|
|
41
|
+
value="list"
|
|
42
|
+
aria-label="list"
|
|
43
|
+
rounded={row.includes('rounded')}
|
|
44
|
+
color={col.replace('-disabled','')}
|
|
45
|
+
selected
|
|
46
|
+
size={makeSize(variant)}
|
|
47
|
+
disabled={col.includes('disabled')}
|
|
48
|
+
>
|
|
49
|
+
<Icon icon={HeartIcon} />
|
|
50
|
+
</ToggleButton>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
)}
|
|
54
|
+
</Stack>
|
|
55
|
+
</Grid>
|
|
56
|
+
)}
|
|
57
|
+
</Grid>
|
|
58
|
+
)}
|
|
59
|
+
</Variants>
|
|
60
|
+
```
|
|
@@ -1,3 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import MuiToggleButton from '@material-ui/lab/ToggleButton'
|
|
2
|
+
import cx from 'classnames'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
import React, { forwardRef } from 'react'
|
|
5
|
+
|
|
6
|
+
const ToggleButton = forwardRef(
|
|
7
|
+
({ className, rounded, color, ...props }, ref) => {
|
|
8
|
+
return (
|
|
9
|
+
<MuiToggleButton
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cx(className, { rounded }, `customColor-${color}`)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
ToggleButton.displayName = 'ToggleButton'
|
|
19
|
+
|
|
20
|
+
ToggleButton.propTypes = {
|
|
21
|
+
className: PropTypes.string,
|
|
22
|
+
rounded: PropTypes.bool,
|
|
23
|
+
color: PropTypes.string
|
|
24
|
+
}
|
|
2
25
|
|
|
3
26
|
export default ToggleButton
|
|
@@ -1,28 +1,90 @@
|
|
|
1
1
|
```jsx
|
|
2
|
+
import { useState } from 'react'
|
|
2
3
|
import ToggleButton from 'cozy-ui/transpiled/react/ToggleButton'
|
|
3
4
|
import ToggleButtonGroup from 'cozy-ui/transpiled/react/ToggleButtonGroup'
|
|
4
5
|
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
5
|
-
import
|
|
6
|
-
import
|
|
6
|
+
import ListIcon from 'cozy-ui/transpiled/react/Icons/List'
|
|
7
|
+
import MosaicIcon from 'cozy-ui/transpiled/react/Icons/MosaicMin'
|
|
8
|
+
import GroupListIcon from 'cozy-ui/transpiled/react/Icons/GroupList'
|
|
9
|
+
import Stack from 'cozy-ui/transpiled/react/Stack'
|
|
10
|
+
import Grid from 'cozy-ui/transpiled/react/Grid'
|
|
11
|
+
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
12
|
+
import Variants from 'cozy-ui/docs/components/Variants'
|
|
7
13
|
|
|
14
|
+
initialVariants = [{ small: false, large: false, third: false }]
|
|
15
|
+
const cols = ['default', 'default-disabled', 'primary', 'primary-disabled']
|
|
16
|
+
const rows = ['square', 'rounded']
|
|
8
17
|
|
|
9
|
-
|
|
18
|
+
const ToggleGroup = ({ row, col, variant }) => {
|
|
19
|
+
const [value, setValue] = useState('list')
|
|
20
|
+
const handleChange = (ev, newValue) => {
|
|
21
|
+
if (newValue !== null) {
|
|
22
|
+
setValue(newValue)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
10
25
|
|
|
11
|
-
const
|
|
26
|
+
const size = Object.keys(variant).filter(key => variant[key])[0]
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<ToggleButtonGroup
|
|
30
|
+
variant={row}
|
|
31
|
+
value={value}
|
|
32
|
+
aria-label="list display"
|
|
33
|
+
exclusive
|
|
34
|
+
size={size}
|
|
35
|
+
onChange={handleChange}
|
|
36
|
+
>
|
|
37
|
+
<ToggleButton
|
|
38
|
+
value="list"
|
|
39
|
+
aria-label="list"
|
|
40
|
+
rounded={row.includes('rounded')}
|
|
41
|
+
color={col.replace('-disabled','')}
|
|
42
|
+
disabled={col.includes('disabled')}
|
|
43
|
+
>
|
|
44
|
+
<Icon icon={ListIcon} />
|
|
45
|
+
</ToggleButton>
|
|
46
|
+
<ToggleButton
|
|
47
|
+
value="mosaic"
|
|
48
|
+
aria-label="mosaic"
|
|
49
|
+
rounded={row.includes('rounded')}
|
|
50
|
+
color={col.replace('-disabled','')}
|
|
51
|
+
disabled={col.includes('disabled')}
|
|
52
|
+
>
|
|
53
|
+
<Icon icon={MosaicIcon} />
|
|
54
|
+
</ToggleButton>
|
|
55
|
+
{variant.third && (
|
|
56
|
+
<ToggleButton
|
|
57
|
+
value="grouplist"
|
|
58
|
+
aria-label="grouplist"
|
|
59
|
+
rounded={row.includes('rounded')}
|
|
60
|
+
color={col.replace('-disabled','')}
|
|
61
|
+
disabled={col.includes('disabled')}
|
|
62
|
+
>
|
|
63
|
+
<Icon icon={GroupListIcon} />
|
|
64
|
+
</ToggleButton>
|
|
65
|
+
)}
|
|
66
|
+
</ToggleButtonGroup>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
12
69
|
|
|
13
70
|
;
|
|
14
71
|
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
</
|
|
72
|
+
<Variants initialVariants={initialVariants} screenshotAllVariants>
|
|
73
|
+
{variant => (
|
|
74
|
+
<Grid container>
|
|
75
|
+
{cols.map(col =>
|
|
76
|
+
<Grid item xs={12} sm={12 / cols.length} className="u-mb-1" key={JSON.stringify(col)}>
|
|
77
|
+
<Stack spacing="s">
|
|
78
|
+
<Typography variant="h5">{col}</Typography>
|
|
79
|
+
{rows.map(row =>
|
|
80
|
+
<div key={row + JSON.stringify(col)}>
|
|
81
|
+
<ToggleGroup row={row} col={col} variant={variant} />
|
|
82
|
+
</div>
|
|
83
|
+
)}
|
|
84
|
+
</Stack>
|
|
85
|
+
</Grid>
|
|
86
|
+
)}
|
|
87
|
+
</Grid>
|
|
88
|
+
)}
|
|
89
|
+
</Variants>
|
|
28
90
|
```
|
|
@@ -1370,6 +1370,8 @@ Display an chip that represents complex identity
|
|
|
1370
1370
|
.u-bdrs-2 - 2nd step of border-radius (3px)
|
|
1371
1371
|
.u-bdrs-3 - 3rd step of border-radius (4px)
|
|
1372
1372
|
.u-bdrs-4 - 4th step of border-radius (8px)
|
|
1373
|
+
.u-bdrs-5 - 4th step of border-radius (10px)
|
|
1374
|
+
.u-bdrs-6 - 4th step of border-radius (12px)
|
|
1373
1375
|
.u-bdrs-circle - Round element with border-radius (100%)
|
|
1374
1376
|
|
|
1375
1377
|
Markup:
|
|
@@ -16,6 +16,12 @@ bdrs-3()
|
|
|
16
16
|
bdrs-4()
|
|
17
17
|
border-radius rem(8) !important // @stylint ignore
|
|
18
18
|
|
|
19
|
+
bdrs-5()
|
|
20
|
+
border-radius rem(10) !important // @stylint ignore
|
|
21
|
+
|
|
22
|
+
bdrs-6()
|
|
23
|
+
border-radius rem(12) !important // @stylint ignore
|
|
24
|
+
|
|
19
25
|
bdrs-circle()
|
|
20
26
|
border-radius 100% !important // @stylint ignore
|
|
21
27
|
|
|
@@ -30,6 +36,8 @@ props = {
|
|
|
30
36
|
'bdrs-2': 'bdrs-2',
|
|
31
37
|
'bdrs-3': 'bdrs-3',
|
|
32
38
|
'bdrs-4': 'bdrs-4',
|
|
39
|
+
'bdrs-5': 'bdrs-5',
|
|
40
|
+
'bdrs-6': 'bdrs-6',
|
|
33
41
|
'bdrs-circle': 'bdrs-circle',
|
|
34
42
|
'bdw-0': 'bdw-0',
|
|
35
43
|
'bdw-1': 'bdw-1'
|
|
@@ -25,6 +25,20 @@ export var colorMapping = {
|
|
|
25
25
|
pluviophile: 'linear-gradient(136deg, #A1D6F4 14.84%, #52CEC2 96.03%)',
|
|
26
26
|
cornflower: 'linear-gradient(135deg, #86D9D3 0%, #1CCFB4 100%)',
|
|
27
27
|
paleGreen: 'linear-gradient(135deg, #E2FA17 0%, #75D8CB 100%)',
|
|
28
|
-
moonBlue: 'linear-gradient(136deg, #6DCFFF 14.84%, #3D88F8 96.03%)'
|
|
29
|
-
|
|
28
|
+
moonBlue: 'linear-gradient(136deg, #6DCFFF 14.84%, #3D88F8 96.03%)'
|
|
29
|
+
};
|
|
30
|
+
var colors = Object.values(supportedColors).filter(Boolean);
|
|
31
|
+
|
|
32
|
+
var makeKey = function makeKey(colors, name) {
|
|
33
|
+
return Array.from(name.toUpperCase()).map(function (letter) {
|
|
34
|
+
return letter.charCodeAt(0);
|
|
35
|
+
}).reduce(function (sum, number) {
|
|
36
|
+
return sum + number;
|
|
37
|
+
}, 0) % colors.length;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export var nameToColor = function nameToColor() {
|
|
41
|
+
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
42
|
+
var key = makeKey(colors, name);
|
|
43
|
+
return colors[key];
|
|
30
44
|
};
|