@goncharovv/layout 0.1.3 → 0.1.4
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/components/Stacks/HStack.d.ts +5 -0
- package/dist/components/Stacks/Stack.d.ts +5 -0
- package/dist/components/Stacks/VStack.d.ts +5 -0
- package/dist/components/Stacks/factory.d.ts +12 -9
- package/dist/components/Stacks/factory.js +5 -1
- package/dist/shared/paddings/index.d.ts +1 -0
- package/dist/shared/paddings/index.js +1 -0
- package/dist/shared/paddings/paddings.d.ts +17 -0
- package/dist/shared/paddings/paddings.js +17 -0
- package/dist/shared/spacings/config.d.ts +5 -0
- package/dist/shared/spacings/config.js +9 -1
- package/dist/styles/spacings.css +2 -0
- package/package.json +1 -1
|
@@ -11,9 +11,14 @@ export declare const HStack: <TElementType extends import("react").ElementType =
|
|
|
11
11
|
justify?: import("csstype").Property.JustifyContent | undefined;
|
|
12
12
|
wrap?: true | import("csstype").Property.FlexWrap | undefined;
|
|
13
13
|
gap?: number | undefined;
|
|
14
|
+
flex?: import("csstype").Property.Flex<string | number> | undefined;
|
|
14
15
|
centered?: boolean | undefined;
|
|
16
|
+
width?: import("csstype").Property.Width<string | number> | undefined;
|
|
15
17
|
style?: import("react").CSSProperties | undefined;
|
|
16
18
|
className?: string | undefined;
|
|
17
19
|
children?: import("react").ReactNode;
|
|
18
20
|
spacing?: import("../../shared/spacings").Spacing | undefined;
|
|
21
|
+
p?: import("../../shared/spacings").Spacing | undefined;
|
|
22
|
+
ph?: import("../../shared/spacings").Spacing | undefined;
|
|
23
|
+
pv?: import("../../shared/spacings").Spacing | undefined;
|
|
19
24
|
}>) => import("react").ReactNode;
|
|
@@ -17,11 +17,16 @@ export declare const Stack: <TElementType extends ElementType = "div">(props: im
|
|
|
17
17
|
justify?: import("csstype").Property.JustifyContent | undefined;
|
|
18
18
|
wrap?: true | import("csstype").Property.FlexWrap | undefined;
|
|
19
19
|
gap?: number | undefined;
|
|
20
|
+
flex?: import("csstype").Property.Flex<string | number> | undefined;
|
|
20
21
|
centered?: boolean | undefined;
|
|
22
|
+
width?: import("csstype").Property.Width<string | number> | undefined;
|
|
21
23
|
style?: CSSProperties | undefined;
|
|
22
24
|
className?: string | undefined;
|
|
23
25
|
children?: import("react").ReactNode;
|
|
24
26
|
spacing?: import("../../shared/spacings").Spacing | undefined;
|
|
27
|
+
p?: import("../../shared/spacings").Spacing | undefined;
|
|
28
|
+
ph?: import("../../shared/spacings").Spacing | undefined;
|
|
29
|
+
pv?: import("../../shared/spacings").Spacing | undefined;
|
|
25
30
|
}>) => import("react").ReactNode;
|
|
26
31
|
export declare function getStackClassesAndStyles(props: Pick<StackProps, 'direction' | 'horizontal' | 'vertical' | 'className' | 'style'>): {
|
|
27
32
|
className: string;
|
|
@@ -11,9 +11,14 @@ export declare const VStack: <TElementType extends import("react").ElementType =
|
|
|
11
11
|
justify?: import("csstype").Property.JustifyContent | undefined;
|
|
12
12
|
wrap?: true | import("csstype").Property.FlexWrap | undefined;
|
|
13
13
|
gap?: number | undefined;
|
|
14
|
+
flex?: import("csstype").Property.Flex<string | number> | undefined;
|
|
14
15
|
centered?: boolean | undefined;
|
|
16
|
+
width?: import("csstype").Property.Width<string | number> | undefined;
|
|
15
17
|
style?: import("react").CSSProperties | undefined;
|
|
16
18
|
className?: string | undefined;
|
|
17
19
|
children?: import("react").ReactNode;
|
|
18
20
|
spacing?: import("../../shared/spacings").Spacing | undefined;
|
|
21
|
+
p?: import("../../shared/spacings").Spacing | undefined;
|
|
22
|
+
ph?: import("../../shared/spacings").Spacing | undefined;
|
|
23
|
+
pv?: import("../../shared/spacings").Spacing | undefined;
|
|
19
24
|
}>) => import("react").ReactNode;
|
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
import { ComponentProps, CSSProperties, ElementType, PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
import { PropsWithPaddings } from '../../shared/paddings';
|
|
2
3
|
import { PropsWithSpacing } from '../../shared/spacings';
|
|
3
4
|
import { Prettify } from '../../shared/types';
|
|
4
|
-
export interface BaseStackProps<TElementType extends ElementType = 'div'> extends PropsWithChildren, PropsWithSpacing {
|
|
5
|
+
export interface BaseStackProps<TElementType extends ElementType = 'div'> extends PropsWithChildren, PropsWithSpacing, PropsWithPaddings {
|
|
5
6
|
as?: TElementType;
|
|
6
7
|
alignItems?: CSSProperties['alignItems'];
|
|
7
8
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
* shortcut for `alignItems`
|
|
10
|
+
*/
|
|
10
11
|
align?: CSSProperties['alignItems'];
|
|
11
12
|
justifyContent?: CSSProperties['justifyContent'];
|
|
12
13
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
* shortcut for `justifyContent`
|
|
15
|
+
*/
|
|
15
16
|
justify?: CSSProperties['justifyContent'];
|
|
16
17
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
* `flex-wrap` property
|
|
19
|
+
*
|
|
20
|
+
* If value equals `true`, add css property `flex-wrap: wrap`;
|
|
21
|
+
*/
|
|
21
22
|
wrap?: true | CSSProperties['flexWrap'];
|
|
22
23
|
/**
|
|
23
24
|
* Custom gap. This is uncommon prop. Consider using `spacing` instead.
|
|
24
25
|
*/
|
|
25
26
|
gap?: number;
|
|
27
|
+
flex?: CSSProperties['flex'];
|
|
26
28
|
/**
|
|
27
29
|
* Alias for:
|
|
28
30
|
* ```css
|
|
@@ -31,6 +33,7 @@ export interface BaseStackProps<TElementType extends ElementType = 'div'> extend
|
|
|
31
33
|
* ```
|
|
32
34
|
*/
|
|
33
35
|
centered?: boolean;
|
|
36
|
+
width?: CSSProperties['width'];
|
|
34
37
|
style?: CSSProperties;
|
|
35
38
|
className?: string;
|
|
36
39
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import cn from 'classnames';
|
|
3
|
+
import { getPaddingStyles } from '../../shared/paddings';
|
|
3
4
|
import { getSpacingStyles } from '../../shared/spacings';
|
|
4
5
|
import styles from './Stack.module.css';
|
|
5
6
|
export function createStack(name, options) {
|
|
6
7
|
const Component = function GenericStack(_props) {
|
|
7
8
|
const props = options.overrideProps ? options.overrideProps(_props) : _props;
|
|
8
9
|
// WARNING: Avoid proxying *component props* to real DOM
|
|
9
|
-
const { as: Element = 'div', align, alignItems, centered, gap, justify, justifyContent, spacing, style, wrap, className, children, ...rest } = props;
|
|
10
|
+
const { as: Element = 'div', align, alignItems, centered, gap, justify, justifyContent, spacing, style, wrap, className, children, p, pv, ph, width, flex, ...rest } = props;
|
|
10
11
|
return (_jsx(Element, { ...rest, className: cn(styles.stack, {
|
|
11
12
|
[styles.centered]: centered,
|
|
12
13
|
}, className), style: {
|
|
@@ -14,6 +15,9 @@ export function createStack(name, options) {
|
|
|
14
15
|
flexWrap: wrap === true ? 'wrap' : wrap,
|
|
15
16
|
alignItems: centered ? undefined : (alignItems ?? align),
|
|
16
17
|
justifyContent: centered ? undefined : (justifyContent ?? justify),
|
|
18
|
+
width,
|
|
19
|
+
flex,
|
|
20
|
+
...getPaddingStyles({ p, pv, ph }),
|
|
17
21
|
...style,
|
|
18
22
|
}, children: children }));
|
|
19
23
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './paddings';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './paddings';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { Spacing } from '../spacings';
|
|
3
|
+
export interface PropsWithPaddings {
|
|
4
|
+
/**
|
|
5
|
+
* padding
|
|
6
|
+
*/
|
|
7
|
+
p?: Spacing;
|
|
8
|
+
/**
|
|
9
|
+
* padding-horizontal. applies to `padding-left` and `padding-right`
|
|
10
|
+
*/
|
|
11
|
+
ph?: Spacing;
|
|
12
|
+
/**
|
|
13
|
+
* padding-vertical. applies to `padding-top` and `padding-bottom`
|
|
14
|
+
*/
|
|
15
|
+
pv?: Spacing;
|
|
16
|
+
}
|
|
17
|
+
export declare function getPaddingStyles(props: PropsWithPaddings): CSSProperties;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getSpacingStyleVariable } from '../spacings';
|
|
2
|
+
export function getPaddingStyles(props) {
|
|
3
|
+
const { p, ph, pv } = props;
|
|
4
|
+
if (p) {
|
|
5
|
+
return {
|
|
6
|
+
padding: getSpacingStyleVariable(p),
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
if (!ph && !pv) {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
const horizontal = getSpacingStyleVariable(ph) ?? 0;
|
|
13
|
+
const vertical = getSpacingStyleVariable(pv) ?? 0;
|
|
14
|
+
return {
|
|
15
|
+
padding: `${vertical} ${horizontal}`,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -5,10 +5,12 @@ export declare const spacings: {
|
|
|
5
5
|
'small-s': number;
|
|
6
6
|
'small-m': number;
|
|
7
7
|
'small-l': number;
|
|
8
|
+
'small-xl': number;
|
|
8
9
|
'medium-xs': number;
|
|
9
10
|
'medium-s': number;
|
|
10
11
|
'medium-m': number;
|
|
11
12
|
'medium-l': number;
|
|
13
|
+
'medium-xl': number;
|
|
12
14
|
'large-xxs': number;
|
|
13
15
|
'large-xs': number;
|
|
14
16
|
'large-s': number;
|
|
@@ -24,11 +26,13 @@ export interface PropsWithSpacing {
|
|
|
24
26
|
* - 'small-s': 4px
|
|
25
27
|
* - 'small-m': 6px
|
|
26
28
|
* - 'small-l': 8px
|
|
29
|
+
* - 'small-xl': 10px
|
|
27
30
|
* - medium:
|
|
28
31
|
* - 'medium-xs': 12px
|
|
29
32
|
* - 'medium-s': 16px
|
|
30
33
|
* - 'medium-m': 20px
|
|
31
34
|
* - 'medium-l': 24px
|
|
35
|
+
* - 'medium-xl': 28px
|
|
32
36
|
* - large:
|
|
33
37
|
* - 'large-xxs': 32px
|
|
34
38
|
* - 'large-xs': 40px
|
|
@@ -39,4 +43,5 @@ export interface PropsWithSpacing {
|
|
|
39
43
|
spacing?: Spacing;
|
|
40
44
|
}
|
|
41
45
|
export declare function getSpacing(spacing: Spacing | undefined): number | undefined;
|
|
46
|
+
export declare function getSpacingStyleVariable(spacing: Spacing | undefined): string | undefined;
|
|
42
47
|
export declare function getSpacingStyles(spacing: Spacing | undefined): CSSProperties;
|
|
@@ -7,10 +7,12 @@ export const spacings = {
|
|
|
7
7
|
'small-s': 4,
|
|
8
8
|
'small-m': 6,
|
|
9
9
|
'small-l': 8,
|
|
10
|
+
'small-xl': 10,
|
|
10
11
|
'medium-xs': 12,
|
|
11
12
|
'medium-s': 16,
|
|
12
13
|
'medium-m': 20,
|
|
13
14
|
'medium-l': 24,
|
|
15
|
+
'medium-xl': 28,
|
|
14
16
|
'large-xxs': 32,
|
|
15
17
|
'large-xs': 40,
|
|
16
18
|
'large-s': 48,
|
|
@@ -23,8 +25,14 @@ export function getSpacing(spacing) {
|
|
|
23
25
|
}
|
|
24
26
|
return spacings[spacing];
|
|
25
27
|
}
|
|
28
|
+
export function getSpacingStyleVariable(spacing) {
|
|
29
|
+
if (!spacing) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
return `var(--spacing-${spacing})`;
|
|
33
|
+
}
|
|
26
34
|
export function getSpacingStyles(spacing) {
|
|
27
35
|
return {
|
|
28
|
-
gap:
|
|
36
|
+
gap: getSpacingStyleVariable(spacing),
|
|
29
37
|
};
|
|
30
38
|
}
|
package/dist/styles/spacings.css
CHANGED
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
--spacing-small-s: 4px;
|
|
9
9
|
--spacing-small-m: 6px;
|
|
10
10
|
--spacing-small-l: 8px;
|
|
11
|
+
--spacing-small-xl: 10px;
|
|
11
12
|
--spacing-medium-xs: 12px;
|
|
12
13
|
--spacing-medium-s: 16px;
|
|
13
14
|
--spacing-medium-m: 20px;
|
|
14
15
|
--spacing-medium-l: 24px;
|
|
16
|
+
--spacing-medium-xl: 28px;
|
|
15
17
|
--spacing-large-xxs: 32px;
|
|
16
18
|
--spacing-large-xs: 40px;
|
|
17
19
|
--spacing-large-s: 48px;
|