@toptal/picasso-container 3.1.3-alpha-MP-669-first-batch-of-rework-c1fb81067.24 → 3.1.3-alpha-MP-669-remove-default-props-dkjf3234-7db07b500.31
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/Container/Container.d.ts +2 -11
- package/dist-package/src/Container/Container.d.ts.map +1 -1
- package/dist-package/src/Container/Container.js +13 -14
- package/dist-package/src/Container/Container.js.map +1 -1
- package/dist-package/src/Container/constants.d.ts +5 -0
- package/dist-package/src/Container/constants.d.ts.map +1 -0
- package/dist-package/src/Container/constants.js +5 -0
- package/dist-package/src/Container/constants.js.map +1 -0
- package/package.json +5 -5
- package/src/Container/Container.tsx +101 -105
- package/src/Container/constants.ts +4 -0
- package/src/Container/story/index.jsx +4 -11
|
@@ -7,7 +7,6 @@ declare type ContainerType = 'div' | 'span';
|
|
|
7
7
|
declare type DirectionType = 'row' | 'column' | 'row-reverse' | 'column-reverse';
|
|
8
8
|
declare type WrapType = 'wrap' | 'nowrap' | 'wrap-reverse';
|
|
9
9
|
declare type BorderableType = 'transparent' | 'white';
|
|
10
|
-
declare type BorderedType<V extends VariantType> = V extends BorderableType ? boolean : never;
|
|
11
10
|
export interface Props<V extends VariantType = VariantType> extends StandardProps, HTMLAttributes<HTMLDivElement | HTMLSpanElement> {
|
|
12
11
|
/** Content of Container */
|
|
13
12
|
children?: ReactNode;
|
|
@@ -24,7 +23,7 @@ export interface Props<V extends VariantType = VariantType> extends StandardProp
|
|
|
24
23
|
/** Defines flex-wrap style property */
|
|
25
24
|
wrap?: WrapType;
|
|
26
25
|
/** Whether (`white`, `transparent`) container has border or not */
|
|
27
|
-
bordered?:
|
|
26
|
+
bordered?: V extends BorderableType ? boolean : never;
|
|
28
27
|
/** Whether container has 8px border-radius applied or not */
|
|
29
28
|
rounded?: boolean;
|
|
30
29
|
/** Style variant of Notification */
|
|
@@ -46,20 +45,12 @@ export interface Props<V extends VariantType = VariantType> extends StandardProp
|
|
|
46
45
|
/** Gap between elements for a flex container */
|
|
47
46
|
gap?: SpacingType;
|
|
48
47
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Separate component is needed for proper Storybook props display
|
|
51
|
-
*/
|
|
52
|
-
export declare const ContainerFunction: {
|
|
53
|
-
<V extends "transparent" | "red" | "green" | "white" | "yellow" | "blue" | "grey">({ as, inline, rounded, bordered, ref, ...props }: Props<V> & {
|
|
54
|
-
ref?: Ref<HTMLDivElement> | undefined;
|
|
55
|
-
}): JSX.Element;
|
|
56
|
-
displayName: string;
|
|
57
|
-
};
|
|
58
48
|
declare type ContainerProps = {
|
|
59
49
|
<V extends VariantType = VariantType>(props: Props<V> & {
|
|
60
50
|
ref?: Ref<HTMLDivElement> | null;
|
|
61
51
|
}): ReactElement;
|
|
62
52
|
displayName?: string;
|
|
53
|
+
defaultProps?: Partial<Props<VariantType>>;
|
|
63
54
|
};
|
|
64
55
|
/**
|
|
65
56
|
* Container component used for spacing 2 elements
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../../src/Container/Container.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAKzE,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAI/E,aAAK,aAAa,GAAG,KAAK,GAAG,MAAM,CAAA;AAEnC,aAAK,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,aAAa,GAAG,gBAAgB,CAAA;AAExE,aAAK,QAAQ,GAAG,MAAM,GAAG,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f,mEAAmE;IACnE,QAAQ,CAAC,EAAE,CAAC,SAAS,cAAc,GAAG,OAAO,GAAG,KAAK,CAAA;IACrD,6DAA6D;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,oCAAoC;IACpC,OAAO,CAAC,EAAE,CAAC,CAAA;IACX,uCAAuC;IACvC,EAAE,CAAC,EAAE,aAAa,CAAA;IAClB,mCAAmC;IACnC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAA;IAC3B,wDAAwD;IACxD,GAAG,CAAC,EAAE,WAAW,CAAA;IACjB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,yDAAyD;IACzD,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,0DAA0D;IAC1D,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB,qDAAqD;IACrD,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,gDAAgD;IAChD,GAAG,CAAC,EAAE,WAAW,CAAA;CAClB;AAED,aAAK,cAAc,GAAG;IACpB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAClC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG;QAAE,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,GAAG,IAAI,CAAA;KAAE,GACrD,YAAY,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAA;CAC3C,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,cA2FvB,CAAA;AASD,eAAe,SAAS,CAAA;AACxB,YAAY,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -10,20 +10,18 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import React from 'react';
|
|
13
|
-
import { forwardRef } from '@toptal/picasso-utils';
|
|
13
|
+
import { documentable, forwardRef } from '@toptal/picasso-utils';
|
|
14
14
|
import { twMerge } from '@toptal/picasso-tailwind-merge';
|
|
15
15
|
import { alignmentClasses, variantClassesByColor } from './styles';
|
|
16
16
|
import { getSpacingClasses, getSpacingStyles } from './utils';
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Container component used for spacing 2 elements
|
|
19
19
|
*/
|
|
20
|
-
export const
|
|
21
|
-
|
|
22
|
-
const { children, className, flex, direction, alignItems, justifyContent, wrap, style, variant, align, top, bottom, left, right, padded, gap,
|
|
20
|
+
export const Container = documentable(forwardRef((props, ref) => {
|
|
21
|
+
const { children, className, inline, flex, direction, alignItems, justifyContent, wrap, style, bordered = false, rounded = false, variant, align, as: Component = inline ? 'span' : 'div', top, bottom, left, right, padded, gap,
|
|
23
22
|
// Avoid passing external classes inside the rest props
|
|
24
23
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
25
|
-
classes: externalClasses } = props, rest = __rest(props, ["children", "className", "flex", "direction", "alignItems", "justifyContent", "wrap", "style", "variant", "align", "top", "bottom", "left", "right", "padded", "gap", "classes"]);
|
|
26
|
-
const Component = as;
|
|
24
|
+
classes: externalClasses } = props, rest = __rest(props, ["children", "className", "inline", "flex", "direction", "alignItems", "justifyContent", "wrap", "style", "bordered", "rounded", "variant", "align", "as", "top", "bottom", "left", "right", "padded", "gap", "classes"]);
|
|
27
25
|
const spacingProps = { gap, padded, top, bottom, right, left };
|
|
28
26
|
const isBorderedVariant = !variant || variant === 'white' || variant === 'transparent';
|
|
29
27
|
const getDisplayValue = (isInline, isFlex) => {
|
|
@@ -35,15 +33,16 @@ export const ContainerFunction = function ContainerFunction(_a) {
|
|
|
35
33
|
? 'inline-block'
|
|
36
34
|
: '';
|
|
37
35
|
};
|
|
38
|
-
return (React.createElement(Component, Object.assign({}, rest, { ref: ref, className: twMerge(variant && variantClassesByColor[variant], getSpacingClasses(spacingProps), typeof align === 'string' && alignmentClasses.textAlign[align], alignItems && alignmentClasses.alignItems[alignItems], justifyContent && alignmentClasses.justifyContent[justifyContent], wrap && alignmentClasses.wrap[wrap], bordered &&
|
|
36
|
+
return (React.createElement(Component, Object.assign({}, rest, { ref: ref, className: twMerge(variant && variantClassesByColor[variant], getSpacingClasses(spacingProps), typeof align === 'string' && alignmentClasses.textAlign[align], alignItems && alignmentClasses.alignItems[alignItems], justifyContent && alignmentClasses.justifyContent[justifyContent], wrap && alignmentClasses.wrap[wrap], bordered &&
|
|
37
|
+
isBorderedVariant &&
|
|
38
|
+
'border border-solid border-gray-200', rounded && 'rounded-md', getDisplayValue(inline, flex), direction &&
|
|
39
39
|
direction !== 'row' &&
|
|
40
40
|
alignmentClasses.direction[direction], className), style: Object.assign(Object.assign({}, getSpacingStyles(spacingProps)), style) }), children));
|
|
41
|
-
};
|
|
42
|
-
ContainerFunction.displayName = 'ContainerFunction';
|
|
43
|
-
/**
|
|
44
|
-
* Container component used for spacing 2 elements
|
|
45
|
-
*/
|
|
46
|
-
export const Container = forwardRef((props, ref) => ContainerFunction(Object.assign(Object.assign({}, props), { ref })));
|
|
41
|
+
}));
|
|
47
42
|
Container.displayName = 'Container';
|
|
43
|
+
Container.defaultProps = {
|
|
44
|
+
as: 'div',
|
|
45
|
+
inline: false,
|
|
46
|
+
};
|
|
48
47
|
export default Container;
|
|
49
48
|
//# sourceMappingURL=Container.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Container.js","sourceRoot":"","sources":["../../../src/Container/Container.tsx"],"names":[],"mappings":";;;;;;;;;;;AAKA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"Container.js","sourceRoot":"","sources":["../../../src/Container/Container.tsx"],"names":[],"mappings":";;;;;;;;;;;AAKA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,EAAE,OAAO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AAG,EACR,SAAS,EAAE,OAAO,CAChB,OAAO,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAEzC,iBAAiB,CAAC,YAAY,CAAC,EAE/B,OAAO,KAAK,KAAK,QAAQ,IAAI,gBAAgB,CAAC,SAAS,CAAC,KAAK,CAAC,EAE9D,UAAU,IAAI,gBAAgB,CAAC,UAAU,CAAC,UAAU,CAAC,EAErD,cAAc,IAAI,gBAAgB,CAAC,cAAc,CAAC,cAAc,CAAC,EAEjE,IAAI,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAEnC,QAAQ;YACN,iBAAiB;YACjB,qCAAqC,EACvC,OAAO,IAAI,YAAY,EAEvB,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,EAE7B,SAAS;YACP,SAAS,KAAK,KAAK;YACnB,gBAAgB,CAAC,SAAS,CAAC,SAAS,CAAC,EAEvC,SAAS,CACV,EACD,KAAK,kCAEA,gBAAgB,CAAC,YAAY,CAAC,GAC9B,KAAK,MAGT,QAAQ,CACC,CACb,CAAA;AACH,CAAC,CACgB,CACpB,CAAA;AAED,SAAS,CAAC,WAAW,GAAG,WAAW,CAAA;AAEnC,SAAS,CAAC,YAAY,GAAG;IACvB,EAAE,EAAE,KAAK;IACT,MAAM,EAAE,KAAK;CACd,CAAA;AAED,eAAe,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/Container/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,QAAQ,CAAA;AACnC,eAAO,MAAM,UAAU,QAAQ,CAAA;AAC/B,eAAO,MAAM,gBAAgB,QAAQ,CAAA;AACrC,eAAO,MAAM,eAAe,QAAQ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/Container/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAA;AACnC,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAA;AAC/B,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAA;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toptal/picasso-container",
|
|
3
|
-
"version": "3.1.3-alpha-MP-669-
|
|
3
|
+
"version": "3.1.3-alpha-MP-669-remove-default-props-dkjf3234-7db07b500.31+7db07b500",
|
|
4
4
|
"description": "Toptal UI components library - Container",
|
|
5
5
|
"homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"prepublishOnly": "yarn build:package"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@toptal/picasso-utils": "3.1.1-alpha-MP-669-
|
|
29
|
+
"@toptal/picasso-utils": "3.1.1-alpha-MP-669-remove-default-props-dkjf3234-7db07b500.31+7db07b500"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@toptal/picasso-provider": "*",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"react": ">=16.12.0 < 19.0.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@toptal/picasso-provider": "5.0.
|
|
39
|
-
"@toptal/picasso-test-utils": "1.1.2-alpha-MP-669-
|
|
38
|
+
"@toptal/picasso-provider": "5.0.2-alpha-MP-669-remove-default-props-dkjf3234-7db07b500.10+7db07b500",
|
|
39
|
+
"@toptal/picasso-test-utils": "1.1.2-alpha-MP-669-remove-default-props-dkjf3234-7db07b500.377+7db07b500"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"!dist-package/tsconfig.tsbuildinfo",
|
|
47
47
|
"src"
|
|
48
48
|
],
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "7db07b500402a91f0c09da3be294305a194fd1e4"
|
|
50
50
|
}
|
|
@@ -4,7 +4,7 @@ import type { SpacingType } from '@toptal/picasso-provider'
|
|
|
4
4
|
import type { StandardProps } from '@toptal/picasso-shared'
|
|
5
5
|
import type { HTMLAttributes, ReactElement, ReactNode, Ref } from 'react'
|
|
6
6
|
import React from 'react'
|
|
7
|
-
import { forwardRef } from '@toptal/picasso-utils'
|
|
7
|
+
import { documentable, forwardRef } from '@toptal/picasso-utils'
|
|
8
8
|
import { twMerge } from '@toptal/picasso-tailwind-merge'
|
|
9
9
|
|
|
10
10
|
import type { AlignItemsType, JustifyContentType, VariantType } from './styles'
|
|
@@ -19,14 +19,12 @@ type WrapType = 'wrap' | 'nowrap' | 'wrap-reverse'
|
|
|
19
19
|
|
|
20
20
|
type BorderableType = 'transparent' | 'white'
|
|
21
21
|
|
|
22
|
-
type BorderedType<V extends VariantType> = V extends BorderableType
|
|
23
|
-
? boolean
|
|
24
|
-
: never
|
|
25
22
|
export interface Props<V extends VariantType = VariantType>
|
|
26
23
|
extends StandardProps,
|
|
27
24
|
HTMLAttributes<HTMLDivElement | HTMLSpanElement> {
|
|
28
25
|
/** Content of Container */
|
|
29
26
|
children?: ReactNode
|
|
27
|
+
|
|
30
28
|
/** Whether container should act as inline element `display: inline-block` */
|
|
31
29
|
inline?: boolean
|
|
32
30
|
/** Use flexbox */
|
|
@@ -40,7 +38,7 @@ export interface Props<V extends VariantType = VariantType>
|
|
|
40
38
|
/** Defines flex-wrap style property */
|
|
41
39
|
wrap?: WrapType
|
|
42
40
|
/** Whether (`white`, `transparent`) container has border or not */
|
|
43
|
-
bordered?:
|
|
41
|
+
bordered?: V extends BorderableType ? boolean : never
|
|
44
42
|
/** Whether container has 8px border-radius applied or not */
|
|
45
43
|
rounded?: boolean
|
|
46
44
|
/** Style variant of Notification */
|
|
@@ -63,118 +61,116 @@ export interface Props<V extends VariantType = VariantType>
|
|
|
63
61
|
gap?: SpacingType
|
|
64
62
|
}
|
|
65
63
|
|
|
66
|
-
/**
|
|
67
|
-
* Separate component is needed for proper Storybook props display
|
|
68
|
-
*/
|
|
69
|
-
export const ContainerFunction = function ContainerFunction<
|
|
70
|
-
V extends VariantType
|
|
71
|
-
>({
|
|
72
|
-
as = 'div',
|
|
73
|
-
inline = false,
|
|
74
|
-
rounded = false,
|
|
75
|
-
bordered = false as BorderedType<V>,
|
|
76
|
-
ref,
|
|
77
|
-
...props
|
|
78
|
-
}: Props<V> & { ref?: Ref<HTMLDivElement> | null }) {
|
|
79
|
-
const {
|
|
80
|
-
children,
|
|
81
|
-
className,
|
|
82
|
-
flex,
|
|
83
|
-
direction,
|
|
84
|
-
alignItems,
|
|
85
|
-
justifyContent,
|
|
86
|
-
wrap,
|
|
87
|
-
style,
|
|
88
|
-
variant,
|
|
89
|
-
align,
|
|
90
|
-
top,
|
|
91
|
-
bottom,
|
|
92
|
-
left,
|
|
93
|
-
right,
|
|
94
|
-
padded,
|
|
95
|
-
gap,
|
|
96
|
-
// Avoid passing external classes inside the rest props
|
|
97
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
98
|
-
classes: externalClasses,
|
|
99
|
-
...rest
|
|
100
|
-
} = props
|
|
101
|
-
|
|
102
|
-
const Component = as
|
|
103
|
-
|
|
104
|
-
const spacingProps = { gap, padded, top, bottom, right, left }
|
|
105
|
-
const isBorderedVariant =
|
|
106
|
-
!variant || variant === 'white' || variant === 'transparent'
|
|
107
|
-
|
|
108
|
-
const getDisplayValue = (
|
|
109
|
-
isInline: boolean | undefined,
|
|
110
|
-
isFlex: boolean | undefined
|
|
111
|
-
) => {
|
|
112
|
-
return isFlex
|
|
113
|
-
? isInline
|
|
114
|
-
? 'inline-flex'
|
|
115
|
-
: 'flex'
|
|
116
|
-
: isInline
|
|
117
|
-
? 'inline-block'
|
|
118
|
-
: ''
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return (
|
|
122
|
-
<Component
|
|
123
|
-
{...rest}
|
|
124
|
-
ref={ref}
|
|
125
|
-
className={twMerge(
|
|
126
|
-
variant && variantClassesByColor[variant],
|
|
127
|
-
|
|
128
|
-
getSpacingClasses(spacingProps),
|
|
129
|
-
|
|
130
|
-
typeof align === 'string' && alignmentClasses.textAlign[align],
|
|
131
|
-
|
|
132
|
-
alignItems && alignmentClasses.alignItems[alignItems],
|
|
133
|
-
|
|
134
|
-
justifyContent && alignmentClasses.justifyContent[justifyContent],
|
|
135
|
-
|
|
136
|
-
wrap && alignmentClasses.wrap[wrap],
|
|
137
|
-
|
|
138
|
-
bordered && isBorderedVariant && 'border border-solid border-gray-200',
|
|
139
|
-
rounded && 'rounded-md',
|
|
140
|
-
|
|
141
|
-
getDisplayValue(inline, flex),
|
|
142
|
-
|
|
143
|
-
direction &&
|
|
144
|
-
direction !== 'row' &&
|
|
145
|
-
alignmentClasses.direction[direction],
|
|
146
|
-
|
|
147
|
-
className
|
|
148
|
-
)}
|
|
149
|
-
style={{
|
|
150
|
-
// used for deprecated spacing props (typeof number)
|
|
151
|
-
...getSpacingStyles(spacingProps),
|
|
152
|
-
...style,
|
|
153
|
-
}}
|
|
154
|
-
>
|
|
155
|
-
{children}
|
|
156
|
-
</Component>
|
|
157
|
-
)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
ContainerFunction.displayName = 'ContainerFunction'
|
|
161
|
-
|
|
162
64
|
type ContainerProps = {
|
|
163
65
|
<V extends VariantType = VariantType>(
|
|
164
66
|
props: Props<V> & { ref?: Ref<HTMLDivElement> | null }
|
|
165
67
|
): ReactElement
|
|
166
68
|
displayName?: string
|
|
69
|
+
defaultProps?: Partial<Props<VariantType>>
|
|
167
70
|
}
|
|
168
71
|
|
|
169
72
|
/**
|
|
170
73
|
* Container component used for spacing 2 elements
|
|
171
74
|
*/
|
|
172
|
-
export const Container: ContainerProps =
|
|
173
|
-
<
|
|
174
|
-
|
|
175
|
-
|
|
75
|
+
export const Container: ContainerProps = documentable(
|
|
76
|
+
forwardRef<Props, HTMLDivElement>(
|
|
77
|
+
<V extends VariantType>(
|
|
78
|
+
props: Props<V>,
|
|
79
|
+
ref: Ref<HTMLDivElement> | null
|
|
80
|
+
) => {
|
|
81
|
+
const {
|
|
82
|
+
children,
|
|
83
|
+
className,
|
|
84
|
+
inline,
|
|
85
|
+
flex,
|
|
86
|
+
direction,
|
|
87
|
+
alignItems,
|
|
88
|
+
justifyContent,
|
|
89
|
+
wrap,
|
|
90
|
+
style,
|
|
91
|
+
bordered = false,
|
|
92
|
+
rounded = false,
|
|
93
|
+
variant,
|
|
94
|
+
align,
|
|
95
|
+
as: Component = inline ? 'span' : 'div',
|
|
96
|
+
top,
|
|
97
|
+
bottom,
|
|
98
|
+
left,
|
|
99
|
+
right,
|
|
100
|
+
padded,
|
|
101
|
+
gap,
|
|
102
|
+
// Avoid passing external classes inside the rest props
|
|
103
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
104
|
+
classes: externalClasses,
|
|
105
|
+
...rest
|
|
106
|
+
} = props
|
|
107
|
+
|
|
108
|
+
const spacingProps = { gap, padded, top, bottom, right, left }
|
|
109
|
+
const isBorderedVariant =
|
|
110
|
+
!variant || variant === 'white' || variant === 'transparent'
|
|
111
|
+
|
|
112
|
+
const getDisplayValue = (
|
|
113
|
+
isInline: boolean | undefined,
|
|
114
|
+
isFlex: boolean | undefined
|
|
115
|
+
) => {
|
|
116
|
+
return isFlex
|
|
117
|
+
? isInline
|
|
118
|
+
? 'inline-flex'
|
|
119
|
+
: 'flex'
|
|
120
|
+
: isInline
|
|
121
|
+
? 'inline-block'
|
|
122
|
+
: ''
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<Component
|
|
127
|
+
{...rest}
|
|
128
|
+
ref={ref}
|
|
129
|
+
className={twMerge(
|
|
130
|
+
variant && variantClassesByColor[variant],
|
|
131
|
+
|
|
132
|
+
getSpacingClasses(spacingProps),
|
|
133
|
+
|
|
134
|
+
typeof align === 'string' && alignmentClasses.textAlign[align],
|
|
135
|
+
|
|
136
|
+
alignItems && alignmentClasses.alignItems[alignItems],
|
|
137
|
+
|
|
138
|
+
justifyContent && alignmentClasses.justifyContent[justifyContent],
|
|
139
|
+
|
|
140
|
+
wrap && alignmentClasses.wrap[wrap],
|
|
141
|
+
|
|
142
|
+
bordered &&
|
|
143
|
+
isBorderedVariant &&
|
|
144
|
+
'border border-solid border-gray-200',
|
|
145
|
+
rounded && 'rounded-md',
|
|
146
|
+
|
|
147
|
+
getDisplayValue(inline, flex),
|
|
148
|
+
|
|
149
|
+
direction &&
|
|
150
|
+
direction !== 'row' &&
|
|
151
|
+
alignmentClasses.direction[direction],
|
|
152
|
+
|
|
153
|
+
className
|
|
154
|
+
)}
|
|
155
|
+
style={{
|
|
156
|
+
// used for deprecated spacing props (typeof number)
|
|
157
|
+
...getSpacingStyles(spacingProps),
|
|
158
|
+
...style,
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
{children}
|
|
162
|
+
</Component>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
) as ContainerProps
|
|
166
|
+
)
|
|
176
167
|
|
|
177
168
|
Container.displayName = 'Container'
|
|
178
169
|
|
|
170
|
+
Container.defaultProps = {
|
|
171
|
+
as: 'div',
|
|
172
|
+
inline: false,
|
|
173
|
+
}
|
|
174
|
+
|
|
179
175
|
export default Container
|
|
180
176
|
export type { VariantType }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Container } from '../Container'
|
|
2
2
|
import PicassoBook from '~/.storybook/components/PicassoBook'
|
|
3
3
|
|
|
4
4
|
const page = PicassoBook.section('Layout').createPage(
|
|
@@ -9,16 +9,9 @@ const page = PicassoBook.section('Layout').createPage(
|
|
|
9
9
|
`
|
|
10
10
|
)
|
|
11
11
|
|
|
12
|
-
page
|
|
13
|
-
|
|
14
|
-
name: '
|
|
15
|
-
additionalDocs: {
|
|
16
|
-
bordered: {
|
|
17
|
-
type: 'boolean',
|
|
18
|
-
defaultValue: 'false',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
})
|
|
12
|
+
page
|
|
13
|
+
.createTabChapter('Props')
|
|
14
|
+
.addComponentDocs({ component: Container, name: 'Container' })
|
|
22
15
|
|
|
23
16
|
page
|
|
24
17
|
.createChapter()
|