cozy-ui 121.0.0 → 121.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.
@@ -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 ToggleButton from '@material-ui/lab/ToggleButton'
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 PeopleIcon from 'cozy-ui/transpiled/react/Icons/People'
6
- import TrashIcon from 'cozy-ui/transpiled/react/Icons/Trash'
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
- initialState = { alignment: 'left' }
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 handleAlignment = (ev, value) => setState({ alignment: value })
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
- <ToggleButtonGroup
16
- value={state.alignment}
17
- exclusive
18
- onChange={handleAlignment}
19
- aria-label="text alignment"
20
- >
21
- <ToggleButton value="left" aria-label="left aligned">
22
- <Icon icon={PeopleIcon} />
23
- </ToggleButton>
24
- <ToggleButton value="right" aria-label="right aligned">
25
- <Icon icon={TrashIcon} />
26
- </ToggleButton>
27
- </ToggleButtonGroup>
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'
@@ -57,6 +57,85 @@ export function makeDarkInvertedOverrides(theme: any): {
57
57
  };
58
58
  };
59
59
  };
60
+ MuiToggleButtonGroup: {
61
+ groupedHorizontal: {
62
+ '&.rounded': {
63
+ marginRight: number;
64
+ '&:last-child': {
65
+ marginRight: number;
66
+ };
67
+ '&:not(:first-child)': {
68
+ borderTopLeftRadius: string;
69
+ borderBottomLeftRadius: string;
70
+ marginLeft: string;
71
+ borderLeft: string;
72
+ };
73
+ '&:not(:last-child)': {
74
+ '&.rounded': {
75
+ borderTopRightRadius: string;
76
+ borderBottomRightRadius: string;
77
+ };
78
+ };
79
+ };
80
+ };
81
+ };
82
+ MuiToggleButton: {
83
+ root: {
84
+ borderRadius: number;
85
+ color: any;
86
+ border: string;
87
+ padding: number;
88
+ '&$selected': {
89
+ color: any;
90
+ backgroundColor: string;
91
+ '&:not($disabled)': {
92
+ '&.customColor': {
93
+ '&-primary': {
94
+ color: any;
95
+ };
96
+ };
97
+ };
98
+ };
99
+ '&$disabled': {
100
+ color: any;
101
+ };
102
+ '&.rounded': {
103
+ border: number;
104
+ borderRadius: any;
105
+ padding: string;
106
+ '&$selected': {
107
+ backgroundColor: any;
108
+ '&:not($disabled)': {
109
+ '&.customColor': {
110
+ '&-primary': {
111
+ color: any;
112
+ backgroundColor: string;
113
+ '&:hover': {
114
+ textDecoration: string;
115
+ backgroundColor: string;
116
+ '@media (hover: none)': {
117
+ backgroundColor: string;
118
+ };
119
+ };
120
+ };
121
+ };
122
+ };
123
+ };
124
+ };
125
+ };
126
+ sizeSmall: {
127
+ padding: number;
128
+ '&.rounded': {
129
+ padding: string;
130
+ };
131
+ };
132
+ sizeLarge: {
133
+ padding: number;
134
+ '&.rounded': {
135
+ padding: number;
136
+ };
137
+ };
138
+ };
60
139
  MuiButton: {
61
140
  root: {
62
141
  borderRadius: number;
@@ -57,6 +57,85 @@ export function makeDarkNormalOverrides(theme: any): {
57
57
  };
58
58
  };
59
59
  };
