cozy-ui 65.1.3 → 66.2.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 +32 -0
- package/package.json +4 -8
- package/react/BottomSheet/BottomSheet.jsx +5 -3
- package/react/CircleButton/Readme.md +120 -0
- package/react/CircleButton/helpers.js +16 -0
- package/react/CircleButton/helpers.spec.js +61 -0
- package/react/CircleButton/index.jsx +82 -0
- package/react/Dialog/index.jsx +3 -3
- package/react/IconButton/Readme.md +45 -17
- package/react/IconButton/index.jsx +17 -1
- package/react/MuiCozyTheme/makeOverrides.js +9 -0
- package/react/__snapshots__/examples.spec.jsx.snap +23 -2
- package/react/index.js +1 -0
- package/transpiled/react/BottomSheet/BottomSheet.js +3 -3
- package/transpiled/react/CircleButton/helpers.js +26 -0
- package/transpiled/react/CircleButton/index.js +97 -0
- package/transpiled/react/Dialog/index.js +3 -3
- package/transpiled/react/IconButton/index.js +24 -1
- package/transpiled/react/MuiCozyTheme/makeOverrides.js +9 -0
- package/transpiled/react/index.js +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
# [66.2.0](https://github.com/cozy/cozy-ui/compare/v66.1.0...v66.2.0) (2022-05-03)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Small size for IconButton ([63b6f70](https://github.com/cozy/cozy-ui/commit/63b6f70))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add CircleButton ([bd2692a](https://github.com/cozy/cozy-ui/commit/bd2692a))
|
|
12
|
+
|
|
13
|
+
# [66.1.0](https://github.com/cozy/cozy-ui/compare/v66.0.0...v66.1.0) (2022-05-03)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* Add large size on IconButton ([2a58a7a](https://github.com/cozy/cozy-ui/commit/2a58a7a))
|
|
19
|
+
|
|
20
|
+
# [66.0.0](https://github.com/cozy/cozy-ui/compare/v65.1.3...v66.0.0) (2022-05-02)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* Upgrade cozy-device-helper API ([45b22fa](https://github.com/cozy/cozy-ui/commit/45b22fa))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### BREAKING CHANGES
|
|
29
|
+
|
|
30
|
+
* This will use a more robust CDH API.
|
|
31
|
+
In order to support the update, it is need to upgrade CDH to >=2.0.0
|
|
32
|
+
|
|
1
33
|
## [65.1.3](https://github.com/cozy/cozy-ui/compare/v65.1.2...v65.1.3) (2022-04-29)
|
|
2
34
|
|
|
3
35
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "66.2.0",
|
|
4
4
|
"description": "Cozy apps UI SDK",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -29,11 +29,9 @@
|
|
|
29
29
|
"build:doc:react": "styleguidist build --config docs/styleguide.config.js",
|
|
30
30
|
"build": "env BABEL_ENV=transpilation babel --extensions .ts,.tsx,.js,.jsx react/ --out-dir transpiled/react --verbose",
|
|
31
31
|
"clean:doc:kss": "rm -rf build/styleguide",
|
|
32
|
-
"commitmsg": "commitlint -e $GIT_PARAMS",
|
|
33
32
|
"deploy:doc": "git-directory-deploy --directory build/ --branch gh-pages",
|
|
34
33
|
"makeSvgr": "scripts/generate-svgr-icon.sh",
|
|
35
34
|
"lint": "npm-run-all 'lint:*'",
|
|
36
|
-
"lint:commit": "git merge-base HEAD master && commitlint --from=$(git merge-base HEAD master) --to=HEAD || true",
|
|
37
35
|
"lint:js": "eslint 'react/**/*.jsx' 'react/**/*.js' 'react/**/*.ts' 'docs/styleguide.config.js'",
|
|
38
36
|
"lint:stylus": "stylint stylus --config .stylintrc",
|
|
39
37
|
"lint:md": "remark . -o -S",
|
|
@@ -49,6 +47,7 @@
|
|
|
49
47
|
"jest": "yarn test:jest",
|
|
50
48
|
"screenshots": "node scripts/screenshots.js --screenshot-dir ./screenshots --styleguide-url file://$(pwd)/build/react --kss-dir ./build/styleguide",
|
|
51
49
|
"test": "yarn test:jest",
|
|
50
|
+
"test:update:expl": "yarn test react/examples.spec.jsx -u",
|
|
52
51
|
"screenshots:server": "nodemon ./scripts/pixelmatch-server/server.js -e js,hbs",
|
|
53
52
|
"test:jest": "jest",
|
|
54
53
|
"postbuild": "postcss transpiled/react/stylesheet.css --replace",
|
|
@@ -87,11 +86,9 @@
|
|
|
87
86
|
"babel-plugin-inline-json-import": "0.3.2",
|
|
88
87
|
"babel-preset-cozy-app": "2.0.2",
|
|
89
88
|
"browserslist-config-cozy": "0.4.0",
|
|
90
|
-
"commitlint": "7.6.1",
|
|
91
|
-
"commitlint-config-cozy": "0.6.0",
|
|
92
89
|
"copyfiles": "2.4.1",
|
|
93
90
|
"cozy-client": "28.2.0",
|
|
94
|
-
"cozy-device-helper": "
|
|
91
|
+
"cozy-device-helper": "2.0.0",
|
|
95
92
|
"cozy-doctypes": "^1.69.0",
|
|
96
93
|
"cozy-harvest-lib": "^6.7.3",
|
|
97
94
|
"cozy-intent": "1.16.1",
|
|
@@ -110,7 +107,6 @@
|
|
|
110
107
|
"git-directory-deploy": "1.5.1",
|
|
111
108
|
"handlebars": "^4.7.6",
|
|
112
109
|
"http-server": "0.13.0",
|
|
113
|
-
"husky": "0.14.3",
|
|
114
110
|
"identity-obj-proxy": "3.0.0",
|
|
115
111
|
"jest-canvas-mock": "2.3.1",
|
|
116
112
|
"jest-cli": "^26.6.3",
|
|
@@ -176,7 +172,7 @@
|
|
|
176
172
|
"peerDependencies": {
|
|
177
173
|
"@material-ui/core": ">=4.12",
|
|
178
174
|
"cozy-client": ">=28.1.0",
|
|
179
|
-
"cozy-device-helper": "^
|
|
175
|
+
"cozy-device-helper": "^2.0.0",
|
|
180
176
|
"cozy-doctypes": "^1.69.0",
|
|
181
177
|
"cozy-harvest-lib": "^6.7.3",
|
|
182
178
|
"cozy-intent": ">=1.3.0",
|
|
@@ -2,7 +2,7 @@ import React, { useState, useEffect, useRef, useMemo } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import { BottomSheet as MuiBottomSheet } from 'mui-bottom-sheet'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { getFlagshipMetadata } from 'cozy-device-helper'
|
|
6
6
|
|
|
7
7
|
import Stack from 'cozy-ui/transpiled/react/Stack'
|
|
8
8
|
import Paper from 'cozy-ui/transpiled/react/Paper'
|
|
@@ -112,7 +112,7 @@ const BottomSheet = ({ toolbarProps, settings, children }) => {
|
|
|
112
112
|
headerRef.current.offsetHeight +
|
|
113
113
|
actionButtonsHeight +
|
|
114
114
|
actionButtonsBottomMargin +
|
|
115
|
-
(
|
|
115
|
+
(getFlagshipMetadata().navbarHeight || 0)
|
|
116
116
|
|
|
117
117
|
// Used so that the bottomSheet can be opened to the top,
|
|
118
118
|
// without stopping at the content height
|
|
@@ -154,7 +154,9 @@ const BottomSheet = ({ toolbarProps, settings, children }) => {
|
|
|
154
154
|
|
|
155
155
|
return (
|
|
156
156
|
<>
|
|
157
|
-
{
|
|
157
|
+
{getFlagshipMetadata().immersive && (
|
|
158
|
+
<span style={styles.flagshipImmersive} />
|
|
159
|
+
)}
|
|
158
160
|
|
|
159
161
|
<MuiBottomSheet
|
|
160
162
|
peekHeights={peekHeights}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
```jsx
|
|
2
|
+
import CircleButton from 'cozy-ui/transpiled/react/CircleButton'
|
|
3
|
+
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
4
|
+
import HeartIcon from 'cozy-ui/transpiled/react/Icons/Heart'
|
|
5
|
+
import PeopleIcon from 'cozy-ui/transpiled/react/Icons/People'
|
|
6
|
+
|
|
7
|
+
// <-- only useful for the documentation
|
|
8
|
+
import Grid from 'cozy-ui/transpiled/react/MuiCozyTheme/Grid'
|
|
9
|
+
import Stack from 'cozy-ui/transpiled/react/Stack'
|
|
10
|
+
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
11
|
+
import Variants from 'cozy-ui/docs/components/Variants'
|
|
12
|
+
|
|
13
|
+
const columns = [{ title: 'default', disabled: false }, { title: 'disabled', disabled: true }]
|
|
14
|
+
const initialVariants = [{ default: true, active: false }]
|
|
15
|
+
// -->
|
|
16
|
+
|
|
17
|
+
;
|
|
18
|
+
|
|
19
|
+
<Variants initialVariants={initialVariants} radio={true} screenshotAllVariants>
|
|
20
|
+
{variant => (
|
|
21
|
+
<Grid container>
|
|
22
|
+
{columns.map(column =>
|
|
23
|
+
<Grid item xs={12} sm={6} className="u-mb-1" key={JSON.stringify(column)}>
|
|
24
|
+
<Stack spacing="s">
|
|
25
|
+
<Typography>{Object.values(column)[0]}</Typography>
|
|
26
|
+
<CircleButton
|
|
27
|
+
label="Button"
|
|
28
|
+
disabled={Object.values(column)[1]}
|
|
29
|
+
variant={Object.keys(variant).find(key => variant[key])}
|
|
30
|
+
>
|
|
31
|
+
<Icon icon={HeartIcon} />
|
|
32
|
+
</CircleButton>
|
|
33
|
+
<CircleButton
|
|
34
|
+
label="Long label button"
|
|
35
|
+
disabled={Object.values(column)[1]}
|
|
36
|
+
variant={Object.keys(variant).find(key => variant[key])}
|
|
37
|
+
>
|
|
38
|
+
<Icon icon={HeartIcon} />
|
|
39
|
+
</CircleButton>
|
|
40
|
+
<CircleButton
|
|
41
|
+
disabled={Object.values(column)[1]}
|
|
42
|
+
variant={Object.keys(variant).find(key => variant[key])}
|
|
43
|
+
>
|
|
44
|
+
<Icon icon={PeopleIcon} />
|
|
45
|
+
</CircleButton>
|
|
46
|
+
</Stack>
|
|
47
|
+
</Grid>
|
|
48
|
+
)}
|
|
49
|
+
</Grid>
|
|
50
|
+
)}
|
|
51
|
+
</Variants>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Use case
|
|
55
|
+
|
|
56
|
+
Can be used in a responsive container to distribute the elements.
|
|
57
|
+
|
|
58
|
+
```jsx
|
|
59
|
+
import CircleButton from 'cozy-ui/transpiled/react/CircleButton'
|
|
60
|
+
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
61
|
+
import HeartIcon from 'cozy-ui/transpiled/react/Icons/Heart'
|
|
62
|
+
import PeopleIcon from 'cozy-ui/transpiled/react/Icons/People'
|
|
63
|
+
|
|
64
|
+
// <-- only useful for the documentation
|
|
65
|
+
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
66
|
+
import Variants from 'cozy-ui/docs/components/Variants'
|
|
67
|
+
|
|
68
|
+
const initialVariants = [{ fullWidth: false }]
|
|
69
|
+
const styles = {
|
|
70
|
+
display: 'flex',
|
|
71
|
+
justifyContent: 'center',
|
|
72
|
+
flexWrap: 'wrap'
|
|
73
|
+
}
|
|
74
|
+
// -->
|
|
75
|
+
|
|
76
|
+
;
|
|
77
|
+
|
|
78
|
+
<Variants initialVariants={initialVariants} screenshotAllVariants>
|
|
79
|
+
{variant => (
|
|
80
|
+
<div style={styles}>
|
|
81
|
+
<CircleButton
|
|
82
|
+
label="Label"
|
|
83
|
+
fullWidth={variant.fullWidth}
|
|
84
|
+
>
|
|
85
|
+
<Icon icon={HeartIcon} />
|
|
86
|
+
</CircleButton>
|
|
87
|
+
<CircleButton
|
|
88
|
+
label="Very long long label"
|
|
89
|
+
fullWidth={variant.fullWidth}
|
|
90
|
+
>
|
|
91
|
+
<Icon icon={HeartIcon} />
|
|
92
|
+
</CircleButton>
|
|
93
|
+
<CircleButton
|
|
94
|
+
label="Label"
|
|
95
|
+
fullWidth={variant.fullWidth}
|
|
96
|
+
>
|
|
97
|
+
<Icon icon={HeartIcon} />
|
|
98
|
+
</CircleButton>
|
|
99
|
+
<CircleButton
|
|
100
|
+
label="Label"
|
|
101
|
+
fullWidth={variant.fullWidth}
|
|
102
|
+
>
|
|
103
|
+
<Icon icon={HeartIcon} />
|
|
104
|
+
</CircleButton>
|
|
105
|
+
<CircleButton
|
|
106
|
+
label="Very long long label"
|
|
107
|
+
fullWidth={variant.fullWidth}
|
|
108
|
+
>
|
|
109
|
+
<Icon icon={HeartIcon} />
|
|
110
|
+
</CircleButton>
|
|
111
|
+
<CircleButton
|
|
112
|
+
label="Label"
|
|
113
|
+
fullWidth={variant.fullWidth}
|
|
114
|
+
>
|
|
115
|
+
<Icon icon={HeartIcon} />
|
|
116
|
+
</CircleButton>
|
|
117
|
+
</div>
|
|
118
|
+
)}
|
|
119
|
+
</Variants>
|
|
120
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const makeTypoColor = ({ theme, active, disabled }) => {
|
|
2
|
+
if (disabled) {
|
|
3
|
+
return theme.palette.text.disabled
|
|
4
|
+
}
|
|
5
|
+
if (active) {
|
|
6
|
+
return theme.palette.primary.main
|
|
7
|
+
}
|
|
8
|
+
return theme.palette.text.primary
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const makeButtonShadow = ({ theme, active, disabled }) => {
|
|
12
|
+
if (disabled || !active) {
|
|
13
|
+
return `inset 0 0 0 1px ${theme.palette.border.main}`
|
|
14
|
+
}
|
|
15
|
+
return `none`
|
|
16
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { makeTypoColor, makeButtonShadow } from './helpers'
|
|
2
|
+
|
|
3
|
+
const theme = {
|
|
4
|
+
palette: {
|
|
5
|
+
primary: { main: 'white' },
|
|
6
|
+
text: { disabled: 'lightGrey', primary: 'grey' },
|
|
7
|
+
border: { main: 'paleGrey' }
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe('makeTypoColor', () => {
|
|
12
|
+
it('should be correct color by default', () => {
|
|
13
|
+
const res = makeTypoColor({ theme, active: false, disabled: false })
|
|
14
|
+
|
|
15
|
+
expect(res).toBe('grey')
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('should be correct color when disabled', () => {
|
|
19
|
+
const res = makeTypoColor({ theme, active: false, disabled: true })
|
|
20
|
+
|
|
21
|
+
expect(res).toBe('lightGrey')
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('should be correct color when active', () => {
|
|
25
|
+
const res = makeTypoColor({ theme, active: true, disabled: false })
|
|
26
|
+
|
|
27
|
+
expect(res).toBe('white')
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('should be correct color when active disabled', () => {
|
|
31
|
+
const res = makeTypoColor({ theme, active: true, disabled: true })
|
|
32
|
+
|
|
33
|
+
expect(res).toBe('lightGrey')
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
describe('makeButtonShadow', () => {
|
|
38
|
+
it('should be correct color by default', () => {
|
|
39
|
+
const res = makeButtonShadow({ theme, active: false, disabled: false })
|
|
40
|
+
|
|
41
|
+
expect(res).toBe('inset 0 0 0 1px paleGrey')
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('should be correct color when disabled', () => {
|
|
45
|
+
const res = makeButtonShadow({ theme, active: false, disabled: true })
|
|
46
|
+
|
|
47
|
+
expect(res).toBe('inset 0 0 0 1px paleGrey')
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('should be none when active', () => {
|
|
51
|
+
const res = makeButtonShadow({ theme, active: true, disabled: false })
|
|
52
|
+
|
|
53
|
+
expect(res).toBe('none')
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('should be correct color when active disabled', () => {
|
|
57
|
+
const res = makeButtonShadow({ theme, active: true, disabled: true })
|
|
58
|
+
|
|
59
|
+
expect(res).toBe('inset 0 0 0 1px paleGrey')
|
|
60
|
+
})
|
|
61
|
+
})
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import { makeStyles } from '@material-ui/core/styles'
|
|
4
|
+
|
|
5
|
+
import Box from '../Box'
|
|
6
|
+
import IconButton from '../IconButton'
|
|
7
|
+
import Typography from '../Typography'
|
|
8
|
+
import { makeTypoColor, makeButtonShadow } from './helpers'
|
|
9
|
+
|
|
10
|
+
const useStyles = makeStyles(theme => ({
|
|
11
|
+
iconButton: {
|
|
12
|
+
margin: '0 auto',
|
|
13
|
+
boxShadow: ({ active, disabled }) =>
|
|
14
|
+
makeButtonShadow({ theme, active, disabled }),
|
|
15
|
+
backgroundColor: ({ active }) =>
|
|
16
|
+
active ? theme.palette.primary.main : 'transparent',
|
|
17
|
+
color: ({ active }) =>
|
|
18
|
+
active ? theme.palette.primary.contrastText : theme.palette.text.icon,
|
|
19
|
+
'&:hover': {
|
|
20
|
+
backgroundColor: ({ active }) =>
|
|
21
|
+
active ? theme.palette.primary.dark : theme.palette.action.hover
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
typography: {
|
|
25
|
+
marginTop: '0.25rem',
|
|
26
|
+
color: ({ active, disabled }) => makeTypoColor({ theme, active, disabled })
|
|
27
|
+
}
|
|
28
|
+
}))
|
|
29
|
+
|
|
30
|
+
const CircleButton = ({
|
|
31
|
+
className,
|
|
32
|
+
label,
|
|
33
|
+
variant = 'default',
|
|
34
|
+
disabled,
|
|
35
|
+
fullWidth = false,
|
|
36
|
+
children,
|
|
37
|
+
...props
|
|
38
|
+
}) => {
|
|
39
|
+
const styles = useStyles({ active: variant === 'active', disabled })
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Box
|
|
43
|
+
className={className}
|
|
44
|
+
display="inline-flex"
|
|
45
|
+
flexDirection="column"
|
|
46
|
+
flexGrow={fullWidth ? 1 : undefined}
|
|
47
|
+
minWidth="64px"
|
|
48
|
+
flexBasis="64px"
|
|
49
|
+
padding="8px 0 4px 0"
|
|
50
|
+
>
|
|
51
|
+
<IconButton
|
|
52
|
+
className={styles.iconButton}
|
|
53
|
+
size="large"
|
|
54
|
+
disabled={disabled}
|
|
55
|
+
{...props}
|
|
56
|
+
>
|
|
57
|
+
{children}
|
|
58
|
+
</IconButton>
|
|
59
|
+
{label && (
|
|
60
|
+
<Typography
|
|
61
|
+
component="div"
|
|
62
|
+
className={styles.typography}
|
|
63
|
+
variant="caption"
|
|
64
|
+
align="center"
|
|
65
|
+
noWrap
|
|
66
|
+
>
|
|
67
|
+
{label}
|
|
68
|
+
</Typography>
|
|
69
|
+
)}
|
|
70
|
+
</Box>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
CircleButton.propTypes = {
|
|
75
|
+
className: PropTypes.string,
|
|
76
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
77
|
+
variant: PropTypes.oneOf(['default', 'active']),
|
|
78
|
+
disabled: PropTypes.bool,
|
|
79
|
+
fullWidth: PropTypes.bool
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default CircleButton
|
package/react/Dialog/index.jsx
CHANGED
|
@@ -3,7 +3,7 @@ import { RemoveScroll } from 'react-remove-scroll'
|
|
|
3
3
|
import { default as MUIDialog } from '@material-ui/core/Dialog'
|
|
4
4
|
import { useTheme } from '@material-ui/core'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { getFlagshipMetadata } from 'cozy-device-helper'
|
|
7
7
|
|
|
8
8
|
import useBreakpoints from '../hooks/useBreakpoints'
|
|
9
9
|
import { useCozyTheme } from '../CozyTheme'
|
|
@@ -49,13 +49,13 @@ const Dialog = props => {
|
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
bottomBackground: theme.palette.background[sidebar ? 'default' : 'paper'],
|
|
52
|
-
bottomTheme:
|
|
52
|
+
bottomTheme: getFlagshipMetadata().immersive ? 'light' : 'dark',
|
|
53
53
|
bottomOverlay: 'transparent',
|
|
54
54
|
topOverlay: 'transparent',
|
|
55
55
|
topBackground:
|
|
56
56
|
cozBar && getComputedStyle(cozBar).getPropertyValue('background-color'),
|
|
57
57
|
topTheme:
|
|
58
|
-
|
|
58
|
+
getFlagshipMetadata().immersive ||
|
|
59
59
|
(cozBar && cozBar.classList.contains('coz-theme-primary'))
|
|
60
60
|
? 'light'
|
|
61
61
|
: 'dark'
|
|
@@ -1,30 +1,58 @@
|
|
|
1
1
|
A component suitable to be used when an Icon should be used as a button.
|
|
2
|
-
Provides hover, active styles + accessible size
|
|
2
|
+
Provides hover, active styles + accessible size.
|
|
3
3
|
|
|
4
4
|
```jsx
|
|
5
5
|
import IconButton from 'cozy-ui/transpiled/react/IconButton'
|
|
6
6
|
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
7
7
|
|
|
8
|
+
// <-- only useful for the documentation
|
|
8
9
|
import TrashIcon from 'cozy-ui/transpiled/react/Icons/Trash'
|
|
9
|
-
import LeftIcon from 'cozy-ui/transpiled/react/Icons/Left'
|
|
10
10
|
import RestoreIcon from 'cozy-ui/transpiled/react/Icons/Restore'
|
|
11
|
-
import RightIcon from 'cozy-ui/transpiled/react/Icons/Right'
|
|
12
11
|
import CrossIcon from 'cozy-ui/transpiled/react/Icons/Cross'
|
|
12
|
+
import Grid from 'cozy-ui/transpiled/react/MuiCozyTheme/Grid'
|
|
13
|
+
import Stack from 'cozy-ui/transpiled/react/Stack'
|
|
14
|
+
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
15
|
+
import Variants from 'cozy-ui/docs/components/Variants'
|
|
16
|
+
|
|
17
|
+
const columns = [{ title: 'default', disabled: false }, { title: 'disabled', disabled: true }]
|
|
18
|
+
const initialVariants = [{ small: false, medium: true, large: false }]
|
|
19
|
+
// -->
|
|
13
20
|
|
|
14
21
|
;
|
|
15
22
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
<Variants initialVariants={initialVariants} radio screenshotAllVariants>
|
|
24
|
+
{variant => (
|
|
25
|
+
<Grid container>
|
|
26
|
+
{columns.map(column =>
|
|
27
|
+
<Grid item xs={12} sm={6} className="u-mb-1" key={JSON.stringify(column)}>
|
|
28
|
+
<Stack spacing="s">
|
|
29
|
+
<Typography>{Object.values(column)[0]}</Typography>
|
|
30
|
+
<p>
|
|
31
|
+
<IconButton
|
|
32
|
+
disabled={Object.values(column)[1]}
|
|
33
|
+
size={Object.keys(variant).find(key => variant[key])}
|
|
34
|
+
>
|
|
35
|
+
<Icon icon={TrashIcon}/>
|
|
36
|
+
</IconButton>
|
|
37
|
+
<IconButton
|
|
38
|
+
color="primary"
|
|
39
|
+
disabled={Object.values(column)[1]}
|
|
40
|
+
size={Object.keys(variant).find(key => variant[key])}
|
|
41
|
+
>
|
|
42
|
+
<Icon icon={RestoreIcon} />
|
|
43
|
+
</IconButton>
|
|
44
|
+
<IconButton
|
|
45
|
+
color="secondary"
|
|
46
|
+
disabled={Object.values(column)[1]}
|
|
47
|
+
size={Object.keys(variant).find(key => variant[key])}
|
|
48
|
+
>
|
|
49
|
+
<Icon icon={CrossIcon}/>
|
|
50
|
+
</IconButton>
|
|
51
|
+
</p>
|
|
52
|
+
</Stack>
|
|
53
|
+
</Grid>
|
|
54
|
+
)}
|
|
55
|
+
</Grid>
|
|
56
|
+
)}
|
|
57
|
+
</Variants>
|
|
30
58
|
```
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import cx from 'classnames'
|
|
4
|
+
import MuiIconButton from '@material-ui/core/IconButton'
|
|
5
|
+
|
|
6
|
+
const IconButton = ({ size = 'medium', className, children, ...props }) => {
|
|
7
|
+
return (
|
|
8
|
+
<MuiIconButton className={cx(className, size)} {...props}>
|
|
9
|
+
{children}
|
|
10
|
+
</MuiIconButton>
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
IconButton.propTypes = {
|
|
15
|
+
className: PropTypes.string,
|
|
16
|
+
size: PropTypes.oneOf(['small', 'medium', 'large'])
|
|
17
|
+
}
|
|
2
18
|
|
|
3
19
|
export default IconButton
|
|
@@ -666,6 +666,15 @@ const makeOverrides = theme => ({
|
|
|
666
666
|
MuiIconButton: {
|
|
667
667
|
root: {
|
|
668
668
|
color: theme.palette.text.secondary,
|
|
669
|
+
'&.small': {
|
|
670
|
+
padding: 3
|
|
671
|
+
},
|
|
672
|
+
'&.medium': {
|
|
673
|
+
padding: 12
|
|
674
|
+
},
|
|
675
|
+
'&.large': {
|
|
676
|
+
padding: 16
|
|
677
|
+
},
|
|
669
678
|
'&.dialogIconButton': {
|
|
670
679
|
backgroundColor: theme.palette.background.paper,
|
|
671
680
|
'&:hover': {
|
|
@@ -7329,7 +7329,28 @@ exports[`Icon should render examples: Icon 6`] = `
|
|
|
7329
7329
|
</div>"
|
|
7330
7330
|
`;
|
|
7331
7331
|
|
|
7332
|
-
exports[`IconButton should render examples: IconButton 1`] = `
|
|
7332
|
+
exports[`IconButton should render examples: IconButton 1`] = `
|
|
7333
|
+
"<div>
|
|
7334
|
+
<div class=\\"MuiPaper-root u-p-1 u-mb-1 MuiPaper-elevation1\\">
|
|
7335
|
+
<h5 class=\\"MuiTypography-root u-mb-1 MuiTypography-h5\\">Variant selector</h5>
|
|
7336
|
+
<div class=\\"MuiFormGroup-root MuiFormGroup-row\\" role=\\"radiogroup\\" aria-label=\\"radio\\"><label class=\\"MuiFormControlLabel-root\\"><span class=\\"MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root-1 MuiRadio-root MuiRadio-colorPrimary MuiIconButton-colorPrimary\\" aria-disabled=\\"false\\"><span class=\\"MuiIconButton-label\\"><input class=\\"PrivateSwitchBase-input-4\\" name=\\"variantRadioSelector\\" type=\\"radio\\" value=\\"small\\"><svg viewBox=\\"0 0 16 16\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\"><path fill-rule=\\"evenodd\\" d=\\"M8 0a8 8 0 100 16A8 8 0 008 0zm0 14A6 6 0 108 2a6 6 0 000 12z\\" clip-rule=\\"evenodd\\"></path></svg></span></span><span class=\\"MuiTypography-root MuiFormControlLabel-label MuiTypography-body1\\">SMALL</span></label><label class=\\"MuiFormControlLabel-root\\"><span class=\\"MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root-1 MuiRadio-root MuiRadio-colorPrimary PrivateSwitchBase-checked-2 Mui-checked MuiIconButton-colorPrimary\\" aria-disabled=\\"false\\"><span class=\\"MuiIconButton-label\\"><input class=\\"PrivateSwitchBase-input-4\\" name=\\"variantRadioSelector\\" type=\\"radio\\" value=\\"medium\\" checked=\\"\\"><svg viewBox=\\"0 0 16 16\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\"><path fill-rule=\\"evenodd\\" d=\\"M8 16A8 8 0 108 0a8 8 0 000 16zm0-6a2 2 0 100-4 2 2 0 000 4z\\" clip-rule=\\"evenodd\\"></path></svg></span></span><span class=\\"MuiTypography-root MuiFormControlLabel-label MuiTypography-body1\\">MEDIUM</span></label><label class=\\"MuiFormControlLabel-root\\"><span class=\\"MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root-1 MuiRadio-root MuiRadio-colorPrimary MuiIconButton-colorPrimary\\" aria-disabled=\\"false\\"><span class=\\"MuiIconButton-label\\"><input class=\\"PrivateSwitchBase-input-4\\" name=\\"variantRadioSelector\\" type=\\"radio\\" value=\\"large\\"><svg viewBox=\\"0 0 16 16\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\"><path fill-rule=\\"evenodd\\" d=\\"M8 0a8 8 0 100 16A8 8 0 008 0zm0 14A6 6 0 108 2a6 6 0 000 12z\\" clip-rule=\\"evenodd\\"></path></svg></span></span><span class=\\"MuiTypography-root MuiFormControlLabel-label MuiTypography-body1\\">LARGE</span></label></div>
|
|
7337
|
+
</div>
|
|
7338
|
+
<div class=\\"MuiGrid-root MuiGrid-container\\">
|
|
7339
|
+
<div class=\\"MuiGrid-root u-mb-1 MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-6\\">
|
|
7340
|
+
<div class=\\"styles__Stack--s___22WMg\\">
|
|
7341
|
+
<p class=\\"MuiTypography-root MuiTypography-body1\\">default</p>
|
|
7342
|
+
<p><button class=\\"MuiButtonBase-root MuiIconButton-root medium\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiIconButton-label\\"><svg viewBox=\\"0 0 16 16\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\"><g fill-rule=\\"evenodd\\"><path d=\\"M4.5 1H2.007C1.45 1 1 1.448 1 2v1h14V2c0-.556-.45-1-1.007-1H11.5L11 0H5l-.5 1zM2 4h12v9.991A2.01 2.01 0 0111.991 16H4.01A2.01 2.01 0 012 13.991V4z\\"></path><path d=\\"M4.5 1H2.007C1.45 1 1 1.448 1 2v1h14V2c0-.556-.45-1-1.007-1H11.5L11 0H5l-.5 1zM2 4h12v9.991A2.01 2.01 0 0111.991 16H4.01A2.01 2.01 0 012 13.991V4z\\"></path></g></svg></span></button><button class=\\"MuiButtonBase-root MuiIconButton-root medium MuiIconButton-colorPrimary\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiIconButton-label\\"><svg viewBox=\\"0 0 16 16\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\"><g fill-rule=\\"evenodd\\"><path d=\\"M1 15h8c4.052 0 7-2.948 7-7s-2.948-7-7-7-7 2.948-7 7a1 1 0 102 0c0-2.948 2.052-5 5-5s5 2.052 5 5-2.052 5-5 5H1a1 1 0 000 2z\\"></path><path d=\\"M1.832 4.445a1 1 0 00-1.664 1.11l2 3a1 1 0 001.387.277l3-2a1 1 0 00-1.11-1.664L3.277 6.613 1.832 4.445z\\"></path></g></svg></span></button><button class=\\"MuiButtonBase-root MuiIconButton-root medium MuiIconButton-colorSecondary\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiIconButton-label\\"><svg viewBox=\\"0 0 24 24\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\"><path fill-rule=\\"evenodd\\" d=\\"M10.586 12L.293 1.707A1 1 0 011.707.293L12 10.586 22.293.293a1 1 0 011.414 1.414L13.414 12l10.293 10.293a1 1 0 01-1.414 1.414L12 13.414 1.707 23.707a1 1 0 01-1.414-1.414L10.586 12z\\"></path></svg></span></button></p>
|
|
7343
|
+
</div>
|
|
7344
|
+
</div>
|
|
7345
|
+
<div class=\\"MuiGrid-root u-mb-1 MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-6\\">
|
|
7346
|
+
<div class=\\"styles__Stack--s___22WMg\\">
|
|
7347
|
+
<p class=\\"MuiTypography-root MuiTypography-body1\\">disabled</p>
|
|
7348
|
+
<p><button class=\\"MuiButtonBase-root MuiIconButton-root medium Mui-disabled Mui-disabled\\" tabindex=\\"-1\\" type=\\"button\\" disabled=\\"\\"><span class=\\"MuiIconButton-label\\"><svg viewBox=\\"0 0 16 16\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\"><g fill-rule=\\"evenodd\\"><path d=\\"M4.5 1H2.007C1.45 1 1 1.448 1 2v1h14V2c0-.556-.45-1-1.007-1H11.5L11 0H5l-.5 1zM2 4h12v9.991A2.01 2.01 0 0111.991 16H4.01A2.01 2.01 0 012 13.991V4z\\"></path><path d=\\"M4.5 1H2.007C1.45 1 1 1.448 1 2v1h14V2c0-.556-.45-1-1.007-1H11.5L11 0H5l-.5 1zM2 4h12v9.991A2.01 2.01 0 0111.991 16H4.01A2.01 2.01 0 012 13.991V4z\\"></path></g></svg></span></button><button class=\\"MuiButtonBase-root MuiIconButton-root medium MuiIconButton-colorPrimary Mui-disabled Mui-disabled\\" tabindex=\\"-1\\" type=\\"button\\" disabled=\\"\\"><span class=\\"MuiIconButton-label\\"><svg viewBox=\\"0 0 16 16\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\"><g fill-rule=\\"evenodd\\"><path d=\\"M1 15h8c4.052 0 7-2.948 7-7s-2.948-7-7-7-7 2.948-7 7a1 1 0 102 0c0-2.948 2.052-5 5-5s5 2.052 5 5-2.052 5-5 5H1a1 1 0 000 2z\\"></path><path d=\\"M1.832 4.445a1 1 0 00-1.664 1.11l2 3a1 1 0 001.387.277l3-2a1 1 0 00-1.11-1.664L3.277 6.613 1.832 4.445z\\"></path></g></svg></span></button><button class=\\"MuiButtonBase-root MuiIconButton-root medium MuiIconButton-colorSecondary Mui-disabled Mui-disabled\\" tabindex=\\"-1\\" type=\\"button\\" disabled=\\"\\"><span class=\\"MuiIconButton-label\\"><svg viewBox=\\"0 0 24 24\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\"><path fill-rule=\\"evenodd\\" d=\\"M10.586 12L.293 1.707A1 1 0 011.707.293L12 10.586 22.293.293a1 1 0 011.414 1.414L13.414 12l10.293 10.293a1 1 0 01-1.414 1.414L12 13.414 1.707 23.707a1 1 0 01-1.414-1.414L10.586 12z\\"></path></svg></span></button></p>
|
|
7349
|
+
</div>
|
|
7350
|
+
</div>
|
|
7351
|
+
</div>
|
|
7352
|
+
</div>"
|
|
7353
|
+
`;
|
|
7333
7354
|
|
|
7334
7355
|
exports[`IconStack should render examples: IconStack 1`] = `
|
|
7335
7356
|
"<div>
|
|
@@ -7433,7 +7454,7 @@ exports[`InfosCarrousel should render examples: InfosCarrousel 1`] = `
|
|
|
7433
7454
|
</div>
|
|
7434
7455
|
</div>
|
|
7435
7456
|
</div>
|
|
7436
|
-
<div class=\\"styles__InfosCarrousel-navigation___3s_hu\\"><button class=\\"MuiButtonBase-root MuiIconButton-root Mui-disabled Mui-disabled\\" tabindex=\\"-1\\" type=\\"button\\" disabled=\\"\\"><span class=\\"MuiIconButton-label\\"><svg viewBox=\\"0 0 16 16\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\"><path fill-rule=\\"evenodd\\" d=\\"M10.707 2.707a.999.999 0 10-1.414-1.414l-6 6a.999.999 0 000 1.414l6 6a.999.999 0 101.414-1.414L5.414 8l5.293-5.293z\\"></path></svg></span></button><span class=\\"styles__InfosCarrousel-separator___AvH5m\\"></span><button class=\\"MuiButtonBase-root MuiIconButton-root\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiIconButton-label\\"><svg viewBox=\\"0 0 16 16\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\"><path fill-rule=\\"evenodd\\" d=\\"M12.707 7.293l-6-6a.999.999 0 10-1.414 1.414L10.586 8l-5.293 5.293a.999.999 0 101.414 1.414l6-6a.999.999 0 000-1.414\\"></path></svg></span></button></div>
|
|
7457
|
+
<div class=\\"styles__InfosCarrousel-navigation___3s_hu\\"><button class=\\"MuiButtonBase-root MuiIconButton-root medium Mui-disabled Mui-disabled\\" tabindex=\\"-1\\" type=\\"button\\" disabled=\\"\\"><span class=\\"MuiIconButton-label\\"><svg viewBox=\\"0 0 16 16\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\"><path fill-rule=\\"evenodd\\" d=\\"M10.707 2.707a.999.999 0 10-1.414-1.414l-6 6a.999.999 0 000 1.414l6 6a.999.999 0 101.414-1.414L5.414 8l5.293-5.293z\\"></path></svg></span></button><span class=\\"styles__InfosCarrousel-separator___AvH5m\\"></span><button class=\\"MuiButtonBase-root MuiIconButton-root medium\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiIconButton-label\\"><svg viewBox=\\"0 0 16 16\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\"><path fill-rule=\\"evenodd\\" d=\\"M12.707 7.293l-6-6a.999.999 0 10-1.414 1.414L10.586 8l-5.293 5.293a.999.999 0 101.414 1.414l6-6a.999.999 0 000-1.414\\"></path></svg></span></button></div>
|
|
7437
7458
|
</div>
|
|
7438
7459
|
</div>
|
|
7439
7460
|
</div>"
|
package/react/index.js
CHANGED
|
@@ -105,3 +105,4 @@ export { default as FilePicker } from './FilePicker'
|
|
|
105
105
|
export { default as Chips } from './Chips'
|
|
106
106
|
export { default as PieChart } from './PieChart'
|
|
107
107
|
export { default as DropdownText } from './DropdownText'
|
|
108
|
+
export { default as CircleButton } from './CircleButton'
|
|
@@ -8,7 +8,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
8
8
|
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
10
|
import { BottomSheet as MuiBottomSheet } from 'mui-bottom-sheet';
|
|
11
|
-
import {
|
|
11
|
+
import { getFlagshipMetadata } from 'cozy-device-helper';
|
|
12
12
|
import Stack from 'cozy-ui/transpiled/react/Stack';
|
|
13
13
|
import Paper from 'cozy-ui/transpiled/react/Paper';
|
|
14
14
|
|
|
@@ -126,7 +126,7 @@ var BottomSheet = function BottomSheet(_ref2) {
|
|
|
126
126
|
var computedMediumHeight = mediumHeight || Math.round(maxHeight * mediumHeightRatio);
|
|
127
127
|
var actionButtonsHeight = headerContent ? parseFloat(getComputedStyle(headerContent).getPropertyValue('height')) : 0;
|
|
128
128
|
var actionButtonsBottomMargin = headerContent ? parseFloat(getComputedStyle(headerContent).getPropertyValue('padding-bottom')) : 0;
|
|
129
|
-
var minHeight = headerRef.current.offsetHeight + actionButtonsHeight + actionButtonsBottomMargin + (
|
|
129
|
+
var minHeight = headerRef.current.offsetHeight + actionButtonsHeight + actionButtonsBottomMargin + (getFlagshipMetadata().navbarHeight || 0); // Used so that the bottomSheet can be opened to the top,
|
|
130
130
|
// without stopping at the content height
|
|
131
131
|
|
|
132
132
|
var bottomSpacerHeight = maxHeight - innerContentRef.current.offsetHeight;
|
|
@@ -157,7 +157,7 @@ var BottomSheet = function BottomSheet(_ref2) {
|
|
|
157
157
|
|
|
158
158
|
return child;
|
|
159
159
|
});
|
|
160
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
160
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, getFlagshipMetadata().immersive && /*#__PURE__*/React.createElement("span", {
|
|
161
161
|
style: styles.flagshipImmersive
|
|
162
162
|
}), /*#__PURE__*/React.createElement(MuiBottomSheet, {
|
|
163
163
|
peekHeights: peekHeights,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export var makeTypoColor = function makeTypoColor(_ref) {
|
|
2
|
+
var theme = _ref.theme,
|
|
3
|
+
active = _ref.active,
|
|
4
|
+
disabled = _ref.disabled;
|
|
5
|
+
|
|
6
|
+
if (disabled) {
|
|
7
|
+
return theme.palette.text.disabled;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (active) {
|
|
11
|
+
return theme.palette.primary.main;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return theme.palette.text.primary;
|
|
15
|
+
};
|
|
16
|
+
export var makeButtonShadow = function makeButtonShadow(_ref2) {
|
|
17
|
+
var theme = _ref2.theme,
|
|
18
|
+
active = _ref2.active,
|
|
19
|
+
disabled = _ref2.disabled;
|
|
20
|
+
|
|
21
|
+
if (disabled || !active) {
|
|
22
|
+
return "inset 0 0 0 1px ".concat(theme.palette.border.main);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return "none";
|
|
26
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["className", "label", "variant", "disabled", "fullWidth", "children"];
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
7
|
+
import Box from "cozy-ui/transpiled/react/Box";
|
|
8
|
+
import IconButton from "cozy-ui/transpiled/react/IconButton";
|
|
9
|
+
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
10
|
+
import { makeTypoColor, makeButtonShadow } from "cozy-ui/transpiled/react/CircleButton/helpers";
|
|
11
|
+
var useStyles = makeStyles(function (theme) {
|
|
12
|
+
return {
|
|
13
|
+
iconButton: {
|
|
14
|
+
margin: '0 auto',
|
|
15
|
+
boxShadow: function boxShadow(_ref) {
|
|
16
|
+
var active = _ref.active,
|
|
17
|
+
disabled = _ref.disabled;
|
|
18
|
+
return makeButtonShadow({
|
|
19
|
+
theme: theme,
|
|
20
|
+
active: active,
|
|
21
|
+
disabled: disabled
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
backgroundColor: function backgroundColor(_ref2) {
|
|
25
|
+
var active = _ref2.active;
|
|
26
|
+
return active ? theme.palette.primary.main : 'transparent';
|
|
27
|
+
},
|
|
28
|
+
color: function color(_ref3) {
|
|
29
|
+
var active = _ref3.active;
|
|
30
|
+
return active ? theme.palette.primary.contrastText : theme.palette.text.icon;
|
|
31
|
+
},
|
|
32
|
+
'&:hover': {
|
|
33
|
+
backgroundColor: function backgroundColor(_ref4) {
|
|
34
|
+
var active = _ref4.active;
|
|
35
|
+
return active ? theme.palette.primary.dark : theme.palette.action.hover;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
typography: {
|
|
40
|
+
marginTop: '0.25rem',
|
|
41
|
+
color: function color(_ref5) {
|
|
42
|
+
var active = _ref5.active,
|
|
43
|
+
disabled = _ref5.disabled;
|
|
44
|
+
return makeTypoColor({
|
|
45
|
+
theme: theme,
|
|
46
|
+
active: active,
|
|
47
|
+
disabled: disabled
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
var CircleButton = function CircleButton(_ref6) {
|
|
55
|
+
var className = _ref6.className,
|
|
56
|
+
label = _ref6.label,
|
|
57
|
+
_ref6$variant = _ref6.variant,
|
|
58
|
+
variant = _ref6$variant === void 0 ? 'default' : _ref6$variant,
|
|
59
|
+
disabled = _ref6.disabled,
|
|
60
|
+
_ref6$fullWidth = _ref6.fullWidth,
|
|
61
|
+
fullWidth = _ref6$fullWidth === void 0 ? false : _ref6$fullWidth,
|
|
62
|
+
children = _ref6.children,
|
|
63
|
+
props = _objectWithoutProperties(_ref6, _excluded);
|
|
64
|
+
|
|
65
|
+
var styles = useStyles({
|
|
66
|
+
active: variant === 'active',
|
|
67
|
+
disabled: disabled
|
|
68
|
+
});
|
|
69
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
70
|
+
className: className,
|
|
71
|
+
display: "inline-flex",
|
|
72
|
+
flexDirection: "column",
|
|
73
|
+
flexGrow: fullWidth ? 1 : undefined,
|
|
74
|
+
minWidth: "64px",
|
|
75
|
+
flexBasis: "64px",
|
|
76
|
+
padding: "8px 0 4px 0"
|
|
77
|
+
}, /*#__PURE__*/React.createElement(IconButton, _extends({
|
|
78
|
+
className: styles.iconButton,
|
|
79
|
+
size: "large",
|
|
80
|
+
disabled: disabled
|
|
81
|
+
}, props), children), label && /*#__PURE__*/React.createElement(Typography, {
|
|
82
|
+
component: "div",
|
|
83
|
+
className: styles.typography,
|
|
84
|
+
variant: "caption",
|
|
85
|
+
align: "center",
|
|
86
|
+
noWrap: true
|
|
87
|
+
}, label));
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
CircleButton.propTypes = {
|
|
91
|
+
className: PropTypes.string,
|
|
92
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
93
|
+
variant: PropTypes.oneOf(['default', 'active']),
|
|
94
|
+
disabled: PropTypes.bool,
|
|
95
|
+
fullWidth: PropTypes.bool
|
|
96
|
+
};
|
|
97
|
+
export default CircleButton;
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { RemoveScroll } from 'react-remove-scroll';
|
|
4
4
|
import { default as MUIDialog } from '@material-ui/core/Dialog';
|
|
5
5
|
import { useTheme } from '@material-ui/core';
|
|
6
|
-
import {
|
|
6
|
+
import { getFlagshipMetadata } from 'cozy-device-helper';
|
|
7
7
|
import useBreakpoints from "cozy-ui/transpiled/react/hooks/useBreakpoints";
|
|
8
8
|
import { useCozyTheme } from "cozy-ui/transpiled/react/CozyTheme";
|
|
9
9
|
var themesStyles = {
|
|
@@ -45,11 +45,11 @@ var Dialog = function Dialog(props) {
|
|
|
45
45
|
topTheme: 'light'
|
|
46
46
|
}, {
|
|
47
47
|
bottomBackground: theme.palette.background[sidebar ? 'default' : 'paper'],
|
|
48
|
-
bottomTheme:
|
|
48
|
+
bottomTheme: getFlagshipMetadata().immersive ? 'light' : 'dark',
|
|
49
49
|
bottomOverlay: 'transparent',
|
|
50
50
|
topOverlay: 'transparent',
|
|
51
51
|
topBackground: cozBar && getComputedStyle(cozBar).getPropertyValue('background-color'),
|
|
52
|
-
topTheme:
|
|
52
|
+
topTheme: getFlagshipMetadata().immersive || cozBar && cozBar.classList.contains('coz-theme-primary') ? 'light' : 'dark'
|
|
53
53
|
}, 'cozy-ui/Dialog');
|
|
54
54
|
return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(MUIDialog, _extends({
|
|
55
55
|
className: themesStyles["CozyTheme--".concat(cozyTheme)]
|
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["size", "className", "children"];
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import cx from 'classnames';
|
|
7
|
+
import MuiIconButton from '@material-ui/core/IconButton';
|
|
8
|
+
|
|
9
|
+
var IconButton = function IconButton(_ref) {
|
|
10
|
+
var _ref$size = _ref.size,
|
|
11
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
12
|
+
className = _ref.className,
|
|
13
|
+
children = _ref.children,
|
|
14
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
15
|
+
|
|
16
|
+
return /*#__PURE__*/React.createElement(MuiIconButton, _extends({
|
|
17
|
+
className: cx(className, size)
|
|
18
|
+
}, props), children);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
IconButton.propTypes = {
|
|
22
|
+
className: PropTypes.string,
|
|
23
|
+
size: PropTypes.oneOf(['small', 'medium', 'large'])
|
|
24
|
+
};
|
|
2
25
|
export default IconButton;
|
|
@@ -606,6 +606,15 @@ var makeOverrides = function makeOverrides(theme) {
|
|
|
606
606
|
MuiIconButton: {
|
|
607
607
|
root: {
|
|
608
608
|
color: theme.palette.text.secondary,
|
|
609
|
+
'&.small': {
|
|
610
|
+
padding: 3
|
|
611
|
+
},
|
|
612
|
+
'&.medium': {
|
|
613
|
+
padding: 12
|
|
614
|
+
},
|
|
615
|
+
'&.large': {
|
|
616
|
+
padding: 16
|
|
617
|
+
},
|
|
609
618
|
'&.dialogIconButton': {
|
|
610
619
|
backgroundColor: theme.palette.background.paper,
|
|
611
620
|
'&:hover': {
|
|
@@ -82,4 +82,5 @@ export { default as BottomSheet, BottomSheetItem } from './BottomSheet';
|
|
|
82
82
|
export { default as FilePicker } from './FilePicker';
|
|
83
83
|
export { default as Chips } from './Chips';
|
|
84
84
|
export { default as PieChart } from './PieChart';
|
|
85
|
-
export { default as DropdownText } from './DropdownText';
|
|
85
|
+
export { default as DropdownText } from './DropdownText';
|
|
86
|
+
export { default as CircleButton } from './CircleButton';
|