@toptal/picasso-section 2.0.7 → 2.0.8-alpha-fx-4618-migrate-section-bdcbfe499.7
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/LICENSE +20 -0
- package/dist-package/src/Section/Section.d.ts.map +1 -1
- package/dist-package/src/Section/Section.js +31 -18
- package/dist-package/src/Section/Section.js.map +1 -1
- package/package.json +12 -11
- package/src/Section/Section.tsx +42 -24
- package/src/Section/__snapshots__/test.tsx.snap +25 -40
- package/dist-package/src/Section/styles.d.ts +0 -4
- package/dist-package/src/Section/styles.d.ts.map +0 -1
- package/dist-package/src/Section/styles.js +0 -64
- package/dist-package/src/Section/styles.js.map +0 -1
- package/src/Section/styles.ts +0 -77
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-2022 Toptal, LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the “Software”), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Section.d.ts","sourceRoot":"","sources":["../../../src/Section/Section.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Section.d.ts","sourceRoot":"","sources":["../../../src/Section/Section.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAA+B,MAAM,OAAO,CAAA;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AASjE,aAAK,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,eAAe,CAAA;AAE3D,MAAM,WAAW,KAAM,SAAQ,SAAS;IACtC,2BAA2B;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,wCAAwC;IACxC,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,uCAAuC;IACvC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,OAAO,CAAC,EAAE;QACR,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,mCAAmC;IACnC,SAAS,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAA;CACzC;AA8BD,eAAO,MAAM,OAAO,8EA+GlB,CAAA;AASF,eAAe,OAAO,CAAA"}
|
|
@@ -9,22 +9,41 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import cx from 'classnames';
|
|
13
12
|
import React, { forwardRef, useState } from 'react';
|
|
14
|
-
import { makeStyles } from '@material-ui/core/styles';
|
|
15
|
-
import { Collapse } from '@material-ui/core';
|
|
16
13
|
import { ButtonCircular } from '@toptal/picasso-button';
|
|
17
14
|
import { Container } from '@toptal/picasso-container';
|
|
18
15
|
import { Typography } from '@toptal/picasso-typography';
|
|
19
16
|
import { isString, Rotate180 } from '@toptal/picasso-utils';
|
|
20
17
|
import { ArrowDownMinor16 } from '@toptal/picasso-icons';
|
|
21
|
-
import
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
import { twMerge } from 'tailwind-merge';
|
|
19
|
+
import { Collapse } from '@toptal/picasso-collapse';
|
|
20
|
+
const variantMapping = {
|
|
21
|
+
default: '[&>_:last-child:not(:first-child)]:mt-6',
|
|
22
|
+
bordered: [
|
|
23
|
+
'[&>_:last-child:not(:first-child)]:mt-6',
|
|
24
|
+
'border rounded-md border-solid border-gray-300',
|
|
25
|
+
'p-8 [&_>_:last-child]:pb-0',
|
|
26
|
+
],
|
|
27
|
+
withHeaderBar: 'p-0 rounded-md border border-solid border-gray-400',
|
|
28
|
+
};
|
|
29
|
+
const headerMapping = {
|
|
30
|
+
default: 'flex',
|
|
31
|
+
bordered: 'flex',
|
|
32
|
+
withHeaderBar: [
|
|
33
|
+
'flex',
|
|
34
|
+
'pt-3 pb-3 pl-4 pr-4',
|
|
35
|
+
'rounded-tl-md rounded-tr-md rounded-br-0 rounded-bl-0',
|
|
36
|
+
'border-solid border-l-0 border-r-0 border-t-0 border-b border-gray-400',
|
|
37
|
+
'bg-gray-100',
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
const collapsedHeaderMapping = {
|
|
41
|
+
default: 'pb-0',
|
|
42
|
+
bordered: 'pb-0',
|
|
43
|
+
withHeaderBar: ['border-b-0 rounded-md', 'transition delay-300'],
|
|
44
|
+
};
|
|
25
45
|
export const Section = forwardRef(function Section(props, ref) {
|
|
26
46
|
const { className, style, title, subtitle, actions, children, testIds, collapsible = false, defaultCollapsed = true, variant = 'default', titleSize = 'medium' } = props, rest = __rest(props, ["className", "style", "title", "subtitle", "actions", "children", "testIds", "collapsible", "defaultCollapsed", "variant", "titleSize"]);
|
|
27
|
-
const classes = useStyles();
|
|
28
47
|
const [collapsed, setCollapsed] = useState(collapsible ? defaultCollapsed : false);
|
|
29
48
|
const toggleCollapse = () => setCollapsed(!collapsed);
|
|
30
49
|
const renderTitle = () => title ? (React.createElement(Typography, { as: isString(title) ? undefined : 'div', className: '!mr-4 min-w-0', "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.title, variant: 'heading', size: titleSize }, title)) : null;
|
|
@@ -32,23 +51,17 @@ export const Section = forwardRef(function Section(props, ref) {
|
|
|
32
51
|
const renderCollapse = () => collapsible ? (React.createElement(ButtonCircular, { onClick: toggleCollapse, "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.collapse, variant: 'flat', icon: React.createElement(Rotate180, { on: !collapsed },
|
|
33
52
|
React.createElement(ArrowDownMinor16, null)) })) : null;
|
|
34
53
|
const hasActions = actions || collapsible;
|
|
35
|
-
const renderActions = () => hasActions ? (React.createElement(Container, { "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.actions, className:
|
|
54
|
+
const renderActions = () => hasActions ? (React.createElement(Container, { "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.actions, flex: true, className: 'ml-auto' },
|
|
36
55
|
actions,
|
|
37
56
|
renderCollapse())) : null;
|
|
38
57
|
const hasHeader = title || subtitle || hasActions;
|
|
39
|
-
return (React.createElement(Container, Object.assign({ ref: ref, className:
|
|
40
|
-
|
|
41
|
-
[classes.collapsed]: variant === 'default' && collapsed,
|
|
42
|
-
}, classes.root, className), variant: ['bordered', 'withHeaderBar'].includes(variant) ? 'white' : undefined, style: style }, rest),
|
|
43
|
-
hasHeader && (React.createElement(Container, { "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.header, className: cx({
|
|
44
|
-
[classes[`${variant}Header`]]: true,
|
|
45
|
-
[classes[`${variant}CollapsedHeader`]]: collapsed,
|
|
46
|
-
}) },
|
|
58
|
+
return (React.createElement(Container, Object.assign({ ref: ref, variant: ['bordered', 'withHeaderBar'].includes(variant) ? 'white' : undefined, style: style }, rest, { className: twMerge('pt-8', variantMapping[variant], variant === 'default' && collapsed && 'pb-8', className) }),
|
|
59
|
+
hasHeader && (React.createElement(Container, { "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.header, className: twMerge(headerMapping[variant], collapsed && collapsedHeaderMapping[variant]) },
|
|
47
60
|
renderTitle(),
|
|
48
61
|
renderSubtitle(),
|
|
49
62
|
renderActions())),
|
|
50
63
|
React.createElement(Collapse, { in: !collapsed, unmountOnExit: true },
|
|
51
|
-
React.createElement(Container, { className:
|
|
64
|
+
React.createElement(Container, { className: twMerge(variant === 'withHeaderBar' && 'p-6') }, children))));
|
|
52
65
|
});
|
|
53
66
|
Section.displayName = 'Section';
|
|
54
67
|
Section.defaultProps = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Section.js","sourceRoot":"","sources":["../../../src/Section/Section.tsx"],"names":[],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Section.js","sourceRoot":"","sources":["../../../src/Section/Section.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4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asso-section",
|
|
3
|
-
"version": "2.0.7",
|
|
3
|
+
"version": "2.0.8-alpha-fx-4618-migrate-section-bdcbfe499.7+bdcbfe499",
|
|
4
4
|
"description": "Toptal UI components library - Section",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,31 +22,32 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso#readme",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@toptal/picasso-button": "2.0.
|
|
26
|
-
"@toptal/picasso-
|
|
27
|
-
"@toptal/picasso-
|
|
28
|
-
"@toptal/picasso-
|
|
29
|
-
"@toptal/picasso-
|
|
30
|
-
"
|
|
25
|
+
"@toptal/picasso-button": "2.0.2-alpha-fx-4618-migrate-section-bdcbfe499.7+bdcbfe499",
|
|
26
|
+
"@toptal/picasso-collapse": "1.0.3-alpha-fx-4618-migrate-section-bdcbfe499.9+bdcbfe499",
|
|
27
|
+
"@toptal/picasso-container": "1.0.4-alpha-fx-4618-migrate-section-bdcbfe499.9+bdcbfe499",
|
|
28
|
+
"@toptal/picasso-icons": "1.1.2-alpha-fx-4618-migrate-section-bdcbfe499.9+bdcbfe499",
|
|
29
|
+
"@toptal/picasso-typography": "2.0.2-alpha-fx-4618-migrate-section-bdcbfe499.9+bdcbfe499",
|
|
30
|
+
"@toptal/picasso-utils": "1.0.4-alpha-fx-4618-migrate-section-bdcbfe499.9+bdcbfe499",
|
|
31
|
+
"tailwind-merge": "^2.2.2"
|
|
31
32
|
},
|
|
32
33
|
"sideEffects": [
|
|
33
34
|
"**/styles.ts",
|
|
34
35
|
"**/styles.js"
|
|
35
36
|
],
|
|
36
37
|
"peerDependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"tailwindcss": ">=3",
|
|
38
|
+
"@toptal/picasso-tailwind": "^2.5.0",
|
|
39
39
|
"react": ">=16.12.0 < 19.0.0"
|
|
40
40
|
},
|
|
41
41
|
"exports": {
|
|
42
42
|
".": "./dist-package/src/index.js"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@toptal/picasso-test-utils": "1.1.
|
|
45
|
+
"@toptal/picasso-test-utils": "1.1.2-alpha-fx-4618-migrate-section-bdcbfe499.9+bdcbfe499"
|
|
46
46
|
},
|
|
47
47
|
"files": [
|
|
48
48
|
"dist-package/**",
|
|
49
49
|
"!dist-package/tsconfig.tsbuildinfo",
|
|
50
50
|
"src"
|
|
51
|
-
]
|
|
51
|
+
],
|
|
52
|
+
"gitHead": "bdcbfe4990a9041d6effc060e31f96d3d21e346f"
|
|
52
53
|
}
|
package/src/Section/Section.tsx
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import cx from 'classnames'
|
|
2
1
|
import type { ReactNode } from 'react'
|
|
3
2
|
import React, { forwardRef, useState } from 'react'
|
|
4
|
-
import type { Theme } from '@material-ui/core/styles'
|
|
5
|
-
import { makeStyles } from '@material-ui/core/styles'
|
|
6
|
-
import { Collapse } from '@material-ui/core'
|
|
7
3
|
import type { SizeType, BaseProps } from '@toptal/picasso-shared'
|
|
8
4
|
import { ButtonCircular } from '@toptal/picasso-button'
|
|
9
5
|
import { Container } from '@toptal/picasso-container'
|
|
10
6
|
import { Typography } from '@toptal/picasso-typography'
|
|
11
7
|
import { isString, Rotate180 } from '@toptal/picasso-utils'
|
|
12
8
|
import { ArrowDownMinor16 } from '@toptal/picasso-icons'
|
|
13
|
-
|
|
14
|
-
import
|
|
9
|
+
import { twMerge } from 'tailwind-merge'
|
|
10
|
+
import { Collapse } from '@toptal/picasso-collapse'
|
|
15
11
|
|
|
16
12
|
type VariantType = 'bordered' | 'default' | 'withHeaderBar'
|
|
17
13
|
|
|
@@ -40,9 +36,33 @@ export interface Props extends BaseProps {
|
|
|
40
36
|
titleSize?: SizeType<'small' | 'medium'>
|
|
41
37
|
}
|
|
42
38
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
const variantMapping: { [K in VariantType]: string | string[] } = {
|
|
40
|
+
default: '[&>_:last-child:not(:first-child)]:mt-6',
|
|
41
|
+
bordered: [
|
|
42
|
+
'[&>_:last-child:not(:first-child)]:mt-6',
|
|
43
|
+
'border rounded-md border-solid border-gray-300',
|
|
44
|
+
'p-8 [&_>_:last-child]:pb-0',
|
|
45
|
+
],
|
|
46
|
+
withHeaderBar: 'p-0 rounded-md border border-solid border-gray-400',
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const headerMapping: { [K in VariantType]: string | string[] } = {
|
|
50
|
+
default: 'flex',
|
|
51
|
+
bordered: 'flex',
|
|
52
|
+
withHeaderBar: [
|
|
53
|
+
'flex',
|
|
54
|
+
'pt-3 pb-3 pl-4 pr-4',
|
|
55
|
+
'rounded-tl-md rounded-tr-md rounded-br-0 rounded-bl-0',
|
|
56
|
+
'border-solid border-l-0 border-r-0 border-t-0 border-b border-gray-400',
|
|
57
|
+
'bg-gray-100',
|
|
58
|
+
],
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const collapsedHeaderMapping: { [K in VariantType]: string | string[] } = {
|
|
62
|
+
default: 'pb-0',
|
|
63
|
+
bordered: 'pb-0',
|
|
64
|
+
withHeaderBar: ['border-b-0 rounded-md', 'transition delay-300'],
|
|
65
|
+
}
|
|
46
66
|
|
|
47
67
|
export const Section = forwardRef<HTMLDivElement, Props>(function Section(
|
|
48
68
|
props,
|
|
@@ -62,7 +82,7 @@ export const Section = forwardRef<HTMLDivElement, Props>(function Section(
|
|
|
62
82
|
titleSize = 'medium',
|
|
63
83
|
...rest
|
|
64
84
|
} = props
|
|
65
|
-
|
|
85
|
+
|
|
66
86
|
const [collapsed, setCollapsed] = useState(
|
|
67
87
|
collapsible ? defaultCollapsed : false
|
|
68
88
|
)
|
|
@@ -112,7 +132,7 @@ export const Section = forwardRef<HTMLDivElement, Props>(function Section(
|
|
|
112
132
|
const hasActions = actions || collapsible
|
|
113
133
|
const renderActions = () =>
|
|
114
134
|
hasActions ? (
|
|
115
|
-
<Container data-testid={testIds?.actions} className=
|
|
135
|
+
<Container data-testid={testIds?.actions} flex className='ml-auto'>
|
|
116
136
|
{actions}
|
|
117
137
|
{renderCollapse()}
|
|
118
138
|
</Container>
|
|
@@ -123,27 +143,25 @@ export const Section = forwardRef<HTMLDivElement, Props>(function Section(
|
|
|
123
143
|
return (
|
|
124
144
|
<Container
|
|
125
145
|
ref={ref}
|
|
126
|
-
className={cx(
|
|
127
|
-
{
|
|
128
|
-
[classes[variant]]: true,
|
|
129
|
-
[classes.collapsed]: variant === 'default' && collapsed,
|
|
130
|
-
},
|
|
131
|
-
classes.root,
|
|
132
|
-
className
|
|
133
|
-
)}
|
|
134
146
|
variant={
|
|
135
147
|
['bordered', 'withHeaderBar'].includes(variant) ? 'white' : undefined
|
|
136
148
|
}
|
|
137
149
|
style={style}
|
|
138
150
|
{...rest}
|
|
151
|
+
className={twMerge(
|
|
152
|
+
'pt-8',
|
|
153
|
+
variantMapping[variant],
|
|
154
|
+
variant === 'default' && collapsed && 'pb-8',
|
|
155
|
+
className
|
|
156
|
+
)}
|
|
139
157
|
>
|
|
140
158
|
{hasHeader && (
|
|
141
159
|
<Container
|
|
142
160
|
data-testid={testIds?.header}
|
|
143
|
-
className={
|
|
144
|
-
[
|
|
145
|
-
[
|
|
146
|
-
|
|
161
|
+
className={twMerge(
|
|
162
|
+
headerMapping[variant],
|
|
163
|
+
collapsed && collapsedHeaderMapping[variant]
|
|
164
|
+
)}
|
|
147
165
|
>
|
|
148
166
|
{renderTitle()}
|
|
149
167
|
{renderSubtitle()}
|
|
@@ -151,7 +169,7 @@ export const Section = forwardRef<HTMLDivElement, Props>(function Section(
|
|
|
151
169
|
</Container>
|
|
152
170
|
)}
|
|
153
171
|
<Collapse in={!collapsed} unmountOnExit>
|
|
154
|
-
<Container className={
|
|
172
|
+
<Container className={twMerge(variant === 'withHeaderBar' && 'p-6')}>
|
|
155
173
|
{children}
|
|
156
174
|
</Container>
|
|
157
175
|
</Collapse>
|
|
@@ -6,14 +6,14 @@ exports[`Section renders collapsible initially collapsed 1`] = `
|
|
|
6
6
|
class="Picasso-root"
|
|
7
7
|
>
|
|
8
8
|
<div
|
|
9
|
-
class="
|
|
9
|
+
class="pt-8 [&>_:last-child:not(:first-child)]:mt-6 pb-8"
|
|
10
10
|
>
|
|
11
11
|
<div
|
|
12
|
-
class="
|
|
12
|
+
class="flex pb-0"
|
|
13
13
|
data-testid="header"
|
|
14
14
|
>
|
|
15
15
|
<div
|
|
16
|
-
class="
|
|
16
|
+
class="PicassoContainer-flex ml-auto"
|
|
17
17
|
data-testid="actions"
|
|
18
18
|
>
|
|
19
19
|
<button
|
|
@@ -52,14 +52,14 @@ exports[`Section renders collapsible initially expanded 1`] = `
|
|
|
52
52
|
class="Picasso-root"
|
|
53
53
|
>
|
|
54
54
|
<div
|
|
55
|
-
class="
|
|
55
|
+
class="pt-8 [&>_:last-child:not(:first-child)]:mt-6"
|
|
56
56
|
>
|
|
57
57
|
<div
|
|
58
|
-
class="
|
|
58
|
+
class="flex"
|
|
59
59
|
data-testid="header"
|
|
60
60
|
>
|
|
61
61
|
<div
|
|
62
|
-
class="
|
|
62
|
+
class="PicassoContainer-flex ml-auto"
|
|
63
63
|
data-testid="actions"
|
|
64
64
|
>
|
|
65
65
|
<button
|
|
@@ -88,22 +88,17 @@ exports[`Section renders collapsible initially expanded 1`] = `
|
|
|
88
88
|
</div>
|
|
89
89
|
</div>
|
|
90
90
|
<div
|
|
91
|
-
class="
|
|
92
|
-
style="min-height: 0px;"
|
|
91
|
+
class="flex"
|
|
93
92
|
>
|
|
94
93
|
<div
|
|
95
|
-
class="
|
|
94
|
+
class="w-full"
|
|
96
95
|
>
|
|
97
96
|
<div
|
|
98
|
-
class="
|
|
97
|
+
class=""
|
|
99
98
|
>
|
|
100
99
|
<div
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
<div
|
|
104
|
-
data-testid="content"
|
|
105
|
-
/>
|
|
106
|
-
</div>
|
|
100
|
+
data-testid="content"
|
|
101
|
+
/>
|
|
107
102
|
</div>
|
|
108
103
|
</div>
|
|
109
104
|
</div>
|
|
@@ -118,10 +113,10 @@ exports[`Section renders with title, subtitle, actions and content 1`] = `
|
|
|
118
113
|
class="Picasso-root"
|
|
119
114
|
>
|
|
120
115
|
<div
|
|
121
|
-
class="
|
|
116
|
+
class="pt-8 [&>_:last-child:not(:first-child)]:mt-6"
|
|
122
117
|
>
|
|
123
118
|
<div
|
|
124
|
-
class="
|
|
119
|
+
class="flex"
|
|
125
120
|
data-testid="header"
|
|
126
121
|
>
|
|
127
122
|
<h3
|
|
@@ -137,29 +132,24 @@ exports[`Section renders with title, subtitle, actions and content 1`] = `
|
|
|
137
132
|
Subtitle
|
|
138
133
|
</p>
|
|
139
134
|
<div
|
|
140
|
-
class="
|
|
135
|
+
class="PicassoContainer-flex ml-auto"
|
|
141
136
|
data-testid="actions"
|
|
142
137
|
>
|
|
143
138
|
Actions
|
|
144
139
|
</div>
|
|
145
140
|
</div>
|
|
146
141
|
<div
|
|
147
|
-
class="
|
|
148
|
-
style="min-height: 0px;"
|
|
142
|
+
class="flex"
|
|
149
143
|
>
|
|
150
144
|
<div
|
|
151
|
-
class="
|
|
145
|
+
class="w-full"
|
|
152
146
|
>
|
|
153
147
|
<div
|
|
154
|
-
class="
|
|
148
|
+
class=""
|
|
155
149
|
>
|
|
156
150
|
<div
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
<div
|
|
160
|
-
data-testid="content"
|
|
161
|
-
/>
|
|
162
|
-
</div>
|
|
151
|
+
data-testid="content"
|
|
152
|
+
/>
|
|
163
153
|
</div>
|
|
164
154
|
</div>
|
|
165
155
|
</div>
|
|
@@ -174,25 +164,20 @@ exports[`Section renders without header 1`] = `
|
|
|
174
164
|
class="Picasso-root"
|
|
175
165
|
>
|
|
176
166
|
<div
|
|
177
|
-
class="
|
|
167
|
+
class="pt-8 [&>_:last-child:not(:first-child)]:mt-6"
|
|
178
168
|
>
|
|
179
169
|
<div
|
|
180
|
-
class="
|
|
181
|
-
style="min-height: 0px;"
|
|
170
|
+
class="flex"
|
|
182
171
|
>
|
|
183
172
|
<div
|
|
184
|
-
class="
|
|
173
|
+
class="w-full"
|
|
185
174
|
>
|
|
186
175
|
<div
|
|
187
|
-
class="
|
|
176
|
+
class=""
|
|
188
177
|
>
|
|
189
178
|
<div
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
<div
|
|
193
|
-
data-testid="content"
|
|
194
|
-
/>
|
|
195
|
-
</div>
|
|
179
|
+
data-testid="content"
|
|
180
|
+
/>
|
|
196
181
|
</div>
|
|
197
182
|
</div>
|
|
198
183
|
</div>
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Theme } from '@material-ui/core';
|
|
2
|
-
declare const _default: ({ sizes, palette }: Theme) => import("@material-ui/styles").StyleRules<{}, "root" | "default" | "title" | "subtitle" | "actions" | "collapsed" | "bordered" | "withHeaderBar" | "defaultHeader" | "borderedHeader" | "withHeaderBarHeader" | "defaultCollapsedHeader" | "borderedCollapsedHeader" | "withHeaderBarCollapsedHeader" | "defaultSectionContent" | "borderedSectionContent" | "withHeaderBarSectionContent">;
|
|
3
|
-
export default _default;
|
|
4
|
-
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/Section/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;6CAiBV,KAAK;AAAzC,wBA2DI"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { createStyles } from '@material-ui/core';
|
|
2
|
-
const defaultHeader = {
|
|
3
|
-
display: 'flex',
|
|
4
|
-
};
|
|
5
|
-
const defaultCollapsedHeader = {
|
|
6
|
-
paddingBottom: '0',
|
|
7
|
-
};
|
|
8
|
-
const defaultSection = {
|
|
9
|
-
'& > :last-child:not(:first-child)': {
|
|
10
|
-
marginTop: '1.5rem',
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
export default ({ sizes, palette }) => createStyles({
|
|
14
|
-
root: {
|
|
15
|
-
paddingTop: '2rem',
|
|
16
|
-
},
|
|
17
|
-
title: {
|
|
18
|
-
marginRight: '1rem',
|
|
19
|
-
minWidth: 0,
|
|
20
|
-
},
|
|
21
|
-
subtitle: {
|
|
22
|
-
alignSelf: 'center',
|
|
23
|
-
marginRight: '1rem',
|
|
24
|
-
minWidth: 0,
|
|
25
|
-
},
|
|
26
|
-
actions: {
|
|
27
|
-
display: 'flex',
|
|
28
|
-
marginLeft: 'auto',
|
|
29
|
-
},
|
|
30
|
-
collapsed: {
|
|
31
|
-
paddingBottom: '2rem',
|
|
32
|
-
},
|
|
33
|
-
default: defaultSection,
|
|
34
|
-
bordered: Object.assign(Object.assign({}, defaultSection), { borderRadius: sizes.borderRadius.medium, border: `solid ${sizes.borderWidth} ${palette.grey.light}`, padding: '2rem', '& > :last-child': {
|
|
35
|
-
paddingBottom: '0',
|
|
36
|
-
} }),
|
|
37
|
-
withHeaderBar: {
|
|
38
|
-
padding: 0,
|
|
39
|
-
borderRadius: sizes.borderRadius.medium,
|
|
40
|
-
border: `solid ${sizes.borderWidth} ${palette.grey.light2}`,
|
|
41
|
-
},
|
|
42
|
-
defaultHeader,
|
|
43
|
-
borderedHeader: defaultHeader,
|
|
44
|
-
withHeaderBarHeader: {
|
|
45
|
-
display: 'flex',
|
|
46
|
-
padding: '0.75rem 1rem',
|
|
47
|
-
borderRadius: `${sizes.borderRadius.medium} ${sizes.borderRadius.medium} 0 0`,
|
|
48
|
-
borderBottom: `solid ${sizes.borderWidth} ${palette.grey.light2}`,
|
|
49
|
-
backgroundColor: palette.grey.lighter,
|
|
50
|
-
},
|
|
51
|
-
defaultCollapsedHeader,
|
|
52
|
-
borderedCollapsedHeader: defaultCollapsedHeader,
|
|
53
|
-
withHeaderBarCollapsedHeader: {
|
|
54
|
-
borderBottomWidth: '0px',
|
|
55
|
-
borderRadius: sizes.borderRadius.medium,
|
|
56
|
-
transitionDelay: '300ms',
|
|
57
|
-
},
|
|
58
|
-
defaultSectionContent: {},
|
|
59
|
-
borderedSectionContent: {},
|
|
60
|
-
withHeaderBarSectionContent: {
|
|
61
|
-
padding: '1.5rem',
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/Section/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,MAAM,aAAa,GAAG;IACpB,OAAO,EAAE,MAAM;CAChB,CAAA;AAED,MAAM,sBAAsB,GAAG;IAC7B,aAAa,EAAE,GAAG;CACnB,CAAA;AAED,MAAM,cAAc,GAAG;IACrB,mCAAmC,EAAE;QACnC,SAAS,EAAE,QAAQ;KACpB;CACF,CAAA;AAED,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,EAAS,EAAE,EAAE,CAC3C,YAAY,CAAC;IACX,IAAI,EAAE;QACJ,UAAU,EAAE,MAAM;KACnB;IACD,KAAK,EAAE;QACL,WAAW,EAAE,MAAM;QACnB,QAAQ,EAAE,CAAC;KACZ;IACD,QAAQ,EAAE;QACR,SAAS,EAAE,QAAQ;QACnB,WAAW,EAAE,MAAM;QACnB,QAAQ,EAAE,CAAC;KACZ;IACD,OAAO,EAAE;QACP,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,MAAM;KACnB;IAED,SAAS,EAAE;QACT,aAAa,EAAE,MAAM;KACtB;IACD,OAAO,EAAE,cAAc;IACvB,QAAQ,kCACH,cAAc,KACjB,YAAY,EAAE,KAAK,CAAC,YAAY,CAAC,MAAM,EACvC,MAAM,EAAE,SAAS,KAAK,CAAC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,EAC1D,OAAO,EAAE,MAAM,EACf,iBAAiB,EAAE;YACjB,aAAa,EAAE,GAAG;SACnB,GACF;IACD,aAAa,EAAE;QACb,OAAO,EAAE,CAAC;QACV,YAAY,EAAE,KAAK,CAAC,YAAY,CAAC,MAAM;QACvC,MAAM,EAAE,SAAS,KAAK,CAAC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE;KAC5D;IACD,aAAa;IACb,cAAc,EAAE,aAAa;IAC7B,mBAAmB,EAAE;QACnB,OAAO,EAAE,MAAM;QACf,OAAO,EAAE,cAAc;QACvB,YAAY,EAAE,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,MAAM;QAC7E,YAAY,EAAE,SAAS,KAAK,CAAC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE;QACjE,eAAe,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO;KACtC;IAED,sBAAsB;IACtB,uBAAuB,EAAE,sBAAsB;IAC/C,4BAA4B,EAAE;QAC5B,iBAAiB,EAAE,KAAK;QACxB,YAAY,EAAE,KAAK,CAAC,YAAY,CAAC,MAAM;QACvC,eAAe,EAAE,OAAO;KACzB;IACD,qBAAqB,EAAE,EAAE;IACzB,sBAAsB,EAAE,EAAE;IAC1B,2BAA2B,EAAE;QAC3B,OAAO,EAAE,QAAQ;KAClB;CACF,CAAC,CAAA"}
|
package/src/Section/styles.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { Theme } from '@material-ui/core'
|
|
2
|
-
import { createStyles } from '@material-ui/core'
|
|
3
|
-
|
|
4
|
-
const defaultHeader = {
|
|
5
|
-
display: 'flex',
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const defaultCollapsedHeader = {
|
|
9
|
-
paddingBottom: '0',
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const defaultSection = {
|
|
13
|
-
'& > :last-child:not(:first-child)': {
|
|
14
|
-
marginTop: '1.5rem',
|
|
15
|
-
},
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default ({ sizes, palette }: Theme) =>
|
|
19
|
-
createStyles({
|
|
20
|
-
root: {
|
|
21
|
-
paddingTop: '2rem',
|
|
22
|
-
},
|
|
23
|
-
title: {
|
|
24
|
-
marginRight: '1rem',
|
|
25
|
-
minWidth: 0,
|
|
26
|
-
},
|
|
27
|
-
subtitle: {
|
|
28
|
-
alignSelf: 'center',
|
|
29
|
-
marginRight: '1rem',
|
|
30
|
-
minWidth: 0,
|
|
31
|
-
},
|
|
32
|
-
actions: {
|
|
33
|
-
display: 'flex',
|
|
34
|
-
marginLeft: 'auto',
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
collapsed: {
|
|
38
|
-
paddingBottom: '2rem',
|
|
39
|
-
},
|
|
40
|
-
default: defaultSection,
|
|
41
|
-
bordered: {
|
|
42
|
-
...defaultSection,
|
|
43
|
-
borderRadius: sizes.borderRadius.medium,
|
|
44
|
-
border: `solid ${sizes.borderWidth} ${palette.grey.light}`,
|
|
45
|
-
padding: '2rem',
|
|
46
|
-
'& > :last-child': {
|
|
47
|
-
paddingBottom: '0',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
withHeaderBar: {
|
|
51
|
-
padding: 0,
|
|
52
|
-
borderRadius: sizes.borderRadius.medium,
|
|
53
|
-
border: `solid ${sizes.borderWidth} ${palette.grey.light2}`,
|
|
54
|
-
},
|
|
55
|
-
defaultHeader,
|
|
56
|
-
borderedHeader: defaultHeader,
|
|
57
|
-
withHeaderBarHeader: {
|
|
58
|
-
display: 'flex',
|
|
59
|
-
padding: '0.75rem 1rem',
|
|
60
|
-
borderRadius: `${sizes.borderRadius.medium} ${sizes.borderRadius.medium} 0 0`,
|
|
61
|
-
borderBottom: `solid ${sizes.borderWidth} ${palette.grey.light2}`,
|
|
62
|
-
backgroundColor: palette.grey.lighter,
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
defaultCollapsedHeader,
|
|
66
|
-
borderedCollapsedHeader: defaultCollapsedHeader,
|
|
67
|
-
withHeaderBarCollapsedHeader: {
|
|
68
|
-
borderBottomWidth: '0px',
|
|
69
|
-
borderRadius: sizes.borderRadius.medium,
|
|
70
|
-
transitionDelay: '300ms',
|
|
71
|
-
},
|
|
72
|
-
defaultSectionContent: {},
|
|
73
|
-
borderedSectionContent: {},
|
|
74
|
-
withHeaderBarSectionContent: {
|
|
75
|
-
padding: '1.5rem',
|
|
76
|
-
},
|
|
77
|
-
})
|