60
+ MuiToggleButtonGroup: {
61
+ groupedHorizontal: {
62
+ '&.rounded': {
63
+ marginRight: number;
64
+ '&:last-child': {
65
+ marginRight: number;
66
+ };
67
+ '&:not(:first-child)': {
68
+ borderTopLeftRadius: string;
69
+ borderBottomLeftRadius: string;
70
+ marginLeft: string;
71
+ borderLeft: string;
72
+ };
73
+ '&:not(:last-child)': {
74
+ '&.rounded': {
75
+ borderTopRightRadius: string;
76
+ borderBottomRightRadius: string;
77
+ };
78
+ };
79
+ };
80
+ };
81
+ };
82
+ MuiToggleButton: {
83
+ root: {
84
+ borderRadius: number;
85
+ color: any;
86
+ border: string;
87
+ padding: number;
88
+ '&$selected': {
89
+ color: any;
90
+ backgroundColor: string;
91
+ '&:not($disabled)': {
92
+ '&.customColor': {
93
+ '&-primary': {
94
+ color: any;
95
+ };
96
+ };
97
+ };
98
+ };
99
+ '&$disabled': {
100
+ color: any;
101
+ };
102
+ '&.rounded': {
103
+ border: number;
104
+ borderRadius: any;
105
+ padding: string;
106
+ '&$selected': {
107
+ backgroundColor: any;
108
+ '&:not($disabled)': {
109
+ '&.customColor': {
110
+ '&-primary': {
111
+ color: any;
112
+ backgroundColor: string;
113
+ '&:hover': {
114
+ textDecoration: string;
115
+ backgroundColor: string;
116
+ '@media (hover: none)': {
117
+ backgroundColor: string;
118
+ };
119
+ };
120
+ };
121
+ };
122
+ };
123
+ };
124
+ };
125
+ };
126
+ sizeSmall: {
127
+ padding: number;
128
+ '&.rounded': {
129
+ padding: string;
130
+ };
131
+ };
132
+ sizeLarge: {
133
+ padding: number;
134
+ '&.rounded': {
135
+ padding: number;
136
+ };
137
+ };
138
+ };
60
139
  MuiButton: {
61
140
  root: {
62
141
  borderRadius: number;
@@ -57,6 +57,85 @@ export function makeLightInvertedOverrides(theme: any): {
57
57
  };
58
58
  };
59
59
  };
60
+ MuiToggleButtonGroup: {
61
+ groupedHorizontal: {
62
+ '&.rounded': {
63
+ marginRight: number;
64
+ '&:last-child': {
65
+ marginRight: number;
66
+ };
67
+ '&:not(:first-child)': {
68
+ borderTopLeftRadius: string;
69
+ borderBottomLeftRadius: string;
70
+ marginLeft: string;
71
+ borderLeft: string;
72
+ };
73
+ '&:not(:last-child)': {
74
+ '&.rounded': {
75
+ borderTopRightRadius: string;
76
+ borderBottomRightRadius: string;
77
+ };
78
+ };
79
+ };
80
+ };
81
+ };
82
+ MuiToggleButton: {
83
+ root: {
84
+ borderRadius: number;
85
+ color: any;
86
+ border: string;
87
+ padding: number;
88
+ '&$selected': {
89
+ color: any;
90
+ backgroundColor: string;
91
+ '&:not($disabled)': {
92
+ '&.customColor': {
93
+ '&-primary': {
94
+ color: any;
95
+ };
96
+ };
97
+ };
98
+ };
99
+ '&$disabled': {
100
+ color: any;
101
+ };
102
+ '&.rounded': {
103
+ border: number;
104
+ borderRadius: any;
105
+ padding: string;
106
+ '&$selected': {
107
+ backgroundColor: any;
108
+ '&:not($disabled)': {
109
+ '&.customColor': {
110
+ '&-primary': {
111
+ color: any;
112
+ backgroundColor: string;
113
+ '&:hover': {
114
+ textDecoration: string;
115
+ backgroundColor: string;
116
+ '@media (hover: none)': {
117
+ backgroundColor: string;
118
+ };
119
+ };
120
+ };
121
+ };
122
+ };
123
+ };
124
+ };
125
+ };
126
+ sizeSmall: {
127
+ padding: number;
128
+ '&.rounded': {
129
+ padding: string;
130
+ };
131
+ };
132
+ sizeLarge: {
133
+ padding: number;
134
+ '&.rounded': {
135
+ padding: number;
136
+ };
137
+ };
138
+ };
60
139
  MuiButton: {
61
140
  root: {
62
141
  borderRadius: number;
@@ -57,6 +57,85 @@ export function makeLightNormalOverrides(theme: any): {
57
57
  };
58
58
  };
59
59
  };
