cozy-ui 57.5.5 → 57.9.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 +46 -0
- package/package.json +1 -1
- package/react/AppSections/Readme.md +10 -11
- package/react/Badge/Readme.md +49 -60
- package/react/Button/Readme.md +5 -2
- package/react/Buttons/Readme.md +202 -0
- package/react/Buttons/index.jsx +72 -0
- package/react/CompositeRow/Readme.md +35 -36
- package/react/ContactsList/helpers.spec.js +3 -2
- package/react/CozyDialogs/Readme.md +11 -4
- package/react/Empty/Readme.md +17 -34
- package/react/Field/Readme.md +40 -14
- package/react/Field/index.jsx +5 -0
- package/react/Icons/LogoutLarge.jsx +1 -1
- package/react/InfosBadge/Readme.md +9 -10
- package/react/Labs/CollectionField/Readme.md +12 -11
- package/react/MuiCozyTheme/Buttons/Readme.md +1 -83
- package/react/MuiCozyTheme/makeOverrides.js +118 -8
- package/react/MuiCozyTheme/makePalette.js +11 -2
- package/react/MuiCozyTheme/makeTheme.js +0 -3
- package/react/Radio/Readme.md +87 -23
- package/react/Radio/index.jsx +23 -1
- package/react/Radio/index.spec.jsx +174 -0
- package/react/SquareAppIcon/Readme.md +23 -0
- package/react/SquareAppIcon/SquareAppIcon.spec.js +9 -0
- package/react/SquareAppIcon/__snapshots__/SquareAppIcon.spec.js.snap +43 -0
- package/react/SquareAppIcon/index.jsx +13 -3
- package/react/SquareAppIcon/styles.styl +2 -5
- package/react/Viewer/AudioViewer.spec.jsx +5 -5
- package/react/Viewer/PdfMobileViewer.spec.jsx +11 -11
- package/react/Viewer/ShortcutViewer.spec.jsx +4 -3
- package/react/Viewer/VideoViewer.spec.jsx +5 -5
- package/react/__snapshots__/examples.spec.jsx.snap +308 -182
- package/react/examples.spec.jsx +1 -0
- package/stylus/cozy-ui/build.styl +1 -1
- package/transpiled/react/Buttons/index.js +75 -0
- package/transpiled/react/Field/index.js +6 -1
- package/transpiled/react/Icons/LogoutLarge.js +4 -1
- package/transpiled/react/MuiCozyTheme/makeOverrides.js +104 -8
- package/transpiled/react/MuiCozyTheme/makePalette.js +11 -2
- package/transpiled/react/MuiCozyTheme/makeTheme.js +0 -3
- package/transpiled/react/Radio/index.js +24 -3
- package/transpiled/react/SquareAppIcon/index.js +9 -4
- package/transpiled/react/stylesheet.css +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
+
# [57.9.0](https://github.com/cozy/cozy-ui/compare/v57.8.0...v57.9.0) (2021-11-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Allow `Radio` to be part of a `RadioGroup` ([0e3cb6c](https://github.com/cozy/cozy-ui/commit/0e3cb6c)), closes [cozy/cozy-ui#1901](https://github.com/cozy/cozy-ui/issues/1901)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Refactor Radio documentation with variants ([fa2efc4](https://github.com/cozy/cozy-ui/commit/fa2efc4))
|
|
12
|
+
|
|
13
|
+
# [57.8.0](https://github.com/cozy/cozy-ui/compare/v57.7.0...v57.8.0) (2021-11-15)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* Set correct action opacity for Mui theme ([ebb4f45](https://github.com/cozy/cozy-ui/commit/ebb4f45))
|
|
19
|
+
* Set correct border opacities in Mui theme ([7b4c6e0](https://github.com/cozy/cozy-ui/commit/7b4c6e0))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* New Button component conform to the figma specifications ([46e551b](https://github.com/cozy/cozy-ui/commit/46e551b))
|
|
25
|
+
|
|
26
|
+
# [57.7.0](https://github.com/cozy/cozy-ui/compare/v57.6.0...v57.7.0) (2021-11-12)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* Add viewBox to LogoutLarge icon ([6196caa](https://github.com/cozy/cozy-ui/commit/6196caa))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* Add IconComponent prop to SquareAppIcon ([22591ff](https://github.com/cozy/cozy-ui/commit/22591ff))
|
|
37
|
+
* Add type prop to SquareAppIcon ([d9799c7](https://github.com/cozy/cozy-ui/commit/d9799c7))
|
|
38
|
+
* Do not use backdrop-filter on SquareAppIcon anymore ([451d54f](https://github.com/cozy/cozy-ui/commit/451d54f))
|
|
39
|
+
|
|
40
|
+
# [57.6.0](https://github.com/cozy/cozy-ui/compare/v57.5.5...v57.6.0) (2021-11-08)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Features
|
|
44
|
+
|
|
45
|
+
* Add `autoCapitalize` prop in Fields ([54efb34](https://github.com/cozy/cozy-ui/commit/54efb34))
|
|
46
|
+
|
|
1
47
|
## [57.5.5](https://github.com/cozy/cozy-ui/compare/v57.5.4...v57.5.5) (2021-11-08)
|
|
2
48
|
|
|
3
49
|
|
package/package.json
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
```jsx
|
|
2
2
|
import { useState } from 'react'
|
|
3
|
-
import mockApps from './_mockApps'
|
|
4
|
-
import { I18n } from '../I18n'
|
|
5
|
-
import { BreakpointsProvider } from '../hooks/useBreakpoints'
|
|
6
|
-
import Sections from 'cozy-ui/transpiled/react/AppSections'
|
|
7
|
-
import Variants from 'cozy-ui/docs/components/Variants'
|
|
3
|
+
import mockApps from './_mockApps'
|
|
4
|
+
import { I18n } from '../I18n'
|
|
5
|
+
import { BreakpointsProvider } from '../hooks/useBreakpoints'
|
|
6
|
+
import Sections from 'cozy-ui/transpiled/react/AppSections'
|
|
7
|
+
import Variants from 'cozy-ui/docs/components/Variants'
|
|
8
8
|
|
|
9
|
-
const locale = {}
|
|
9
|
+
const locale = {}
|
|
10
10
|
|
|
11
11
|
const WrapperSections = () => {
|
|
12
12
|
const handleAppClick = app => {
|
|
13
13
|
alert(JSON.stringify(app, null, 2))
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
const initialVariants = [
|
|
17
|
-
{ displaySpecificMaintenanceStyle: false},
|
|
18
|
-
{ displaySpecificMaintenanceStyle: true },
|
|
19
|
-
]
|
|
16
|
+
const initialVariants = [{ displaySpecificMaintenanceStyle: false}]
|
|
20
17
|
|
|
21
18
|
return (
|
|
22
|
-
<Variants initialVariants={initialVariants}>
|
|
19
|
+
<Variants initialVariants={initialVariants} screenshotAllVariants>
|
|
23
20
|
{
|
|
24
21
|
variant =>
|
|
25
22
|
<Sections
|
|
@@ -31,6 +28,8 @@ const WrapperSections = () => {
|
|
|
31
28
|
)
|
|
32
29
|
}
|
|
33
30
|
|
|
31
|
+
;
|
|
32
|
+
|
|
34
33
|
<BreakpointsProvider>
|
|
35
34
|
<I18n dictRequire={lang => locale} lang="en">
|
|
36
35
|
<WrapperSections />
|
package/react/Badge/Readme.md
CHANGED
|
@@ -6,76 +6,65 @@ The default version of badges is used to indicate an amount of new things that t
|
|
|
6
6
|
|
|
7
7
|
The `dot` variant can be used to indicate that the item _itself_ is new. A `dot` badge on a folder for example indicates that the folder is new, not that it contains new elements.
|
|
8
8
|
|
|
9
|
-
```
|
|
10
|
-
import Badge from 'cozy-ui/transpiled/react/Badge'
|
|
11
|
-
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
12
|
-
import Variants from 'cozy-ui/docs/components/Variants'
|
|
13
|
-
|
|
14
|
-
import CircleFilledIcon from "cozy-ui/transpiled/react/Icons/CircleFilled";
|
|
9
|
+
```jsx
|
|
10
|
+
import Badge from 'cozy-ui/transpiled/react/Badge'
|
|
11
|
+
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
12
|
+
import Variants from 'cozy-ui/docs/components/Variants'
|
|
13
|
+
import CircleFilledIcon from "cozy-ui/transpiled/react/Icons/CircleFilled"
|
|
15
14
|
|
|
16
15
|
const initialVariants = [
|
|
17
|
-
{ error: false, dot: false,
|
|
18
|
-
|
|
19
|
-
{ error: false, dot: false, large: false, small: false, withBorder: false, overlap: true },
|
|
20
|
-
];
|
|
16
|
+
{ overlap: true, error: false, dot: false, withBorder: false, left: false, bottom: false, small: false, large: false }
|
|
17
|
+
]
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
{ color: 'primary', variant: 'standard', size: 'small', vertical: 'top', horizontal: 'left', withBorder: false, overlap: true},
|
|
24
|
-
{ color: 'secondary', variant: 'dot', size: 'medium', vertical: 'bottom', horizontal: 'right', withBorder: true, overlap: true},
|
|
25
|
-
{ color: 'error', variant: 'standard', size: 'large', vertical: 'top', horizontal: 'left', withBorder: false, overlap: true},
|
|
26
|
-
{ color: 'secondary', variant: 'dot', size: 'small', vertical: 'top', horizontal: 'right', withBorder: true, overlap: true},
|
|
27
|
-
{ color: 'error', variant: 'standard', size: 'medium', vertical: 'bottom', horizontal: 'left', withBorder: false, overlap: true},
|
|
28
|
-
{ color: 'primary', variant: 'dot', size: 'large', vertical: 'top', horizontal: 'right', withBorder: true, overlap: true},
|
|
29
|
-
{ color: 'error', variant: 'standard', size: 'medium', vertical: 'bottom', horizontal: 'left', withBorder: false, overlap: false},
|
|
30
|
-
{ color: 'primary', variant: 'dot', size: 'large', vertical: 'top', horizontal: 'right', withBorder: true, overlap: false}
|
|
31
|
-
];
|
|
19
|
+
;
|
|
32
20
|
|
|
33
|
-
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
21
|
+
<Variants initialVariants={initialVariants} screenshotAllVariants>
|
|
22
|
+
{variant => (
|
|
23
|
+
<Badge
|
|
24
|
+
className="u-m-half"
|
|
25
|
+
badgeContent={4}
|
|
26
|
+
color={
|
|
27
|
+
variant.error ? "error" : variant.secondaryColor ? "secondary" : "primary"
|
|
28
|
+
}
|
|
29
|
+
variant={variant.dot ? "dot" : "standard"}
|
|
30
|
+
size={variant.large ? "large" : variant.small ? "small" : "medium"}
|
|
31
|
+
anchorOrigin={{
|
|
32
|
+
vertical: variant.bottom ? "bottom" : "top",
|
|
33
|
+
horizontal: variant.left ? "left" : "right",
|
|
34
|
+
}}
|
|
35
|
+
withBorder={variant.withBorder}
|
|
36
|
+
overlap={variant.overlap ? "circle" : "rectangle"}
|
|
37
|
+
>
|
|
38
|
+
<Icon
|
|
39
|
+
icon={CircleFilledIcon}
|
|
40
|
+
size={variant.large ? "32" : variant.small ? "16" : "24"}
|
|
41
|
+
color="var(--slateGrey)"
|
|
42
|
+
/>
|
|
43
|
+
</Badge>
|
|
44
|
+
)}
|
|
45
|
+
</Variants>
|
|
56
46
|
```
|
|
57
47
|
|
|
58
48
|
### Double badges
|
|
59
49
|
|
|
60
50
|
Badges can be combined — in this example, we have an item with a new qualification.
|
|
61
51
|
|
|
62
|
-
```
|
|
63
|
-
import Badge from 'cozy-ui/transpiled/react/Badge'
|
|
64
|
-
import InfosBadge from 'cozy-ui/transpiled/react/InfosBadge'
|
|
65
|
-
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
66
|
-
import Avatar from 'cozy-ui/transpiled/react/Avatar'
|
|
52
|
+
```jsx
|
|
53
|
+
import Badge from 'cozy-ui/transpiled/react/Badge'
|
|
54
|
+
import InfosBadge from 'cozy-ui/transpiled/react/InfosBadge'
|
|
55
|
+
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
56
|
+
import Avatar from 'cozy-ui/transpiled/react/Avatar'
|
|
57
|
+
import LinkIcon from "cozy-ui/transpiled/react/Icons/Link"
|
|
67
58
|
|
|
68
|
-
|
|
59
|
+
;
|
|
69
60
|
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
</InfosBadge>
|
|
80
|
-
</p>
|
|
61
|
+
<InfosBadge
|
|
62
|
+
badgeContent={
|
|
63
|
+
<Badge color="error" variant="dot" size="small">
|
|
64
|
+
<Icon icon={LinkIcon} size="10" />
|
|
65
|
+
</Badge>
|
|
66
|
+
}
|
|
67
|
+
>
|
|
68
|
+
<Avatar text="CD" size="small" />
|
|
69
|
+
</InfosBadge>
|
|
81
70
|
```
|
package/react/Button/Readme.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
⚠️ This `<Button />` is going to be deprecated, please use [Buttons](#/Buttons) instead.
|
|
2
|
+
|
|
3
|
+
There's two kinds of Button at your disposal : `<Button />` and `<ButtonLink />`.
|
|
4
|
+
|
|
2
5
|
The first is a basic `<button>` for a click event, the second is a `<a>`, a link.
|
|
3
|
-
Both look exactly the same, they share the same `className`, `disabled`, `onClick`
|
|
6
|
+
Both look exactly the same, they share the same `className`, `disabled`, `onClick` and `theme` parameters but `<Button>` has also:
|
|
4
7
|
|
|
5
8
|
* `busy` that adds a spinner (default `false`)
|
|
6
9
|
* `type`, eg. `submit` or `reset` (default `submit`)
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
### Default
|
|
2
|
+
|
|
3
|
+
```jsx
|
|
4
|
+
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
5
|
+
import Stack from 'cozy-ui/transpiled/react/Stack'
|
|
6
|
+
import Grid from 'cozy-ui/transpiled/react/MuiCozyTheme/Grid'
|
|
7
|
+
import Paper from 'cozy-ui/transpiled/react/Paper'
|
|
8
|
+
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
9
|
+
import PlusIcon from 'cozy-ui/transpiled/react/Icons/Plus'
|
|
10
|
+
import CozyTheme from 'cozy-ui/transpiled/react/CozyTheme'
|
|
11
|
+
|
|
12
|
+
const variants = ['primary', 'secondary', 'ghost', 'text']
|
|
13
|
+
const propsArr = [{}, { disabled: true }, { busy: true }]
|
|
14
|
+
|
|
15
|
+
;
|
|
16
|
+
|
|
17
|
+
<Grid container>
|
|
18
|
+
{propsArr.map(props =>
|
|
19
|
+
<Grid item xs={12} sm={4} className="u-mb-1" key={JSON.stringify(props)}>
|
|
20
|
+
<Stack spacing="s">
|
|
21
|
+
<div>{Object.keys(props)[0] || 'default'}</div>
|
|
22
|
+
{variants.map(variant =>
|
|
23
|
+
<div key={variant + JSON.stringify(props)}>
|
|
24
|
+
<Button label={variant} variant={variant} {...props} />
|
|
25
|
+
</div>
|
|
26
|
+
)}
|
|
27
|
+
</Stack>
|
|
28
|
+
</Grid>
|
|
29
|
+
)}
|
|
30
|
+
</Grid>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Sizes
|
|
34
|
+
|
|
35
|
+
```jsx
|
|
36
|
+
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
37
|
+
import Stack from 'cozy-ui/transpiled/react/Stack'
|
|
38
|
+
import Grid from 'cozy-ui/transpiled/react/MuiCozyTheme/Grid'
|
|
39
|
+
import Paper from 'cozy-ui/transpiled/react/Paper'
|
|
40
|
+
import CozyTheme from 'cozy-ui/transpiled/react/CozyTheme'
|
|
41
|
+
|
|
42
|
+
const variants = ['primary', 'secondary', 'ghost', 'text']
|
|
43
|
+
const sizes = ['small', 'medium', 'large']
|
|
44
|
+
|
|
45
|
+
;
|
|
46
|
+
|
|
47
|
+
<Grid container>
|
|
48
|
+
{sizes.map(size =>
|
|
49
|
+
<Grid item xs={12} sm={4} className="u-mb-1" key={size}>
|
|
50
|
+
<Stack spacing="s">
|
|
51
|
+
<div>{size}</div>
|
|
52
|
+
{variants.map(variant =>
|
|
53
|
+
<div key={variant + size}>
|
|
54
|
+
<Button label={variant} variant={variant} size={size} />
|
|
55
|
+
</div>
|
|
56
|
+
)}
|
|
57
|
+
</Stack>
|
|
58
|
+
</Grid>
|
|
59
|
+
)}
|
|
60
|
+
</Grid>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Icons
|
|
64
|
+
|
|
65
|
+
```jsx
|
|
66
|
+
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
67
|
+
import Stack from 'cozy-ui/transpiled/react/Stack'
|
|
68
|
+
import Grid from 'cozy-ui/transpiled/react/MuiCozyTheme/Grid'
|
|
69
|
+
import Paper from 'cozy-ui/transpiled/react/Paper'
|
|
70
|
+
import CozyTheme from 'cozy-ui/transpiled/react/CozyTheme'
|
|
71
|
+
import PlusIcon from 'cozy-ui/transpiled/react/Icons/Plus'
|
|
72
|
+
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
73
|
+
import IconButton from 'cozy-ui/transpiled/react/IconButton'
|
|
74
|
+
|
|
75
|
+
const variants = ['primary', 'secondary', 'ghost', 'text']
|
|
76
|
+
const iconPositions = ['startIcon', 'endIcon']
|
|
77
|
+
|
|
78
|
+
;
|
|
79
|
+
|
|
80
|
+
<Grid container>
|
|
81
|
+
{iconPositions.map(iconPosition =>
|
|
82
|
+
<Grid item xs={12} sm={4} className="u-mb-1" key={iconPosition}>
|
|
83
|
+
<Stack spacing="s">
|
|
84
|
+
<div>{iconPosition}</div>
|
|
85
|
+
{variants.map(variant =>
|
|
86
|
+
<div key={variant + iconPosition}>
|
|
87
|
+
<Button
|
|
88
|
+
label={variant}
|
|
89
|
+
variant={variant}
|
|
90
|
+
{...({[`${iconPosition}`]: <Icon icon={PlusIcon}/>})}
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
)}
|
|
94
|
+
</Stack>
|
|
95
|
+
</Grid>
|
|
96
|
+
)}
|
|
97
|
+
<Grid item xs={12} sm={4} className="u-mb-1">
|
|
98
|
+
<Stack spacing="s">
|
|
99
|
+
<div>label is only icon</div>
|
|
100
|
+
{variants.map(variant =>
|
|
101
|
+
<div key={variant}>
|
|
102
|
+
<Button
|
|
103
|
+
className="u-miw-auto"
|
|
104
|
+
label={<Icon icon={PlusIcon}/>}
|
|
105
|
+
variant={variant}
|
|
106
|
+
/>
|
|
107
|
+
</div>
|
|
108
|
+
)}
|
|
109
|
+
</Stack>
|
|
110
|
+
</Grid>
|
|
111
|
+
</Grid>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Colors
|
|
115
|
+
|
|
116
|
+
```jsx
|
|
117
|
+
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
118
|
+
import Stack from 'cozy-ui/transpiled/react/Stack'
|
|
119
|
+
import Grid from 'cozy-ui/transpiled/react/MuiCozyTheme/Grid'
|
|
120
|
+
import Paper from 'cozy-ui/transpiled/react/Paper'
|
|
121
|
+
import CozyTheme from 'cozy-ui/transpiled/react/CozyTheme'
|
|
122
|
+
|
|
123
|
+
const variants = ['primary', 'secondary', 'ghost', 'text']
|
|
124
|
+
const colors = ['success', 'error', 'warning', 'info']
|
|
125
|
+
|
|
126
|
+
;
|
|
127
|
+
|
|
128
|
+
<Grid container>
|
|
129
|
+
{colors.map(color =>
|
|
130
|
+
<Grid item xs={12} sm={6} md={3} className="u-mb-1" key={color}>
|
|
131
|
+
<Stack spacing="s">
|
|
132
|
+
<div>{color}</div>
|
|
133
|
+
{variants.map(variant =>
|
|
134
|
+
<div key={variant + color}>
|
|
135
|
+
<Button label={variant} variant={variant} color={color} />
|
|
136
|
+
</div>
|
|
137
|
+
)}
|
|
138
|
+
</Stack>
|
|
139
|
+
</Grid>
|
|
140
|
+
)}
|
|
141
|
+
</Grid>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Disabled colors
|
|
145
|
+
|
|
146
|
+
```jsx
|
|
147
|
+
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
148
|
+
import Stack from 'cozy-ui/transpiled/react/Stack'
|
|
149
|
+
import Grid from 'cozy-ui/transpiled/react/MuiCozyTheme/Grid'
|
|
150
|
+
import Paper from 'cozy-ui/transpiled/react/Paper'
|
|
151
|
+
import CozyTheme from 'cozy-ui/transpiled/react/CozyTheme'
|
|
152
|
+
|
|
153
|
+
const variants = ['primary', 'secondary', 'ghost', 'text']
|
|
154
|
+
const colors = ['success', 'error', 'warning', 'info']
|
|
155
|
+
|
|
156
|
+
;
|
|
157
|
+
|
|
158
|
+
<Grid container>
|
|
159
|
+
{colors.map(color =>
|
|
160
|
+
<Grid item xs={12} sm={6} md={3} className="u-mb-1" key={color}>
|
|
161
|
+
<Stack spacing="s">
|
|
162
|
+
<div>{color}</div>
|
|
163
|
+
{variants.map(variant =>
|
|
164
|
+
<div key={variant + color}>
|
|
165
|
+
<Button label={variant} variant={variant} color={color} disabled={true} />
|
|
166
|
+
</div>
|
|
167
|
+
)}
|
|
168
|
+
</Stack>
|
|
169
|
+
</Grid>
|
|
170
|
+
)}
|
|
171
|
+
</Grid>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Busy colors
|
|
175
|
+
|
|
176
|
+
```jsx
|
|
177
|
+
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
178
|
+
import Stack from 'cozy-ui/transpiled/react/Stack'
|
|
179
|
+
import Grid from 'cozy-ui/transpiled/react/MuiCozyTheme/Grid'
|
|
180
|
+
import Paper from 'cozy-ui/transpiled/react/Paper'
|
|
181
|
+
import CozyTheme from 'cozy-ui/transpiled/react/CozyTheme'
|
|
182
|
+
|
|
183
|
+
const variants = ['primary', 'secondary', 'ghost', 'text']
|
|
184
|
+
const colors = ['success', 'error', 'warning', 'info']
|
|
185
|
+
|
|
186
|
+
;
|
|
187
|
+
|
|
188
|
+
<Grid container>
|
|
189
|
+
{colors.map(color =>
|
|
190
|
+
<Grid item xs={12} sm={6} md={3} className="u-mb-1" key={color}>
|
|
191
|
+
<Stack spacing="s">
|
|
192
|
+
<div>{color}</div>
|
|
193
|
+
{variants.map(variant =>
|
|
194
|
+
<div key={variant + color}>
|
|
195
|
+
<Button label={variant} variant={variant} color={color} busy={true} />
|
|
196
|
+
</div>
|
|
197
|
+
)}
|
|
198
|
+
</Stack>
|
|
199
|
+
</Grid>
|
|
200
|
+
)}
|
|
201
|
+
</Grid>
|
|
202
|
+
```
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import cx from 'classnames'
|
|
4
|
+
|
|
5
|
+
import MuiButton from '@material-ui/core/Button'
|
|
6
|
+
|
|
7
|
+
import Icon from '../Icon'
|
|
8
|
+
import SpinnerIcon from '../Icons/Spinner'
|
|
9
|
+
|
|
10
|
+
const DefaultButton = ({
|
|
11
|
+
className,
|
|
12
|
+
color,
|
|
13
|
+
label,
|
|
14
|
+
busy,
|
|
15
|
+
disabled,
|
|
16
|
+
endIcon,
|
|
17
|
+
...props
|
|
18
|
+
}) => {
|
|
19
|
+
return (
|
|
20
|
+
<MuiButton
|
|
21
|
+
{...props}
|
|
22
|
+
className={cx({ [`customColor-${color}`]: color }, className)}
|
|
23
|
+
color="primary"
|
|
24
|
+
disabled={disabled || busy}
|
|
25
|
+
endIcon={
|
|
26
|
+
busy ? (
|
|
27
|
+
<Icon icon={SpinnerIcon} spin aria-hidden focusable="false" />
|
|
28
|
+
) : (
|
|
29
|
+
endIcon
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
disableElevation={true}
|
|
33
|
+
>
|
|
34
|
+
{label}
|
|
35
|
+
</MuiButton>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
DefaultButton.defaultProps = {
|
|
40
|
+
variant: 'contained',
|
|
41
|
+
color: 'primary'
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const Buttons = ({ variant, ...props }) => {
|
|
45
|
+
switch (variant) {
|
|
46
|
+
case 'ghost':
|
|
47
|
+
return <DefaultButton className="ghost" variant="outlined" {...props} />
|
|
48
|
+
|
|
49
|
+
case 'secondary':
|
|
50
|
+
return <DefaultButton variant="outlined" {...props} />
|
|
51
|
+
|
|
52
|
+
case 'text':
|
|
53
|
+
return <DefaultButton variant="text" {...props} />
|
|
54
|
+
|
|
55
|
+
case 'primary':
|
|
56
|
+
return <DefaultButton {...props} />
|
|
57
|
+
|
|
58
|
+
default:
|
|
59
|
+
return <DefaultButton {...props} />
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
Buttons.propTypes = {
|
|
64
|
+
variant: PropTypes.oneOf(['primary', 'secondary', 'ghost', 'text']),
|
|
65
|
+
color: PropTypes.oneOf(['success', 'error', 'warning', 'info'])
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Buttons.defaultProps = {
|
|
69
|
+
variant: 'primary'
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default Buttons
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
```js
|
|
2
|
-
import { Media, Bd, Img } from '../Media'
|
|
3
|
-
import UIChip from '../Chip'
|
|
4
|
-
import Icon from '../Icon'
|
|
5
|
-
import Circle from '../Circle'
|
|
6
|
-
import Variants from 'cozy-ui/docs/components/Variants'
|
|
7
|
-
import CompositeRow from 'cozy-ui/transpiled/react/CompositeRow'
|
|
2
|
+
import { Media, Bd, Img } from '../Media'
|
|
3
|
+
import UIChip from '../Chip'
|
|
4
|
+
import Icon from '../Icon'
|
|
5
|
+
import Circle from '../Circle'
|
|
6
|
+
import Variants from 'cozy-ui/docs/components/Variants'
|
|
7
|
+
import CompositeRow from 'cozy-ui/transpiled/react/CompositeRow'
|
|
8
8
|
|
|
9
|
-
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
9
|
+
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
10
10
|
|
|
11
|
-
import WalletIcon from 'cozy-ui/transpiled/react/Icons/Wallet'
|
|
12
|
-
import DotsIcon from 'cozy-ui/transpiled/react/Icons/Dots'
|
|
13
|
-
import palette from 'cozy-ui/transpiled/react/palette'
|
|
11
|
+
import WalletIcon from 'cozy-ui/transpiled/react/Icons/Wallet'
|
|
12
|
+
import DotsIcon from 'cozy-ui/transpiled/react/Icons/Dots'
|
|
13
|
+
import palette from 'cozy-ui/transpiled/react/palette'
|
|
14
14
|
|
|
15
|
-
const fnacLogoURL = 'https://upload.wikimedia.org/wikipedia/commons/2/2e/Fnac_Logo.svg'
|
|
15
|
+
const fnacLogoURL = 'https://upload.wikimedia.org/wikipedia/commons/2/2e/Fnac_Logo.svg'
|
|
16
16
|
|
|
17
17
|
const Chip = React.memo(({ children, ...props }) => (
|
|
18
18
|
<UIChip
|
|
@@ -21,32 +21,32 @@ const Chip = React.memo(({ children, ...props }) => (
|
|
|
21
21
|
size='small'
|
|
22
22
|
children={children} {...props}
|
|
23
23
|
/>
|
|
24
|
-
))
|
|
24
|
+
))
|
|
25
25
|
|
|
26
26
|
const ChipImage = React.memo(({ src }) => (
|
|
27
27
|
<img className='u-mr-half' src={src} height='50%' />
|
|
28
|
-
))
|
|
28
|
+
))
|
|
29
29
|
|
|
30
30
|
const compositeStyle = {
|
|
31
31
|
boxShadow: '0 0 10px rgba(0, 0, 0, 0.15)',
|
|
32
32
|
boxSizing: 'border-box',
|
|
33
|
-
}
|
|
33
|
+
}
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
const CompositeImage = () => (
|
|
37
37
|
<Circle backgroundColor={palette.melon}>
|
|
38
38
|
<Icon icon={WalletIcon} />
|
|
39
39
|
</Circle>
|
|
40
|
-
)
|
|
40
|
+
)
|
|
41
41
|
|
|
42
42
|
const Amount = () => (
|
|
43
43
|
<Typography tag='span' variant="h6">12,15€</Typography>
|
|
44
|
-
)
|
|
44
|
+
)
|
|
45
45
|
|
|
46
46
|
const onDotsClick = () => { alert('clicked dots !')}
|
|
47
47
|
const Dots = () => (
|
|
48
48
|
<Icon className="u-c-pointer" color="var(--coolGrey)" icon={DotsIcon} onClick={onDotsClick}/>
|
|
49
|
-
)
|
|
49
|
+
)
|
|
50
50
|
|
|
51
51
|
const Chips = () => (
|
|
52
52
|
<Bd className='u-row-xs'>
|
|
@@ -57,7 +57,7 @@ const Chips = () => (
|
|
|
57
57
|
<ChipImage src={fnacLogoURL} /> Fnac
|
|
58
58
|
</Chip>
|
|
59
59
|
</Bd>
|
|
60
|
-
)
|
|
60
|
+
)
|
|
61
61
|
|
|
62
62
|
const Actions = ({ extraInformation }) => (
|
|
63
63
|
<Media>
|
|
@@ -71,33 +71,32 @@ const Actions = ({ extraInformation }) => (
|
|
|
71
71
|
</Bd>
|
|
72
72
|
{ extraInformation ? <Shrink><Typography variant="caption" color="textSecondary">Extra information to the right of the card</Typography></Shrink> : null }
|
|
73
73
|
</Media>
|
|
74
|
-
)
|
|
74
|
+
)
|
|
75
75
|
|
|
76
|
-
const Shrink = Img
|
|
76
|
+
const Shrink = Img
|
|
77
77
|
|
|
78
78
|
const initialVariants = [
|
|
79
|
-
{ chips: true, secondaryText: true, dots: true, icon: true, extraInformation: true }
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
<Variants initialVariants={initialVariants}>{
|
|
87
|
-
variant => (
|
|
79
|
+
{ chips: true, dense: false, secondaryText: true, dots: true, icon: true, extraInformation: true }
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
;
|
|
83
|
+
|
|
84
|
+
<Variants initialVariants={initialVariants} screenshotAllVariants>
|
|
85
|
+
{variant => (
|
|
88
86
|
<CompositeRow
|
|
89
87
|
primaryText='Primary text'
|
|
90
88
|
secondaryText={variant.secondaryText ? 'Secondary Text' : null}
|
|
91
89
|
image={variant.icon ? <CompositeImage /> : null}
|
|
92
|
-
right={
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
right={
|
|
91
|
+
<>
|
|
92
|
+
<Shrink><Amount /></Shrink>
|
|
93
|
+
{ variant.dots ? <Shrink><Dots /></Shrink> : null }
|
|
94
|
+
</>
|
|
95
|
+
}
|
|
96
96
|
actions={variant.chips ? <Actions extraInformation={variant.extraInformation} /> : null}
|
|
97
97
|
dense={variant.dense}
|
|
98
98
|
style={compositeStyle}
|
|
99
99
|
/>
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
)}
|
|
101
|
+
</Variants>
|
|
103
102
|
```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { sortLastNameFirst, sortHeaders } from './helpers'
|
|
2
2
|
describe('Sort contacts', () => {
|
|
3
3
|
describe('By Last Name', () => {
|
|
4
|
-
|
|
4
|
+
it('should sort contact by last name', () => {
|
|
5
5
|
const contacts = [
|
|
6
6
|
{ name: { givenName: '', familyName: '' } },
|
|
7
7
|
{ name: { givenName: 'A', familyName: 'A' } },
|
|
@@ -32,7 +32,8 @@ describe('Sort contacts', () => {
|
|
|
32
32
|
{ name: { givenName: 'B', familyName: 'C' } }
|
|
33
33
|
])
|
|
34
34
|
})
|
|
35
|
-
|
|
35
|
+
|
|
36
|
+
it('should work with incomplete data', () => {
|
|
36
37
|
const contacts = [
|
|
37
38
|
{ name: { givenName: '' } },
|
|
38
39
|
{ name: { givenName: 'A' } },
|