@toptal/picasso-section 2.0.8-alpha-fx-4618-migrate-section-bdcbfe499.7 → 2.0.8
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/dist-package/src/Section/Section.d.ts.map +1 -1
- package/dist-package/src/Section/Section.js +18 -31
- package/dist-package/src/Section/Section.js.map +1 -1
- package/dist-package/src/Section/styles.d.ts +4 -0
- package/dist-package/src/Section/styles.d.ts.map +1 -0
- package/dist-package/src/Section/styles.js +64 -0
- package/dist-package/src/Section/styles.js.map +1 -0
- package/package.json +11 -12
- package/src/Section/Section.tsx +24 -42
- package/src/Section/__snapshots__/test.tsx.snap +40 -25
- package/src/Section/styles.ts +77 -0
- package/LICENSE +0 -20
|
@@ -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":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAA+B,MAAM,OAAO,CAAA;AAInD,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;AAMD,eAAO,MAAM,OAAO,8EAiHlB,CAAA;AASF,eAAe,OAAO,CAAA"}
|
|
@@ -9,41 +9,22 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
+
import cx from 'classnames';
|
|
12
13
|
import React, { forwardRef, useState } from 'react';
|
|
14
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
15
|
+
import { Collapse } from '@material-ui/core';
|
|
13
16
|
import { ButtonCircular } from '@toptal/picasso-button';
|
|
14
17
|
import { Container } from '@toptal/picasso-container';
|
|
15
18
|
import { Typography } from '@toptal/picasso-typography';
|
|
16
19
|
import { isString, Rotate180 } from '@toptal/picasso-utils';
|
|
17
20
|
import { ArrowDownMinor16 } from '@toptal/picasso-icons';
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
};
|
|
21
|
+
import styles from './styles';
|
|
22
|
+
const useStyles = makeStyles(styles, {
|
|
23
|
+
name: 'PicassoSection',
|
|
24
|
+
});
|
|
45
25
|
export const Section = forwardRef(function Section(props, ref) {
|
|
46
26
|
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();
|
|
47
28
|
const [collapsed, setCollapsed] = useState(collapsible ? defaultCollapsed : false);
|
|
48
29
|
const toggleCollapse = () => setCollapsed(!collapsed);
|
|
49
30
|
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;
|
|
@@ -51,17 +32,23 @@ export const Section = forwardRef(function Section(props, ref) {
|
|
|
51
32
|
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 },
|
|
52
33
|
React.createElement(ArrowDownMinor16, null)) })) : null;
|
|
53
34
|
const hasActions = actions || collapsible;
|
|
54
|
-
const renderActions = () => hasActions ? (React.createElement(Container, { "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.actions,
|
|
35
|
+
const renderActions = () => hasActions ? (React.createElement(Container, { "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.actions, className: classes.actions },
|
|
55
36
|
actions,
|
|
56
37
|
renderCollapse())) : null;
|
|
57
38
|
const hasHeader = title || subtitle || hasActions;
|
|
58
|
-
return (React.createElement(Container, Object.assign({ ref: ref,
|
|
59
|
-
|
|
39
|
+
return (React.createElement(Container, Object.assign({ ref: ref, className: cx({
|
|
40
|
+
[classes[variant]]: true,
|
|
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
|
+
}) },
|
|
60
47
|
renderTitle(),
|
|
61
48
|
renderSubtitle(),
|
|
62
49
|
renderActions())),
|
|
63
50
|
React.createElement(Collapse, { in: !collapsed, unmountOnExit: true },
|
|
64
|
-
React.createElement(Container, { className:
|
|
51
|
+
React.createElement(Container, { className: classes[`${variant}SectionContent`] }, children))));
|
|
65
52
|
});
|
|
66
53
|
Section.displayName = 'Section';
|
|
67
54
|
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":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0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GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CACX;YACE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI;YACxB,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,SAAS,IAAI,SAAS;SACxD,EACD,OAAO,CAAC,IAAI,EACZ,SAAS,CACV,EACD,OAAO,EACL,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAEvE,KAAK,EAAE,KAAK,IACR,IAAI;QAEP,SAAS,IAAI,CACZ,oBAAC,SAAS,mBACK,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,EAC5B,SAAS,EAAE,EAAE,CAAC;gBACZ,CAAC,OAAO,CAAC,GAAG,OAAO,QAAQ,CAAC,CAAC,EAAE,IAAI;gBACnC,CAAC,OAAO,CAAC,GAAG,OAAO,iBAAiB,CAAC,CAAC,EAAE,SAAS;aAClD,CAAC;YAED,WAAW,EAAE;YACb,cAAc,EAAE;YAChB,aAAa,EAAE,CACN,CACb;QACD,oBAAC,QAAQ,IAAC,EAAE,EAAE,CAAC,SAAS,EAAE,aAAa;YACrC,oBAAC,SAAS,IAAC,SAAS,EAAE,OAAO,CAAC,GAAG,OAAO,gBAAgB,CAAC,IACtD,QAAQ,CACC,CACH,CACD,CACb,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,WAAW,GAAG,SAAS,CAAA;AAC/B,OAAO,CAAC,YAAY,GAAG;IACrB,WAAW,EAAE,KAAK;IAClB,gBAAgB,EAAE,IAAI;IACtB,SAAS,EAAE,QAAQ;CACpB,CAAA;AAED,eAAe,OAAO,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;I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,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toptal/picasso-section",
|
|
3
|
-
"version": "2.0.8
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "Toptal UI components library - Section",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,32 +22,31 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso#readme",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@toptal/picasso-button": "2.0.2
|
|
26
|
-
"@toptal/picasso-
|
|
27
|
-
"@toptal/picasso-
|
|
28
|
-
"@toptal/picasso-
|
|
29
|
-
"@toptal/picasso-
|
|
30
|
-
"
|
|
31
|
-
"tailwind-merge": "^2.2.2"
|
|
25
|
+
"@toptal/picasso-button": "2.0.2",
|
|
26
|
+
"@toptal/picasso-container": "1.0.3",
|
|
27
|
+
"@toptal/picasso-icons": "1.1.1",
|
|
28
|
+
"@toptal/picasso-typography": "2.0.1",
|
|
29
|
+
"@toptal/picasso-utils": "1.0.3",
|
|
30
|
+
"classnames": "^2.5.1"
|
|
32
31
|
},
|
|
33
32
|
"sideEffects": [
|
|
34
33
|
"**/styles.ts",
|
|
35
34
|
"**/styles.js"
|
|
36
35
|
],
|
|
37
36
|
"peerDependencies": {
|
|
38
|
-
"@
|
|
37
|
+
"@material-ui/core": "4.12.4",
|
|
38
|
+
"tailwindcss": ">=3",
|
|
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.1"
|
|
46
46
|
},
|
|
47
47
|
"files": [
|
|
48
48
|
"dist-package/**",
|
|
49
49
|
"!dist-package/tsconfig.tsbuildinfo",
|
|
50
50
|
"src"
|
|
51
|
-
]
|
|
52
|
-
"gitHead": "bdcbfe4990a9041d6effc060e31f96d3d21e346f"
|
|
51
|
+
]
|
|
53
52
|
}
|
package/src/Section/Section.tsx
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
import cx from 'classnames'
|
|
1
2
|
import type { ReactNode } from 'react'
|
|
2
3
|
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'
|
|
3
7
|
import type { SizeType, BaseProps } from '@toptal/picasso-shared'
|
|
4
8
|
import { ButtonCircular } from '@toptal/picasso-button'
|
|
5
9
|
import { Container } from '@toptal/picasso-container'
|
|
6
10
|
import { Typography } from '@toptal/picasso-typography'
|
|
7
11
|
import { isString, Rotate180 } from '@toptal/picasso-utils'
|
|
8
12
|
import { ArrowDownMinor16 } from '@toptal/picasso-icons'
|
|
9
|
-
|
|
10
|
-
import
|
|
13
|
+
|
|
14
|
+
import styles from './styles'
|
|
11
15
|
|
|
12
16
|
type VariantType = 'bordered' | 'default' | 'withHeaderBar'
|
|
13
17
|
|
|
@@ -36,33 +40,9 @@ export interface Props extends BaseProps {
|
|
|
36
40
|
titleSize?: SizeType<'small' | 'medium'>
|
|
37
41
|
}
|
|
38
42
|
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
}
|
|
43
|
+
const useStyles = makeStyles<Theme>(styles, {
|
|
44
|
+
name: 'PicassoSection',
|
|
45
|
+
})
|
|
66
46
|
|
|
67
47
|
export const Section = forwardRef<HTMLDivElement, Props>(function Section(
|
|
68
48
|
props,
|
|
@@ -82,7 +62,7 @@ export const Section = forwardRef<HTMLDivElement, Props>(function Section(
|
|
|
82
62
|
titleSize = 'medium',
|
|
83
63
|
...rest
|
|
84
64
|
} = props
|
|
85
|
-
|
|
65
|
+
const classes = useStyles()
|
|
86
66
|
const [collapsed, setCollapsed] = useState(
|
|
87
67
|
collapsible ? defaultCollapsed : false
|
|
88
68
|
)
|
|
@@ -132,7 +112,7 @@ export const Section = forwardRef<HTMLDivElement, Props>(function Section(
|
|
|
132
112
|
const hasActions = actions || collapsible
|
|
133
113
|
const renderActions = () =>
|
|
134
114
|
hasActions ? (
|
|
135
|
-
<Container data-testid={testIds?.actions}
|
|
115
|
+
<Container data-testid={testIds?.actions} className={classes.actions}>
|
|
136
116
|
{actions}
|
|
137
117
|
{renderCollapse()}
|
|
138
118
|
</Container>
|
|
@@ -143,25 +123,27 @@ export const Section = forwardRef<HTMLDivElement, Props>(function Section(
|
|
|
143
123
|
return (
|
|
144
124
|
<Container
|
|
145
125
|
ref={ref}
|
|
126
|
+
className={cx(
|
|
127
|
+
{
|
|
128
|
+
[classes[variant]]: true,
|
|
129
|
+
[classes.collapsed]: variant === 'default' && collapsed,
|
|
130
|
+
},
|
|
131
|
+
classes.root,
|
|
132
|
+
className
|
|
133
|
+
)}
|
|
146
134
|
variant={
|
|
147
135
|
['bordered', 'withHeaderBar'].includes(variant) ? 'white' : undefined
|
|
148
136
|
}
|
|
149
137
|
style={style}
|
|
150
138
|
{...rest}
|
|
151
|
-
className={twMerge(
|
|
152
|
-
'pt-8',
|
|
153
|
-
variantMapping[variant],
|
|
154
|
-
variant === 'default' && collapsed && 'pb-8',
|
|
155
|
-
className
|
|
156
|
-
)}
|
|
157
139
|
>
|
|
158
140
|
{hasHeader && (
|
|
159
141
|
<Container
|
|
160
142
|
data-testid={testIds?.header}
|
|
161
|
-
className={
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
)}
|
|
143
|
+
className={cx({
|
|
144
|
+
[classes[`${variant}Header`]]: true,
|
|
145
|
+
[classes[`${variant}CollapsedHeader`]]: collapsed,
|
|
146
|
+
})}
|
|
165
147
|
>
|
|
166
148
|
{renderTitle()}
|
|
167
149
|
{renderSubtitle()}
|
|
@@ -169,7 +151,7 @@ export const Section = forwardRef<HTMLDivElement, Props>(function Section(
|
|
|
169
151
|
</Container>
|
|
170
152
|
)}
|
|
171
153
|
<Collapse in={!collapsed} unmountOnExit>
|
|
172
|
-
<Container className={
|
|
154
|
+
<Container className={classes[`${variant}SectionContent`]}>
|
|
173
155
|
{children}
|
|
174
156
|
</Container>
|
|
175
157
|
</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="PicassoSection-default PicassoSection-collapsed PicassoSection-root"
|
|
10
10
|
>
|
|
11
11
|
<div
|
|
12
|
-
class="
|
|
12
|
+
class="PicassoSection-defaultHeader PicassoSection-defaultCollapsedHeader"
|
|
13
13
|
data-testid="header"
|
|
14
14
|
>
|
|
15
15
|
<div
|
|
16
|
-
class="
|
|
16
|
+
class="PicassoSection-actions"
|
|
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="PicassoSection-default PicassoSection-root"
|
|
56
56
|
>
|
|
57
57
|
<div
|
|
58
|
-
class="
|
|
58
|
+
class="PicassoSection-defaultHeader"
|
|
59
59
|
data-testid="header"
|
|
60
60
|
>
|
|
61
61
|
<div
|
|
62
|
-
class="
|
|
62
|
+
class="PicassoSection-actions"
|
|
63
63
|
data-testid="actions"
|
|
64
64
|
>
|
|
65
65
|
<button
|
|
@@ -88,17 +88,22 @@ exports[`Section renders collapsible initially expanded 1`] = `
|
|
|
88
88
|
</div>
|
|
89
89
|
</div>
|
|
90
90
|
<div
|
|
91
|
-
class="
|
|
91
|
+
class="MuiCollapse-root MuiCollapse-entered"
|
|
92
|
+
style="min-height: 0px;"
|
|
92
93
|
>
|
|
93
94
|
<div
|
|
94
|
-
class="
|
|
95
|
+
class="MuiCollapse-wrapper"
|
|
95
96
|
>
|
|
96
97
|
<div
|
|
97
|
-
class=""
|
|
98
|
+
class="MuiCollapse-wrapperInner"
|
|
98
99
|
>
|
|
99
100
|
<div
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
class="PicassoSection-defaultSectionContent"
|
|
102
|
+
>
|
|
103
|
+
<div
|
|
104
|
+
data-testid="content"
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
102
107
|
</div>
|
|
103
108
|
</div>
|
|
104
109
|
</div>
|
|
@@ -113,10 +118,10 @@ exports[`Section renders with title, subtitle, actions and content 1`] = `
|
|
|
113
118
|
class="Picasso-root"
|
|
114
119
|
>
|
|
115
120
|
<div
|
|
116
|
-
class="
|
|
121
|
+
class="PicassoSection-default PicassoSection-root"
|
|
117
122
|
>
|
|
118
123
|
<div
|
|
119
|
-
class="
|
|
124
|
+
class="PicassoSection-defaultHeader"
|
|
120
125
|
data-testid="header"
|
|
121
126
|
>
|
|
122
127
|
<h3
|
|
@@ -132,24 +137,29 @@ exports[`Section renders with title, subtitle, actions and content 1`] = `
|
|
|
132
137
|
Subtitle
|
|
133
138
|
</p>
|
|
134
139
|
<div
|
|
135
|
-
class="
|
|
140
|
+
class="PicassoSection-actions"
|
|
136
141
|
data-testid="actions"
|
|
137
142
|
>
|
|
138
143
|
Actions
|
|
139
144
|
</div>
|
|
140
145
|
</div>
|
|
141
146
|
<div
|
|
142
|
-
class="
|
|
147
|
+
class="MuiCollapse-root MuiCollapse-entered"
|
|
148
|
+
style="min-height: 0px;"
|
|
143
149
|
>
|
|
144
150
|
<div
|
|
145
|
-
class="
|
|
151
|
+
class="MuiCollapse-wrapper"
|
|
146
152
|
>
|
|
147
153
|
<div
|
|
148
|
-
class=""
|
|
154
|
+
class="MuiCollapse-wrapperInner"
|
|
149
155
|
>
|
|
150
156
|
<div
|
|
151
|
-
|
|
152
|
-
|
|
157
|
+
class="PicassoSection-defaultSectionContent"
|
|
158
|
+
>
|
|
159
|
+
<div
|
|
160
|
+
data-testid="content"
|
|
161
|
+
/>
|
|
162
|
+
</div>
|
|
153
163
|
</div>
|
|
154
164
|
</div>
|
|
155
165
|
</div>
|
|
@@ -164,20 +174,25 @@ exports[`Section renders without header 1`] = `
|
|
|
164
174
|
class="Picasso-root"
|
|
165
175
|
>
|
|
166
176
|
<div
|
|
167
|
-
class="
|
|
177
|
+
class="PicassoSection-default PicassoSection-root"
|
|
168
178
|
>
|
|
169
179
|
<div
|
|
170
|
-
class="
|
|
180
|
+
class="MuiCollapse-root MuiCollapse-entered"
|
|
181
|
+
style="min-height: 0px;"
|
|
171
182
|
>
|
|
172
183
|
<div
|
|
173
|
-
class="
|
|
184
|
+
class="MuiCollapse-wrapper"
|
|
174
185
|
>
|
|
175
186
|
<div
|
|
176
|
-
class=""
|
|
187
|
+
class="MuiCollapse-wrapperInner"
|
|
177
188
|
>
|
|
178
189
|
<div
|
|
179
|
-
|
|
180
|
-
|
|
190
|
+
class="PicassoSection-defaultSectionContent"
|
|
191
|
+
>
|
|
192
|
+
<div
|
|
193
|
+
data-testid="content"
|
|
194
|
+
/>
|
|
195
|
+
</div>
|
|
181
196
|
</div>
|
|
182
197
|
</div>
|
|
183
198
|
</div>
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
})
|
package/LICENSE
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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.
|