cozy-ui 124.1.1 → 124.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "124.1.1",
3
+ "version": "124.2.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -4,13 +4,22 @@ import React, { Component } from 'react'
4
4
 
5
5
  import styles from './styles.styl'
6
6
 
7
- export const Layout = ({ children, className, monoColumn, ...rest }) => {
7
+ export const Layout = ({
8
+ children,
9
+ className,
10
+ monoColumn,
11
+ withTopBar,
12
+ ...rest
13
+ }) => {
8
14
  return (
9
15
  <div
10
16
  className={cx(
11
17
  monoColumn ? styles['o-layout'] : styles['o-layout-2panes'],
12
18
  className,
13
- [styles['o-layout--rounded']]
19
+ {
20
+ [styles[`o-layout${monoColumn ? '' : '-2panes'}--withTopBar`]]:
21
+ withTopBar
22
+ }
14
23
  )}
15
24
  {...rest}
16
25
  >
@@ -35,9 +44,13 @@ export class Content extends Component {
35
44
  Layout.propTypes = {
36
45
  children: PropTypes.node,
37
46
  className: PropTypes.string,
47
+ /** Used to add/remove top spacing when using with or without a topbar */
48
+ withTopBar: PropTypes.bool,
49
+ /** Should be true if no sidebar in the app */
38
50
  monoColumn: PropTypes.bool
39
51
  }
40
52
 
41
53
  Layout.defaultProps = {
54
+ withTopBar: true,
42
55
  monoColumn: false
43
56
  }
@@ -34,6 +34,7 @@ import CheckIcon from 'cozy-ui/transpiled/react/Icons/Check'
34
34
  import DownloadIcon from 'cozy-ui/transpiled/react/Icons/Download'
35
35
  import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
36
36
  import { makeStyles } from 'cozy-ui/transpiled/react/styles'
37
+ import Variants from 'cozy-ui/docs/components/Variants'
37
38
 
38
39
  /**
39
40
  * In a normal app, ExampleRouterNavLink is from react-router
@@ -50,13 +51,6 @@ const ExampleRouterNavLink = ({ children, className, active, activeClassName, on
50
51
  const NavLink = genNavLink(ExampleRouterNavLink)
51
52
 
52
53
  // Not necessary in a normal app
53
- const styles = {
54
- layout: {
55
- position: 'relative',
56
- transform: 'translateZ(0)'
57
- }
58
- }
59
-
60
54
  const useStyles = makeStyles({
61
55
  layout: {
62
56
  position: 'relative',
@@ -67,12 +61,13 @@ const useStyles = makeStyles({
67
61
  }
68
62
  })
69
63
 
70
- ;
64
+ const initialVariants = [{ monoColumn: false, withTopBar: true }]
65
+ const [active, setActive] = useState(['Section 1', 'Subsection 1'])
66
+ const styles = useStyles()
71
67
 
72
- const Example = () => {
73
- const [active, setActive] = useState(['Section 1', 'Subsection 1'])
74
- const styles = useStyles()
68
+ ;
75
69
 
70
+ const SideBar = ({ variant }) => {
76
71
  // makeProps is not necessary in a normal app since react-router sets active
77
72
  // and onClick by itself
78
73
  const makeProps = route => {
@@ -80,7 +75,7 @@ const Example = () => {
80
75
  return { onClick: () => setActive(route), active: routeIsMatching }
81
76
  }
82
77
 
83
- return <Layout className={styles.layout}>
78
+ return (
84
79
  <Sidebar>
85
80
  <Nav>
86
81
  <NavItem>
@@ -114,53 +109,27 @@ const Example = () => {
114
109
  </NavItem>
115
110
  </Nav>
116
111
  </Sidebar>
117
- <Main>
118
- <Content className='u-p-1'>
119
- <h2 className='u-mt-0'>{ active.join(' / ') }</h2>
120
- { content.ada.short }
121
- </Content>
122
- </Main>
123
- </Layout>
112
+ )
124
113
  }
125
114
 
126
- <DemoProvider>
127
- <Example />
128
- </DemoProvider>
129
- ```
130
-
131
- `monoColumn` option (without sidebar)
132
-
133
- ```jsx
134
- import { Layout, Main, Content } from 'cozy-ui/transpiled/react/Layout'
135
- import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
136
- import { makeStyles } from 'cozy-ui/transpiled/react/styles'
137
-
138
- // Not necessary in a normal app
139
- const useStyles = makeStyles({
140
- layout: {
141
- '& > main': {
142
- minHeight: 'unset'
143
- }
144
- }
145
- })
146
-
147
- const Example = () => {
148
- const styles = useStyles()
149
-
150
- return (
151
- <Layout className={styles.layout} monoColumn>
115
+ <Variants initialVariants={initialVariants} screenshotAllVariants>
116
+ {variant => (
117
+ <DemoProvider>
118
+ <Layout
119
+ className={styles.layout}
120
+ withTopBar={variant.withTopBar}
121
+ monoColumn={variant.monoColumn}
122
+ >
123
+ {!variant.monoColumn && <SideBar variant={variant} />}
124
+ {variant.withTopBar && <div className="u-flex-m u-dn u-flex-items-center u-pos-absolute u-top-0 u-w-100" style={{ height: '48px', backgroundColor: 'var(--defaultBackgroundColor)' }}>Fake TopBar</div>}
152
125
  <Main>
153
126
  <Content className='u-p-1'>
127
+ <h2 className='u-mt-0'>{ active.join(' / ') }</h2>
154
128
  { content.ada.short }
155
129
  </Content>
156
130
  </Main>
157
- </Layout>
158
- )
159
- }
160
-
161
- ;
162
-
163
- <DemoProvider>
164
- <Example />
165
- </DemoProvider>
131
+ </Layout>
132
+ </DemoProvider>
133
+ )}
134
+ </Variants>
166
135
  ```
@@ -3,5 +3,11 @@
3
3
  .o-layout
4
4
  @extend $app
5
5
 
6
+ .o-layout--withTopBar
7
+ @extend $app--withTopBar
8
+
6
9
  .o-layout-2panes
7
10
  @extend $app-2panes-sticky
11
+
12
+ .o-layout-2panes--withTopBar
13
+ @extend $app-2panes--withTopBar
@@ -77,16 +77,6 @@ $app
77
77
  overflow-x hidden
78
78
  overflow-y auto
79
79
 
80
- &--rounded
81
- +medium-screen('min') // desktop only
82
- main
83
- background-color var(--defaultBackgroundColor)
84
-
85
- & > [role=main]
86
- margin 1rem 1rem 1rem 0
87
- border-radius 1rem
88
- background-color var(--paperBackgroundColor)
89
-
90
80
  +medium-screen() // mobile + tablet
91
81
  display block
92
82
 
@@ -95,7 +85,7 @@ $app
95
85
  padding-left env(safe-area-inset-left)
96
86
  padding-right env(safe-area-inset-right)
97
87
  padding-bottom env(safe-area-inset-bottom)
98
- min-height 'calc(100vh - var(--sidebarHeight) - %s)' % barHeight
88
+ min-height 100vh
99
89
 
100
90
  main,
101
91
  main > [role=contentinfo], // Deprecated
@@ -103,18 +93,17 @@ $app
103
93
  display block
104
94
  overflow visible
105
95
 
106
- // These pseudo-element are "ghost" elements replacing bar and nav
96
+ $app--withTopBar
97
+ +medium-screen() // mobile + tablet
98
+ main
99
+ min-height 'calc(100vh - %s)' % barHeight
100
+
101
+ // this pseudo-element is "ghost" element replacing bar
107
102
  &:before
108
- &:after
109
103
  content ''
110
104
  display block
111
-
112
- &:before
113
105
  height barHeight
114
106
 
115
- &:after
116
- height navHeight
117
-
118
107
  // STICKY layout
119
108
  // When you want a sidebar and you want it to act like a sticky footer on mobile
120
109
  $app-2panes-sticky
@@ -132,7 +121,26 @@ $app-2panes-sticky
132
121
  main > [role=main]
133
122
  height auto
134
123
 
124
+ // rounded effect
125
+ +medium-screen('min') // desktop only
126
+ main
127
+ background-color var(--defaultBackgroundColor)
128
+
129
+ & > [role=main]
130
+ margin 1rem 1rem 1rem 0
131
+ border-radius 1rem
132
+ background-color var(--paperBackgroundColor)
133
+
135
134
  +medium-screen() // mobile + tablet
135
+ main
136
+ min-height calc(100vh - var(--sidebarHeight))
137
+
138
+ // this pseudo-element is "ghost" element replacing nav
139
+ &:after
140
+ content ''
141
+ display block
142
+ height navHeight
143
+
136
144
  > aside
137
145
  position fixed
138
146
  bottom 0
@@ -140,3 +148,14 @@ $app-2panes-sticky
140
148
  display block
141
149
  z-index var(--zIndex-nav)
142
150
  width 100%
151
+
152
+ $app-2panes--withTopBar
153
+ +medium-screen() // mobile + tablet
154
+ main
155
+ min-height 'calc(100vh - var(--sidebarHeight) - %s)' % barHeight
156
+
157
+ // this pseudo-element is "ghost" element replacing bar
158
+ &:before
159
+ content ''
160
+ display block
161
+ height barHeight
@@ -1,16 +1,20 @@
1
- export function Layout({ children, className, monoColumn, ...rest }: {
1
+ export function Layout({ children, className, monoColumn, withTopBar, ...rest }: {
2
2
  [x: string]: any;
3
3
  children: any;
4
4
  className: any;
5
5
  monoColumn: any;
6
+ withTopBar: any;
6
7
  }): JSX.Element;
7
8
  export namespace Layout {
8
9
  namespace propTypes {
9
10
  const children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
10
11
  const className: PropTypes.Requireable<string>;
12
+ const withTopBar: PropTypes.Requireable<boolean>;
11
13
  const monoColumn: PropTypes.Requireable<boolean>;
12
14
  }
13
15
  namespace defaultProps {
16
+ const withTopBar_1: boolean;
17
+ export { withTopBar_1 as withTopBar };
14
18
  const monoColumn_1: boolean;
15
19
  export { monoColumn_1 as monoColumn };
16
20
  }
@@ -4,8 +4,9 @@ import _inherits from "@babel/runtime/helpers/inherits";
4
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
6
  import _extends from "@babel/runtime/helpers/extends";
7
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
8
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
8
- var _excluded = ["children", "className", "monoColumn"],
9
+ var _excluded = ["children", "className", "monoColumn", "withTopBar"],
9
10
  _excluded2 = ["children"],
10
11
  _excluded3 = ["children"];
11
12
 
@@ -19,17 +20,18 @@ import React, { Component } from 'react';
19
20
  var styles = {
20
21
  "o-layout": "styles__o-layout___3TSz9",
21
22
  "o-layout-2panes": "styles__o-layout-2panes___1CDQw",
22
- "o-layout--rounded": "styles__o-layout--rounded___1WX4D",
23
- "o-layout-2panes--rounded": "styles__o-layout-2panes--rounded___1FuZT"
23
+ "o-layout--withTopBar": "styles__o-layout--withTopBar___36qd5",
24
+ "o-layout-2panes--withTopBar": "styles__o-layout-2panes--withTopBar___Ub1z2"
24
25
  };
25
26
  export var Layout = function Layout(_ref) {
26
27
  var children = _ref.children,
27
28
  className = _ref.className,
28
29
  monoColumn = _ref.monoColumn,
30
+ withTopBar = _ref.withTopBar,
29
31
  rest = _objectWithoutProperties(_ref, _excluded);
30
32
 
31
33
  return /*#__PURE__*/React.createElement("div", _extends({
32
- className: cx(monoColumn ? styles['o-layout'] : styles['o-layout-2panes'], className, [styles['o-layout--rounded']])
34
+ className: cx(monoColumn ? styles['o-layout'] : styles['o-layout-2panes'], className, _defineProperty({}, styles["o-layout".concat(monoColumn ? '' : '-2panes', "--withTopBar")], withTopBar))
33
35
  }, rest), children);
34
36
  };
35
37
  export var Main = function Main(_ref2) {
@@ -67,8 +69,14 @@ export var Content = /*#__PURE__*/function (_Component) {
67
69
  Layout.propTypes = {
68
70
  children: PropTypes.node,
69
71
  className: PropTypes.string,
72
+
73
+ /** Used to add/remove top spacing when using with or without a topbar */
74
+ withTopBar: PropTypes.bool,
75
+
76
+ /** Should be true if no sidebar in the app */
70
77
  monoColumn: PropTypes.bool
71
78
  };
72
79
  Layout.defaultProps = {
80
+ withTopBar: true,
73
81
  monoColumn: false
74
82
  };