@toptal/picasso-container 3.1.3-alpha-HG-917-fix-overlapping-sidebar-3957b1ee3.11 → 3.1.3-alpha-MP-669-first-batch-of-rework-c1fb81067.24
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 +11 -2
- package/dist-package/src/Container/Container.d.ts.map +1 -1
- package/dist-package/src/Container/Container.js +14 -13
- package/dist-package/src/Container/Container.js.map +1 -1
- package/package.json +5 -5
- package/src/Container/Container.tsx +105 -101
- package/src/Container/story/index.jsx +11 -4
|
@@ -7,6 +7,7 @@ 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;
|
|
10
11
|
export interface Props<V extends VariantType = VariantType> extends StandardProps, HTMLAttributes<HTMLDivElement | HTMLSpanElement> {
|
|
11
12
|
/** Content of Container */
|
|
12
13
|
children?: ReactNode;
|
|
@@ -23,7 +24,7 @@ export interface Props<V extends VariantType = VariantType> extends StandardProp
|
|
|
23
24
|
/** Defines flex-wrap style property */
|
|
24
25
|
wrap?: WrapType;
|
|
25
26
|
/** Whether (`white`, `transparent`) container has border or not */
|
|
26
|
-
bordered?: V
|
|
27
|
+
bordered?: BorderedType<V>;
|
|
27
28
|
/** Whether container has 8px border-radius applied or not */
|
|
28
29
|
rounded?: boolean;
|
|
29
30
|
/** Style variant of Notification */
|
|
@@ -45,12 +46,20 @@ export interface Props<V extends VariantType = VariantType> extends StandardProp
|
|
|
45
46
|
/** Gap between elements for a flex container */
|
|
46
47
|
gap?: SpacingType;
|
|
47
48
|
}
|
|
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
|
+
};
|
|
48
58
|
declare type ContainerProps = {
|
|
49
59
|
<V extends VariantType = VariantType>(props: Props<V> & {
|
|
50
60
|
ref?: Ref<HTMLDivElement> | null;
|
|
51
61
|
}): ReactElement;
|
|
52
62
|
displayName?: string;
|
|
53
|
-
defaultProps?: Partial<Props<VariantType>>;
|
|
54
63
|
};
|
|
55
64
|
/**
|
|
56
65
|
* 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,QAAQ,GAAG,cAAc,CAAA;AAElD,aAAK,cAAc,GAAG,aAAa,GAAG,OAAO,CAAA;AAE7C,MAAM,WAAW,KAAK,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,CACxD,SAAQ,aAA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';
|
|
13
|
-
import {
|
|
13
|
+
import { 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
|
+
* Separate component is needed for proper Storybook props display
|
|
19
19
|
*/
|
|
20
|
-
export const
|
|
21
|
-
|
|
20
|
+
export const ContainerFunction = function ContainerFunction(_a) {
|
|
21
|
+
var { as = 'div', inline = false, rounded = false, bordered = false, ref } = _a, props = __rest(_a, ["as", "inline", "rounded", "bordered", "ref"]);
|
|
22
|
+
const { children, className, flex, direction, alignItems, justifyContent, wrap, style, variant, align, top, bottom, left, right, padded, gap,
|
|
22
23
|
// Avoid passing external classes inside the rest props
|
|
23
24
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
24
|
-
classes: externalClasses } = props, rest = __rest(props, ["children", "className", "
|
|
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;
|
|
25
27
|
const spacingProps = { gap, padded, top, bottom, right, left };
|
|
26
28
|
const isBorderedVariant = !variant || variant === 'white' || variant === 'transparent';
|
|
27
29
|
const getDisplayValue = (isInline, isFlex) => {
|
|
@@ -33,16 +35,15 @@ export const Container = documentable(forwardRef((props, ref) => {
|
|
|
33
35
|
? 'inline-block'
|
|
34
36
|
: '';
|
|
35
37
|
};
|
|
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 &&
|
|
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 && isBorderedVariant && '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
|
-
Container.displayName = 'Container';
|
|
43
|
-
Container.defaultProps = {
|
|
44
|
-
as: 'div',
|
|
45
|
-
inline: false,
|
|
46
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 })));
|
|
47
|
+
Container.displayName = 'Container';
|
|
47
48
|
export default Container;
|
|
48
49
|
//# 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,
|
|
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;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AAGxD,O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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,IAAI,iBAAiB,IAAI,qCAAqC,EACtE,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,CAAA;AAED,iBAAiB,CAAC,WAAW,GAAG,mBAAmB,CAAA;AASnD;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAmB,UAAU,CACjD,CAAwB,KAAe,EAAE,GAA+B,EAAE,EAAE,CAC1E,iBAAiB,iCAAM,KAAK,KAAE,GAAG,IAAG,CACrB,CAAA;AAEnB,SAAS,CAAC,WAAW,GAAG,WAAW,CAAA;AAEnC,eAAe,SAAS,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toptal/picasso-container",
|
|
3
|
-
"version": "3.1.3-alpha-
|
|
3
|
+
"version": "3.1.3-alpha-MP-669-first-batch-of-rework-c1fb81067.24+c1fb81067",
|
|
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-
|
|
29
|
+
"@toptal/picasso-utils": "3.1.1-alpha-MP-669-first-batch-of-rework-c1fb81067.24+c1fb81067"
|
|
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.1-alpha-
|
|
39
|
-
"@toptal/picasso-test-utils": "1.1.2-alpha-
|
|
38
|
+
"@toptal/picasso-provider": "5.0.1-alpha-MP-669-first-batch-of-rework-c1fb81067.291+c1fb81067",
|
|
39
|
+
"@toptal/picasso-test-utils": "1.1.2-alpha-MP-669-first-batch-of-rework-c1fb81067.370+c1fb81067"
|
|
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": "c1fb81067638a739fa725a4befdad405a78db876"
|
|
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 {
|
|
7
|
+
import { 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,12 +19,14 @@ 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
|
|
22
25
|
export interface Props<V extends VariantType = VariantType>
|
|
23
26
|
extends StandardProps,
|
|
24
27
|
HTMLAttributes<HTMLDivElement | HTMLSpanElement> {
|
|
25
28
|
/** Content of Container */
|
|
26
29
|
children?: ReactNode
|
|
27
|
-
|
|
28
30
|
/** Whether container should act as inline element `display: inline-block` */
|
|
29
31
|
inline?: boolean
|
|
30
32
|
/** Use flexbox */
|
|
@@ -38,7 +40,7 @@ export interface Props<V extends VariantType = VariantType>
|
|
|
38
40
|
/** Defines flex-wrap style property */
|
|
39
41
|
wrap?: WrapType
|
|
40
42
|
/** Whether (`white`, `transparent`) container has border or not */
|
|
41
|
-
bordered?: V
|
|
43
|
+
bordered?: BorderedType<V>
|
|
42
44
|
/** Whether container has 8px border-radius applied or not */
|
|
43
45
|
rounded?: boolean
|
|
44
46
|
/** Style variant of Notification */
|
|
@@ -61,116 +63,118 @@ export interface Props<V extends VariantType = VariantType>
|
|
|
61
63
|
gap?: SpacingType
|
|
62
64
|
}
|
|
63
65
|
|
|
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
|
+
|
|
64
162
|
type ContainerProps = {
|
|
65
163
|
<V extends VariantType = VariantType>(
|
|
66
164
|
props: Props<V> & { ref?: Ref<HTMLDivElement> | null }
|
|
67
165
|
): ReactElement
|
|
68
166
|
displayName?: string
|
|
69
|
-
defaultProps?: Partial<Props<VariantType>>
|
|
70
167
|
}
|
|
71
168
|
|
|
72
169
|
/**
|
|
73
170
|
* Container component used for spacing 2 elements
|
|
74
171
|
*/
|
|
75
|
-
export const Container: ContainerProps =
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
)
|
|
172
|
+
export const Container: ContainerProps = forwardRef<Props, HTMLDivElement>(
|
|
173
|
+
<V extends VariantType>(props: Props<V>, ref: Ref<HTMLDivElement> | null) =>
|
|
174
|
+
ContainerFunction({ ...props, ref })
|
|
175
|
+
) as ContainerProps
|
|
167
176
|
|
|
168
177
|
Container.displayName = 'Container'
|
|
169
178
|
|
|
170
|
-
Container.defaultProps = {
|
|
171
|
-
as: 'div',
|
|
172
|
-
inline: false,
|
|
173
|
-
}
|
|
174
|
-
|
|
175
179
|
export default Container
|
|
176
180
|
export type { VariantType }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContainerFunction } from '../Container'
|
|
2
2
|
import PicassoBook from '~/.storybook/components/PicassoBook'
|
|
3
3
|
|
|
4
4
|
const page = PicassoBook.section('Layout').createPage(
|
|
@@ -9,9 +9,16 @@ const page = PicassoBook.section('Layout').createPage(
|
|
|
9
9
|
`
|
|
10
10
|
)
|
|
11
11
|
|
|
12
|
-
page
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
page.createTabChapter('Props').addComponentDocs({
|
|
13
|
+
component: ContainerFunction,
|
|
14
|
+
name: 'ContainerFunction',
|
|
15
|
+
additionalDocs: {
|
|
16
|
+
bordered: {
|
|
17
|
+
type: 'boolean',
|
|
18
|
+
defaultValue: 'false',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
})
|
|
15
22
|
|
|
16
23
|
page
|
|
17
24
|
.createChapter()
|