60
+ MuiToggleButtonGroup: {
61
+ groupedHorizontal: {
62
+ '&.rounded': {
63
+ marginRight: number;
64
+ '&:last-child': {
65
+ marginRight: number;
66
+ };
67
+ '&:not(:first-child)': {
68
+ borderTopLeftRadius: string;
69
+ borderBottomLeftRadius: string;
70
+ marginLeft: string;
71
+ borderLeft: string;
72
+ };
73
+ '&:not(:last-child)': {
74
+ '&.rounded': {
75
+ borderTopRightRadius: string;
76
+ borderBottomRightRadius: string;
77
+ };
78
+ };
79
+ };
80
+ };
81
+ };
82
+ MuiToggleButton: {
83
+ root: {
84
+ borderRadius: number;
85
+ color: any;
86
+ border: string;
87
+ padding: number;
88
+ '&$selected': {
89
+ color: any;
90
+ backgroundColor: string;
91
+ '&:not($disabled)': {
92
+ '&.customColor': {
93
+ '&-primary': {
94
+ color: any;
95
+ };
96
+ };
97
+ };
98
+ };
99
+ '&$disabled': {
100
+ color: any;
101
+ };
102
+ '&.rounded': {
103
+ border: number;
104
+ borderRadius: any;
105
+ padding: string;
106
+ '&$selected': {
107
+ backgroundColor: any;
108
+ '&:not($disabled)': {
109
+ '&.customColor': {
110
+ '&-primary': {
111
+ color: any;
112
+ backgroundColor: string;
113
+ '&:hover': {
114
+ textDecoration: string;
115
+ backgroundColor: string;
116
+ '@media (hover: none)': {
117
+ backgroundColor: string;
118
+ };
119
+ };
120
+ };
121
+ };
122
+ };
123
+ };
124
+ };
125
+ };
126
+ sizeSmall: {
127
+ padding: number;
128
+ '&.rounded': {
129
+ padding: string;
130
+ };
131
+ };
132
+ sizeLarge: {
133
+ padding: number;
134
+ '&.rounded': {
135
+ padding: number;
136
+ };
137
+ };
138
+ };
60
139
  MuiButton: {
61
140
  root: {
62
141
  borderRadius: number;
@@ -69,6 +69,85 @@ export var makeLightNormalOverrides = function makeLightNormalOverrides(theme) {
69
69
  }
70
70
  }
71
71
  },
72
+ MuiToggleButtonGroup: {
73
+ groupedHorizontal: {
74
+ '&.rounded': {
75
+ marginRight: 12,
76
+ '&:last-child': {
77
+ marginRight: 0
78
+ },
79
+ '&:not(:first-child)': {
80
+ borderTopLeftRadius: 'inherit',
81
+ borderBottomLeftRadius: 'inherit',
82
+ marginLeft: 'inherit',
83
+ borderLeft: 'inherit'
84
+ },
85
+ '&:not(:last-child)': {
86
+ '&.rounded': {
87
+ borderTopRightRadius: 'inherit',
88
+ borderBottomRightRadius: 'inherit'
89
+ }
90
+ }
91
+ }
92
+ }
93
+ },
94
+ MuiToggleButton: {
95
+ root: {
96
+ borderRadius: 0,
97
+ color: theme.palette.text.secondary,
98
+ border: "1px solid ".concat(theme.palette.border.main),
99
+ padding: 15,
100
+ '&$selected': {
101
+ color: theme.palette.text.primary,
102
+ backgroundColor: 'transparent',
103
+ '&:not($disabled)': {
104
+ '&.customColor': {
105
+ '&-primary': {
106
+ color: theme.palette.primary.main
107
+ }
108
+ }
109
+ }
110
+ },
111
+ '&$disabled': {
112
+ color: theme.palette.text.disabled
113
+ },
114
+ '&.rounded': {
115
+ border: 0,
116
+ borderRadius: theme.shape.borderRadius,
117
+ padding: '10px 12px',
118
+ '&$selected': {
119
+ backgroundColor: theme.palette.action.selected,
120
+ '&:not($disabled)': {
121
+ '&.customColor': {
122
+ '&-primary': {
123
+ color: theme.palette.text.primary,
124
+ backgroundColor: alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity),
125
+ '&:hover': {
126
+ textDecoration: 'none',
127
+ backgroundColor: alpha(theme.palette.primary.main, theme.palette.action.activatedOpacity),
128
+ '@media (hover: none)': {
129
+ backgroundColor: 'transparent'
130
+ }
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }
136
+ }
137
+ },
138
+ sizeSmall: {
139
+ padding: 11,
140
+ '&.rounded': {
141
+ padding: '7px 10px'
142
+ }
143
+ },
144
+ sizeLarge: {
145
+ padding: 19,
146
+ '&.rounded': {
147
+ padding: 12
148
+ }
149
+ }
150
+ },
72
151
  MuiButton: {
73
152
  root: {
74
153
  borderRadius: 2,