cozy-ui 127.4.0 → 127.5.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 +7 -0
- package/dist/cozy-ui.min.css +1 -1
- package/package.json +1 -1
- package/react/Layout/Layout.jsx +9 -19
- package/react/Layout/Layout.md +73 -23
- package/scripts/screenshots/screenshotComponent.js +4 -8
- package/stylus/elements/defaults.styl +1 -11
- package/stylus/objects/layouts.styl +13 -47
- package/transpiled/react/Layout/Layout.js +9 -9
- package/transpiled/react/stylesheet.css +1 -1
package/package.json
CHANGED
package/react/Layout/Layout.jsx
CHANGED
|
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types'
|
|
|
3
3
|
import React, { createContext, forwardRef, useContext, useMemo } from 'react'
|
|
4
4
|
|
|
5
5
|
import styles from './styles.styl'
|
|
6
|
+
import { useBreakpoints } from '../providers/Breakpoints'
|
|
6
7
|
|
|
7
8
|
export const LayoutContext = createContext()
|
|
8
9
|
|
|
@@ -33,20 +34,13 @@ LayoutProvider.displayName = 'LayoutProvider'
|
|
|
33
34
|
|
|
34
35
|
export const Layout = forwardRef(
|
|
35
36
|
({ children, className, monoColumn, withTopBar, ...props }, ref) => {
|
|
36
|
-
const variant = monoColumn ? 'monocolumn' : '2panes'
|
|
37
|
-
|
|
38
37
|
return (
|
|
39
38
|
<LayoutProvider monoColumn={monoColumn} withTopBar={withTopBar}>
|
|
40
39
|
<div
|
|
41
40
|
ref={ref}
|
|
42
|
-
className={cx(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
styles[`o-layout-${variant}`],
|
|
46
|
-
{
|
|
47
|
-
[styles[`o-layout-topbar`]]: withTopBar
|
|
48
|
-
}
|
|
49
|
-
)}
|
|
41
|
+
className={cx(className, styles['o-layout'], {
|
|
42
|
+
[styles['o-layout-main-2panes']]: !monoColumn
|
|
43
|
+
})}
|
|
50
44
|
{...props}
|
|
51
45
|
>
|
|
52
46
|
{children}
|
|
@@ -59,20 +53,16 @@ export const Layout = forwardRef(
|
|
|
59
53
|
Layout.displayName = 'Layout'
|
|
60
54
|
|
|
61
55
|
export const Main = forwardRef(({ className, children, ...props }, ref) => {
|
|
56
|
+
const { isDesktop } = useBreakpoints()
|
|
62
57
|
const { monoColumn, withTopBar } = useLayout()
|
|
63
|
-
const variant = monoColumn ? 'monocolumn' : '2panes'
|
|
64
58
|
|
|
65
59
|
return (
|
|
66
60
|
<main
|
|
67
61
|
ref={ref}
|
|
68
|
-
className={cx(
|
|
69
|
-
|
|
70
|
-
styles[
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
[styles[`o-layout-main-${variant}--topbar`]]: withTopBar
|
|
74
|
-
}
|
|
75
|
-
)}
|
|
62
|
+
className={cx(className, styles['o-layout-main'], {
|
|
63
|
+
[styles['o-layout-main-2panes']]: !monoColumn,
|
|
64
|
+
[styles[`o-layout-main-topbar`]]: withTopBar && !isDesktop
|
|
65
|
+
})}
|
|
76
66
|
{...props}
|
|
77
67
|
>
|
|
78
68
|
{children}
|
package/react/Layout/Layout.md
CHANGED
|
@@ -29,8 +29,13 @@ import Sidebar from 'cozy-ui/transpiled/react/Sidebar'
|
|
|
29
29
|
import Nav, { NavItem, NavIcon, NavText, genNavLink, NavDesktopLimiter } from 'cozy-ui/transpiled/react/Nav'
|
|
30
30
|
import cx from 'classnames'
|
|
31
31
|
import isEqual from 'lodash/isEqual'
|
|
32
|
+
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
33
|
+
import IconButton from 'cozy-ui/transpiled/react/IconButton'
|
|
32
34
|
import WarnIcon from 'cozy-ui/transpiled/react/Icons/Warn'
|
|
33
35
|
import CheckIcon from 'cozy-ui/transpiled/react/Icons/Check'
|
|
36
|
+
import CrossMediumIcon from 'cozy-ui/transpiled/react/Icons/CrossMedium'
|
|
37
|
+
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
38
|
+
import Dialog from 'cozy-ui/transpiled/react/Dialog'
|
|
34
39
|
import DownloadIcon from 'cozy-ui/transpiled/react/Icons/Download'
|
|
35
40
|
import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
|
|
36
41
|
import { makeStyles } from 'cozy-ui/transpiled/react/styles'
|
|
@@ -51,18 +56,36 @@ const ExampleRouterNavLink = ({ children, className, active, activeClassName, on
|
|
|
51
56
|
const NavLink = genNavLink(ExampleRouterNavLink)
|
|
52
57
|
|
|
53
58
|
// Not necessary in a normal app
|
|
54
|
-
const useStyles = makeStyles({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
'
|
|
59
|
-
|
|
59
|
+
const useStyles = makeStyles(theme => ({
|
|
60
|
+
topBar: { // same style than the cozy-bar
|
|
61
|
+
display: 'flex',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
padding: '0 1rem',
|
|
64
|
+
minHeight: '3rem',
|
|
65
|
+
width: '100%',
|
|
66
|
+
boxSizing: 'border-box',
|
|
67
|
+
zIndex: 'var(--zIndex-bar)',
|
|
68
|
+
backgroundColor: theme.palette.background.default,
|
|
69
|
+
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
70
|
+
position: 'fixed',
|
|
71
|
+
top: 0,
|
|
72
|
+
right: 0,
|
|
73
|
+
[theme.breakpoints.up('lg')]: {
|
|
74
|
+
position: 'relative',
|
|
60
75
|
}
|
|
76
|
+
},
|
|
77
|
+
closeButton: {
|
|
78
|
+
position: 'absolute',
|
|
79
|
+
top: '1.15rem',
|
|
80
|
+
right: '1.15rem',
|
|
81
|
+
zIndex: 'var(--zIndex-modal-toolbar)',
|
|
82
|
+
backgroundColor: theme.palette.background.paper
|
|
61
83
|
}
|
|
62
|
-
})
|
|
84
|
+
}))
|
|
63
85
|
|
|
64
|
-
const initialVariants = [{ monoColumn: false, withTopBar: true }]
|
|
86
|
+
const initialVariants = [{ monoColumn: false, withTopBar: true, longContent: true }]
|
|
65
87
|
const [active, setActive] = useState(['Section 1', 'Subsection 1'])
|
|
88
|
+
const [showDialog, setShowDialog] = useState(isTesting() ? true : false)
|
|
66
89
|
const styles = useStyles()
|
|
67
90
|
|
|
68
91
|
;
|
|
@@ -112,23 +135,50 @@ const SideBar = ({ variant }) => {
|
|
|
112
135
|
)
|
|
113
136
|
}
|
|
114
137
|
|
|
115
|
-
<Variants initialVariants={initialVariants}
|
|
138
|
+
<Variants initialVariants={initialVariants}>
|
|
116
139
|
{variant => (
|
|
117
140
|
<DemoProvider>
|
|
118
|
-
<
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
<
|
|
127
|
-
|
|
128
|
-
{
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
141
|
+
<Button className="u-mb-1" label="Open layout in modal" onClick={() => setShowDialog(true)} />
|
|
142
|
+
{showDialog && (
|
|
143
|
+
<Dialog
|
|
144
|
+
className="cozy-ui-body"
|
|
145
|
+
open
|
|
146
|
+
fullScreen
|
|
147
|
+
fullWidth
|
|
148
|
+
>
|
|
149
|
+
<IconButton
|
|
150
|
+
className={styles.closeButton}
|
|
151
|
+
onClick={() => setShowDialog(false)}
|
|
152
|
+
>
|
|
153
|
+
<Icon icon={CrossMediumIcon} />
|
|
154
|
+
</IconButton>
|
|
155
|
+
{variant.withTopBar &&
|
|
156
|
+
<div
|
|
157
|
+
id="coz-bar"
|
|
158
|
+
role="banner"
|
|
159
|
+
className={styles.topBar}
|
|
160
|
+
>
|
|
161
|
+
Fake TopBar
|
|
162
|
+
</div>
|
|
163
|
+
}
|
|
164
|
+
<div role="application">
|
|
165
|
+
<Layout
|
|
166
|
+
withTopBar={variant.withTopBar}
|
|
167
|
+
monoColumn={variant.monoColumn}
|
|
168
|
+
>
|
|
169
|
+
{!variant.monoColumn && <SideBar variant={variant} />}
|
|
170
|
+
<Main>
|
|
171
|
+
<Content className='u-p-1'>
|
|
172
|
+
<h2 className='u-mt-0'>{ active.join(' / ') }</h2>
|
|
173
|
+
<p>---Start---</p>
|
|
174
|
+
{variant.longContent ? content.ada.long : content.ada.short}
|
|
175
|
+
<p>---END---</p>
|
|
176
|
+
</Content>
|
|
177
|
+
</Main>
|
|
178
|
+
</Layout>
|
|
179
|
+
</div>
|
|
180
|
+
</Dialog>
|
|
181
|
+
)}
|
|
132
182
|
</DemoProvider>
|
|
133
183
|
)}
|
|
134
184
|
</Variants>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
|
+
|
|
2
3
|
const { sleep } = require('./helpers')
|
|
3
4
|
|
|
4
5
|
const rootDirectory = path.join(__dirname, '../')
|
|
@@ -22,17 +23,12 @@ const getDefaultScreenshotName = ({
|
|
|
22
23
|
* component.
|
|
23
24
|
*/
|
|
24
25
|
const screenshotComponent = async (page, options) => {
|
|
25
|
-
const {
|
|
26
|
-
|
|
27
|
-
screenshotDir,
|
|
28
|
-
viewport,
|
|
29
|
-
type,
|
|
30
|
-
variant,
|
|
31
|
-
componentConfig
|
|
32
|
-
} = options
|
|
26
|
+
const { component, screenshotDir, viewport, type, variant, componentConfig } =
|
|
27
|
+
options
|
|
33
28
|
const { link, name } = component
|
|
34
29
|
|
|
35
30
|
await page.goto(link)
|
|
31
|
+
await page.addStyleTag({ content: 'body {height: auto;}' }) // to resize viewport according to its content
|
|
36
32
|
await sleep(200) // to be sure the page is entirely loaded
|
|
37
33
|
|
|
38
34
|
const getScreenshotName =
|
|
@@ -35,21 +35,11 @@ body
|
|
|
35
35
|
textarea
|
|
36
36
|
@extend $font-labor
|
|
37
37
|
|
|
38
|
-
html
|
|
39
|
-
body
|
|
40
|
-
+medium-screen()
|
|
41
|
-
display block
|
|
42
|
-
height auto
|
|
43
|
-
|
|
44
38
|
[role=application]
|
|
45
39
|
display flex
|
|
46
40
|
height inherit
|
|
47
41
|
flex 1 1 100%
|
|
48
|
-
overflow
|
|
49
|
-
overflow-y auto
|
|
50
|
-
|
|
51
|
-
+medium-screen()
|
|
52
|
-
overflow visible
|
|
42
|
+
overflow hidden auto
|
|
53
43
|
|
|
54
44
|
// FORMS
|
|
55
45
|
@require '../components/forms'
|
|
@@ -59,87 +59,53 @@ $app-layout
|
|
|
59
59
|
background-color var(--paperBackgroundColor)
|
|
60
60
|
color var(--primaryTextColor)
|
|
61
61
|
|
|
62
|
-
+medium-screen() // mobile + tablet
|
|
63
|
-
display block
|
|
64
|
-
|
|
65
|
-
&-topbar
|
|
66
|
-
+medium-screen() // mobile + tablet
|
|
67
|
-
// this pseudo-element is "ghost" element replacing bar
|
|
68
|
-
&:before
|
|
69
|
-
content ''
|
|
70
|
-
display block
|
|
71
|
-
height barHeight
|
|
72
|
-
|
|
73
62
|
// When you want a sidebar
|
|
74
63
|
&-2panes
|
|
75
64
|
flex 0 0 100%
|
|
76
65
|
align-items stretch
|
|
77
66
|
|
|
78
|
-
+medium-screen() // mobile + tablet
|
|
79
|
-
// this pseudo-element is "ghost" element replacing nav
|
|
80
|
-
&:after
|
|
81
|
-
content ''
|
|
82
|
-
display block
|
|
83
|
-
height navHeight
|
|
84
|
-
|
|
85
67
|
$app-main
|
|
86
68
|
display flex
|
|
87
69
|
flex-direction column
|
|
88
70
|
position relative
|
|
89
71
|
flex 1 1 auto
|
|
90
72
|
box-sizing border-box
|
|
91
|
-
overflow
|
|
92
|
-
|
|
73
|
+
overflow hidden
|
|
74
|
+
height 100%
|
|
93
75
|
|
|
94
76
|
+medium-screen() // mobile + tablet
|
|
95
|
-
display block
|
|
96
|
-
overflow visible
|
|
97
77
|
// iPhone X environment tweak
|
|
98
78
|
padding-left env(safe-area-inset-left)
|
|
99
79
|
padding-right env(safe-area-inset-right)
|
|
100
80
|
padding-bottom env(safe-area-inset-bottom)
|
|
101
81
|
|
|
102
|
-
&-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
min-height 'calc(100vh - %s)' % barHeight
|
|
82
|
+
&-topbar
|
|
83
|
+
// this pseudo-element is "ghost" element replacing bar
|
|
84
|
+
&:before
|
|
85
|
+
content ''
|
|
86
|
+
display block
|
|
87
|
+
height barHeight
|
|
88
|
+
width 100%
|
|
89
|
+
background-color var(--paperBackgroundColor)
|
|
111
90
|
|
|
112
91
|
&-2panes
|
|
113
|
-
height auto
|
|
114
92
|
background-color var(--defaultBackgroundColor)
|
|
115
93
|
|
|
116
94
|
+medium-screen() // mobile + tablet
|
|
117
|
-
|
|
95
|
+
height calc(100vh - var(--sidebarHeight))
|
|
118
96
|
background-color transparent
|
|
119
97
|
|
|
120
|
-
&--topbar
|
|
121
|
-
+medium-screen() // mobile + tablet
|
|
122
|
-
min-height 'calc(100vh - var(--sidebarHeight) - %s)' % barHeight
|
|
123
|
-
|
|
124
98
|
$app-content
|
|
125
99
|
position relative
|
|
126
100
|
display flex
|
|
127
101
|
flex-direction column
|
|
128
102
|
flex 1 1 auto
|
|
129
103
|
box-sizing border-box
|
|
130
|
-
overflow
|
|
131
|
-
overflow-y auto
|
|
104
|
+
overflow hidden auto
|
|
132
105
|
background-color var(--paperBackgroundColor)
|
|
133
|
-
|
|
134
|
-
+medium-screen() // mobile + tablet
|
|
135
|
-
display block
|
|
136
|
-
overflow visible
|
|
137
|
-
|
|
138
|
-
&-monocolumn
|
|
139
|
-
height 100%
|
|
106
|
+
height 100%
|
|
140
107
|
|
|
141
108
|
&-2panes
|
|
142
|
-
height auto
|
|
143
109
|
margin 1rem 1rem 1rem 0
|
|
144
110
|
border-radius 1rem
|
|
145
111
|
|
|
@@ -9,17 +9,14 @@ import PropTypes from 'prop-types';
|
|
|
9
9
|
import React, { createContext, forwardRef, useContext, useMemo } from 'react';
|
|
10
10
|
var styles = {
|
|
11
11
|
"o-layout": "styles__o-layout___3TSz9",
|
|
12
|
-
"o-layout-topbar": "styles__o-layout-topbar___2SHWi",
|
|
13
12
|
"o-layout-2panes": "styles__o-layout-2panes___1CDQw",
|
|
14
13
|
"o-layout-main": "styles__o-layout-main___3mPxz",
|
|
15
|
-
"o-layout-main-
|
|
16
|
-
"o-layout-main-monocolumn--topbar": "styles__o-layout-main-monocolumn--topbar___9_4Xd",
|
|
14
|
+
"o-layout-main-topbar": "styles__o-layout-main-topbar___3FSE_",
|
|
17
15
|
"o-layout-main-2panes": "styles__o-layout-main-2panes___3ickD",
|
|
18
|
-
"o-layout-main-2panes--topbar": "styles__o-layout-main-2panes--topbar___cGi-H",
|
|
19
16
|
"o-layout-content": "styles__o-layout-content___3D5gN",
|
|
20
|
-
"o-layout-content-monocolumn": "styles__o-layout-content-monocolumn___1rpxp",
|
|
21
17
|
"o-layout-content-2panes": "styles__o-layout-content-2panes___2Hotr"
|
|
22
18
|
};
|
|
19
|
+
import { useBreakpoints } from "cozy-ui/transpiled/react/providers/Breakpoints";
|
|
23
20
|
export var LayoutContext = /*#__PURE__*/createContext();
|
|
24
21
|
export var useLayout = function useLayout() {
|
|
25
22
|
var context = useContext(LayoutContext);
|
|
@@ -52,29 +49,32 @@ export var Layout = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
52
49
|
withTopBar = _ref2.withTopBar,
|
|
53
50
|
props = _objectWithoutProperties(_ref2, _excluded);
|
|
54
51
|
|
|
55
|
-
var variant = monoColumn ? 'monocolumn' : '2panes';
|
|
56
52
|
return /*#__PURE__*/React.createElement(LayoutProvider, {
|
|
57
53
|
monoColumn: monoColumn,
|
|
58
54
|
withTopBar: withTopBar
|
|
59
55
|
}, /*#__PURE__*/React.createElement("div", _extends({
|
|
60
56
|
ref: ref,
|
|
61
|
-
className: cx(className, styles['o-layout'],
|
|
57
|
+
className: cx(className, styles['o-layout'], _defineProperty({}, styles['o-layout-main-2panes'], !monoColumn))
|
|
62
58
|
}, props), children));
|
|
63
59
|
});
|
|
64
60
|
Layout.displayName = 'Layout';
|
|
65
61
|
export var Main = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
62
|
+
var _cx2;
|
|
63
|
+
|
|
66
64
|
var className = _ref3.className,
|
|
67
65
|
children = _ref3.children,
|
|
68
66
|
props = _objectWithoutProperties(_ref3, _excluded2);
|
|
69
67
|
|
|
68
|
+
var _useBreakpoints = useBreakpoints(),
|
|
69
|
+
isDesktop = _useBreakpoints.isDesktop;
|
|
70
|
+
|
|
70
71
|
var _useLayout = useLayout(),
|
|
71
72
|
monoColumn = _useLayout.monoColumn,
|
|
72
73
|
withTopBar = _useLayout.withTopBar;
|
|
73
74
|
|
|
74
|
-
var variant = monoColumn ? 'monocolumn' : '2panes';
|
|
75
75
|
return /*#__PURE__*/React.createElement("main", _extends({
|
|
76
76
|
ref: ref,
|
|
77
|
-
className: cx(className, styles['o-layout-main'], styles[
|
|
77
|
+
className: cx(className, styles['o-layout-main'], (_cx2 = {}, _defineProperty(_cx2, styles['o-layout-main-2panes'], !monoColumn), _defineProperty(_cx2, styles["o-layout-main-topbar"], withTopBar && !isDesktop), _cx2))
|
|
78
78
|
}, props), children);
|
|
79
79
|
});
|
|
80
80
|
Main.displayName = 'Main';
|