@kalink-ui/seedly 0.7.0 → 0.8.1
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/CHANGELOG.md +13 -0
- package/build-storybook.log +67 -0
- package/package.json +7 -18
- package/src/components/box/box.css.ts +13 -2
- package/src/components/box/box.tsx +8 -28
- package/src/components/button/button.css.ts +346 -13
- package/src/components/button/button.tsx +37 -22
- package/src/components/center/center.css.ts +10 -2
- package/src/components/center/center.tsx +6 -20
- package/src/components/cluster/cluster.css.ts +10 -2
- package/src/components/cluster/cluster.tsx +6 -21
- package/src/components/conditional-wrapper/conditional-wrapper.tsx +23 -0
- package/src/components/conditional-wrapper/index.ts +1 -0
- package/src/components/cover/cover.css.ts +4 -13
- package/src/components/cover/cover.tsx +12 -22
- package/src/components/frame/frame.css.ts +3 -0
- package/src/components/frame/frame.tsx +6 -10
- package/src/components/grid/grid.css.ts +4 -2
- package/src/components/grid/grid.tsx +11 -15
- package/src/components/heading/heading.css.ts +5 -0
- package/src/components/heading/heading.tsx +83 -0
- package/src/components/heading/index.ts +1 -0
- package/src/components/index.ts +14 -0
- package/src/{styles → components}/seed/seed.tsx +3 -6
- package/src/components/sidebar/sidebar.css.ts +7 -2
- package/src/components/sidebar/sidebar.tsx +6 -21
- package/src/components/stack/stack.css.ts +7 -2
- package/src/components/stack/stack.tsx +6 -15
- package/src/components/switcher/switcher.css.ts +1 -2
- package/src/components/switcher/switcher.tsx +6 -16
- package/src/components/text/index.ts +1 -1
- package/src/components/text/text.css.ts +12 -2
- package/src/components/text/text.tsx +41 -23
- package/src/index.ts +2 -0
- package/src/styles/index.ts +15 -2
- package/src/styles/reset.css.ts +1 -0
- package/src/styles/system-contract.css.ts +45 -31
- package/src/styles/transition.ts +26 -0
- package/src/styles/typography.css.ts +2 -4
- package/src/utils/arg-types/arg-types-from-recipe.ts +36 -0
- package/src/utils/arg-types/arg-types-from-sprinkles.ts +43 -0
- package/src/utils/arg-types/common/composable.ts +13 -0
- package/src/utils/arg-types/common/index.ts +4 -0
- package/src/utils/arg-types/common/polymorphic.ts +14 -0
- package/src/utils/arg-types/common/referable.ts +10 -0
- package/src/utils/arg-types/common/stylable.ts +14 -0
- package/src/utils/arg-types/common-args.ts +26 -0
- package/src/utils/arg-types/index.ts +3 -0
- package/src/utils/index.ts +6 -2
- /package/src/{styles → components}/seed/index.ts +0 -0
- /package/src/{utils → styles}/extract-sprinkles-props.ts +0 -0
- /package/src/{utils → styles}/map-contract-vars.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { PolymorphicComponentProps } from '@kalink-ui/dibbly
|
|
3
|
+
import { PolymorphicComponentProps } from '@kalink-ui/dibbly';
|
|
4
4
|
import { assignInlineVars } from '@vanilla-extract/dynamic';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import { ElementType } from 'react';
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
sideWidthVar,
|
|
13
13
|
} from './sidebar.css';
|
|
14
14
|
|
|
15
|
-
type SidebarProps<TUse extends ElementType> =
|
|
16
|
-
|
|
15
|
+
type SidebarProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> &
|
|
16
|
+
Omit<SidebarVariants, 'sideWidth'> & {
|
|
17
17
|
/**
|
|
18
18
|
* The size of the side element
|
|
19
19
|
*/
|
|
@@ -24,21 +24,6 @@ type SidebarProps<TUse extends ElementType> =
|
|
|
24
24
|
* Should be a percentage.
|
|
25
25
|
*/
|
|
26
26
|
contentMinWidth?: string;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The side of the sidebar
|
|
30
|
-
*/
|
|
31
|
-
side?: SidebarVariants['side'];
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* The spacing between the sidebar and main content elements
|
|
35
|
-
*/
|
|
36
|
-
spacing?: SidebarVariants['spacing'];
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Whether the sidebar should stretch to fill the available space
|
|
40
|
-
*/
|
|
41
|
-
noStretch?: SidebarVariants['noStretch'];
|
|
42
27
|
};
|
|
43
28
|
|
|
44
29
|
/**
|
|
@@ -49,7 +34,7 @@ type SidebarProps<TUse extends ElementType> =
|
|
|
49
34
|
*
|
|
50
35
|
* https://every-layout.dev/layouts/sidebar/
|
|
51
36
|
*/
|
|
52
|
-
export
|
|
37
|
+
export function Sidebar<TUse extends ElementType>({
|
|
53
38
|
side = 'left',
|
|
54
39
|
sideWidth,
|
|
55
40
|
contentMinWidth,
|
|
@@ -57,7 +42,7 @@ export const Sidebar = <TUse extends ElementType>({
|
|
|
57
42
|
noStretch,
|
|
58
43
|
className,
|
|
59
44
|
...props
|
|
60
|
-
}: SidebarProps<TUse>)
|
|
45
|
+
}: SidebarProps<TUse>) {
|
|
61
46
|
const { use: Comp = 'div', ...rest } = props;
|
|
62
47
|
|
|
63
48
|
return (
|
|
@@ -73,4 +58,4 @@ export const Sidebar = <TUse extends ElementType>({
|
|
|
73
58
|
{...rest}
|
|
74
59
|
/>
|
|
75
60
|
);
|
|
76
|
-
}
|
|
61
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { createVar, globalStyle } from '@vanilla-extract/css';
|
|
2
2
|
import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
|
|
3
3
|
|
|
4
|
+
import { sys, mapContractVars } from '../../styles';
|
|
4
5
|
import { components } from '../../styles/layers.css';
|
|
5
|
-
import { sys } from '../../styles/system-contract.css';
|
|
6
|
-
import { mapContractVars } from '../../utils/map-contract-vars';
|
|
7
6
|
|
|
8
7
|
const spacing = createVar();
|
|
9
8
|
|
|
@@ -19,10 +18,16 @@ export const stackRecipe = recipe({
|
|
|
19
18
|
},
|
|
20
19
|
|
|
21
20
|
variants: {
|
|
21
|
+
/**
|
|
22
|
+
* Whether the stack spacing should be applied recursively
|
|
23
|
+
*/
|
|
22
24
|
recursive: {
|
|
23
25
|
true: {},
|
|
24
26
|
},
|
|
25
27
|
|
|
28
|
+
/**
|
|
29
|
+
* The spacing between items
|
|
30
|
+
*/
|
|
26
31
|
spacing: mapContractVars(sys.spacing, (key) => ({
|
|
27
32
|
'@layer': {
|
|
28
33
|
[components]: {
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import { PolymorphicComponentProps } from '@kalink-ui/dibbly
|
|
1
|
+
import { PolymorphicComponentProps } from '@kalink-ui/dibbly';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
3
|
import { ElementType } from 'react';
|
|
4
4
|
|
|
5
5
|
import { stackRecipe, StackVariants } from './stack.css';
|
|
6
6
|
|
|
7
|
-
type StackProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> &
|
|
8
|
-
|
|
9
|
-
* Whether the stack spacing should be applied recursively
|
|
10
|
-
*/
|
|
11
|
-
recursive?: StackVariants['recursive'];
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The spacing between items
|
|
15
|
-
*/
|
|
16
|
-
spacing?: StackVariants['spacing'];
|
|
17
|
-
};
|
|
7
|
+
type StackProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> &
|
|
8
|
+
StackVariants;
|
|
18
9
|
|
|
19
10
|
/**
|
|
20
11
|
* A custom element for injecting white space (margin) between flow
|
|
@@ -26,12 +17,12 @@ type StackProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> & {
|
|
|
26
17
|
*
|
|
27
18
|
* https://every-layout.dev/layouts/stack
|
|
28
19
|
*/
|
|
29
|
-
export
|
|
20
|
+
export function Stack<TUse extends ElementType = 'div'>({
|
|
30
21
|
recursive,
|
|
31
22
|
spacing,
|
|
32
23
|
className,
|
|
33
24
|
...props
|
|
34
|
-
}: StackProps<TUse>)
|
|
25
|
+
}: StackProps<TUse>) {
|
|
35
26
|
const { use: Comp = 'div', ...rest } = props;
|
|
36
27
|
|
|
37
28
|
return (
|
|
@@ -40,4 +31,4 @@ export const Stack = <TUse extends ElementType = 'div'>({
|
|
|
40
31
|
{...rest}
|
|
41
32
|
/>
|
|
42
33
|
);
|
|
43
|
-
}
|
|
34
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { createVar, globalStyle } from '@vanilla-extract/css';
|
|
2
2
|
import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
|
|
3
3
|
|
|
4
|
+
import { sys, mapContractVars } from '../../styles';
|
|
4
5
|
import { components } from '../../styles/layers.css';
|
|
5
|
-
import { sys } from '../../styles/system-contract.css';
|
|
6
|
-
import { mapContractVars } from '../../utils/map-contract-vars';
|
|
7
6
|
|
|
8
7
|
export const thresholdVar = createVar();
|
|
9
8
|
export const limitVar = createVar();
|
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { PolymorphicComponentProps } from '@kalink-ui/dibbly
|
|
3
|
+
import { PolymorphicComponentProps } from '@kalink-ui/dibbly';
|
|
4
4
|
import { assignInlineVars } from '@vanilla-extract/dynamic';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import { ElementType } from 'react';
|
|
7
7
|
|
|
8
8
|
import { switcherRecipe, SwitcherVariants, thresholdVar } from './switcher.css';
|
|
9
9
|
|
|
10
|
-
type SwitcherProps<TUse extends ElementType> =
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The gap between items
|
|
14
|
-
*/
|
|
15
|
-
spacing?: SwitcherVariants['spacing'];
|
|
16
|
-
|
|
10
|
+
type SwitcherProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> &
|
|
11
|
+
SwitcherVariants & {
|
|
17
12
|
/**
|
|
18
13
|
* The threshold at which to switch between horizontal and vertical layouts
|
|
19
14
|
*/
|
|
20
15
|
threshold?: string;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The maximum number of elements allowed to appear in the horizontal configuration
|
|
24
|
-
*/
|
|
25
|
-
limit?: SwitcherVariants['limit'];
|
|
26
16
|
};
|
|
27
17
|
|
|
28
18
|
/**
|
|
@@ -31,13 +21,13 @@ type SwitcherProps<TUse extends ElementType> =
|
|
|
31
21
|
*
|
|
32
22
|
* https://every-layout.dev/layouts/switcher
|
|
33
23
|
*/
|
|
34
|
-
export
|
|
24
|
+
export function Switcher<TUse extends ElementType>({
|
|
35
25
|
spacing,
|
|
36
26
|
threshold,
|
|
37
27
|
limit,
|
|
38
28
|
className,
|
|
39
29
|
...props
|
|
40
|
-
}: SwitcherProps<TUse>)
|
|
30
|
+
}: SwitcherProps<TUse>) {
|
|
41
31
|
const { use: Comp = 'div' } = props;
|
|
42
32
|
|
|
43
33
|
return (
|
|
@@ -49,4 +39,4 @@ export const Switcher = <TUse extends ElementType>({
|
|
|
49
39
|
{...props}
|
|
50
40
|
/>
|
|
51
41
|
);
|
|
52
|
-
}
|
|
42
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Text } from './text';
|
|
1
|
+
export { Text, type TextProps } from './text';
|
|
@@ -1,15 +1,25 @@
|
|
|
1
|
+
import { style } from '@vanilla-extract/css';
|
|
1
2
|
import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
|
|
2
3
|
|
|
3
4
|
export const textRecipe = recipe({
|
|
4
5
|
variants: {
|
|
6
|
+
/**
|
|
7
|
+
* If true, use an ellipsis when the text overflows the element.
|
|
8
|
+
*/
|
|
5
9
|
ellipsis: {
|
|
6
10
|
true: {
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
display: 'inline-block',
|
|
12
|
+
maxWidth: '100%',
|
|
9
13
|
overflow: 'hidden',
|
|
14
|
+
|
|
15
|
+
textOverflow: 'ellipsis',
|
|
10
16
|
},
|
|
11
17
|
},
|
|
12
18
|
},
|
|
13
19
|
});
|
|
14
20
|
|
|
21
|
+
export const textEllipsisWrapper = style({
|
|
22
|
+
whiteSpace: 'nowrap',
|
|
23
|
+
});
|
|
24
|
+
|
|
15
25
|
export type TextVariants = NonNullable<RecipeVariants<typeof textRecipe>>;
|
|
@@ -1,43 +1,61 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
DistributiveOmit,
|
|
3
|
+
PolymorphicComponentProps,
|
|
4
|
+
getProp,
|
|
5
|
+
} from '@kalink-ui/dibbly';
|
|
3
6
|
import { clsx } from 'clsx';
|
|
4
7
|
import { ElementType } from 'react';
|
|
5
8
|
|
|
6
|
-
import {
|
|
7
|
-
import { Box } from '../box';
|
|
9
|
+
import { TypographySize, TypographyVariant, typography } from '../../styles';
|
|
8
10
|
|
|
9
|
-
import { textRecipe,
|
|
11
|
+
import { TextVariants, textRecipe, textEllipsisWrapper } from './text.css';
|
|
10
12
|
|
|
11
|
-
type TextProps<TUse extends React.ElementType> =
|
|
12
|
-
PolymorphicComponentProps<TUse
|
|
13
|
+
export type TextProps<TUse extends React.ElementType> = DistributiveOmit<
|
|
14
|
+
PolymorphicComponentProps<TUse>,
|
|
15
|
+
'children'
|
|
16
|
+
> &
|
|
17
|
+
TextVariants & {
|
|
13
18
|
/**
|
|
14
|
-
* The typography used to render the text.
|
|
19
|
+
* The size of the typography used to render the text.
|
|
15
20
|
*/
|
|
16
|
-
|
|
21
|
+
size?: TypographySize;
|
|
22
|
+
|
|
17
23
|
/**
|
|
18
|
-
*
|
|
24
|
+
* The typography variant used to render the text.
|
|
19
25
|
*/
|
|
20
|
-
|
|
26
|
+
variant?: Extract<TypographyVariant, 'body' | 'caption' | 'label'>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The text to render.
|
|
30
|
+
*/
|
|
31
|
+
children: string;
|
|
21
32
|
};
|
|
22
33
|
|
|
23
|
-
export function Text<TUse extends ElementType>({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
export function Text<TUse extends ElementType>(props: TextProps<TUse>) {
|
|
35
|
+
const {
|
|
36
|
+
children,
|
|
37
|
+
className,
|
|
38
|
+
ellipsis,
|
|
39
|
+
size = 'medium',
|
|
40
|
+
use: Comp = 'span',
|
|
41
|
+
variant = 'body',
|
|
42
|
+
...rest
|
|
43
|
+
} = props;
|
|
30
44
|
|
|
31
45
|
return (
|
|
32
|
-
<
|
|
33
|
-
// See `frontend/components/box/box.types.ts` for why the cast is required
|
|
34
|
-
use={use as TextProps<TUse>['use']}
|
|
46
|
+
<Comp
|
|
35
47
|
className={clsx(
|
|
36
48
|
textRecipe({ ellipsis }),
|
|
37
|
-
|
|
49
|
+
getProp(typography, `${variant}.${size}`),
|
|
38
50
|
className,
|
|
39
51
|
)}
|
|
40
52
|
{...rest}
|
|
41
|
-
|
|
53
|
+
>
|
|
54
|
+
{ellipsis ? (
|
|
55
|
+
<span className={textEllipsisWrapper}>{children}</span>
|
|
56
|
+
) : (
|
|
57
|
+
children
|
|
58
|
+
)}
|
|
59
|
+
</Comp>
|
|
42
60
|
);
|
|
43
61
|
}
|
package/src/index.ts
ADDED
package/src/styles/index.ts
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
1
|
+
export {
|
|
2
|
+
sys,
|
|
3
|
+
type Spacing,
|
|
4
|
+
type TypographySize,
|
|
5
|
+
type TypographyVariant,
|
|
6
|
+
} from './system-contract.css';
|
|
7
|
+
export { typography } from './typography.css';
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
extractSprinklesProps,
|
|
11
|
+
type GetSprinkles,
|
|
12
|
+
type SprinklesFnBase,
|
|
13
|
+
} from './extract-sprinkles-props';
|
|
14
|
+
|
|
15
|
+
export { mapContractVars } from './map-contract-vars';
|
package/src/styles/reset.css.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createThemeContract } from '@vanilla-extract/css';
|
|
2
|
+
import { ArrayValues } from 'type-fest';
|
|
2
3
|
|
|
3
4
|
export const typeContract = {
|
|
4
5
|
font: null,
|
|
@@ -8,6 +9,16 @@ export const typeContract = {
|
|
|
8
9
|
size: null,
|
|
9
10
|
} as const;
|
|
10
11
|
|
|
12
|
+
const typographyVariants = [
|
|
13
|
+
'display',
|
|
14
|
+
'headline',
|
|
15
|
+
'title',
|
|
16
|
+
'label',
|
|
17
|
+
'body',
|
|
18
|
+
] as const;
|
|
19
|
+
|
|
20
|
+
const typographySizes = ['large', 'medium', 'small'] as const;
|
|
21
|
+
|
|
11
22
|
export const sys = createThemeContract({
|
|
12
23
|
layout: {
|
|
13
24
|
direction: null,
|
|
@@ -31,6 +42,10 @@ export const sys = createThemeContract({
|
|
|
31
42
|
pressed: {
|
|
32
43
|
opacity: null,
|
|
33
44
|
},
|
|
45
|
+
muted: {
|
|
46
|
+
light: null,
|
|
47
|
+
dark: null,
|
|
48
|
+
},
|
|
34
49
|
},
|
|
35
50
|
|
|
36
51
|
shape: {
|
|
@@ -88,37 +103,22 @@ export const sys = createThemeContract({
|
|
|
88
103
|
},
|
|
89
104
|
},
|
|
90
105
|
|
|
91
|
-
typography:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
small: typeContract,
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
label: {
|
|
111
|
-
large: typeContract,
|
|
112
|
-
medium: typeContract,
|
|
113
|
-
small: typeContract,
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
body: {
|
|
117
|
-
large: typeContract,
|
|
118
|
-
medium: typeContract,
|
|
119
|
-
small: typeContract,
|
|
120
|
-
},
|
|
121
|
-
},
|
|
106
|
+
typography: typographyVariants.reduce(
|
|
107
|
+
(acc, variant) => ({
|
|
108
|
+
...acc,
|
|
109
|
+
[variant]: typographySizes.reduce(
|
|
110
|
+
(acc, size) => ({
|
|
111
|
+
...acc,
|
|
112
|
+
[size]: typeContract,
|
|
113
|
+
}),
|
|
114
|
+
{} as Record<TypographySize, typeof typeContract>,
|
|
115
|
+
),
|
|
116
|
+
}),
|
|
117
|
+
{} as Record<
|
|
118
|
+
TypographyVariant,
|
|
119
|
+
Record<TypographySize, typeof typeContract>
|
|
120
|
+
>,
|
|
121
|
+
),
|
|
122
122
|
|
|
123
123
|
spacing: {
|
|
124
124
|
0: null,
|
|
@@ -142,3 +142,17 @@ export const sys = createThemeContract({
|
|
|
142
142
|
18: null,
|
|
143
143
|
},
|
|
144
144
|
});
|
|
145
|
+
|
|
146
|
+
export type Spacing = keyof typeof sys.spacing;
|
|
147
|
+
export type TypographyVariant = ArrayValues<typeof typographyVariants>;
|
|
148
|
+
export type TypographySize = ArrayValues<typeof typographySizes>;
|
|
149
|
+
|
|
150
|
+
export type Duration = {
|
|
151
|
+
[K in keyof typeof sys.motion.duration]: `${K}.${Extract<keyof (typeof sys.motion.duration)[K], string | number>}`;
|
|
152
|
+
}[keyof typeof sys.motion.duration];
|
|
153
|
+
|
|
154
|
+
export type Easing = {
|
|
155
|
+
[K in keyof typeof sys.motion.easing]: (typeof sys.motion.easing)[K] extends string
|
|
156
|
+
? K
|
|
157
|
+
: `${K}.${Extract<keyof (typeof sys.motion.easing)[K], string | number>}`;
|
|
158
|
+
}[keyof typeof sys.motion.easing];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getProp } from '@kalink-ui/dibbly';
|
|
2
|
+
|
|
3
|
+
import { type Duration, type Easing, sys } from './system-contract.css';
|
|
4
|
+
|
|
5
|
+
export type CreateTransitionFn = (
|
|
6
|
+
props: string | string[],
|
|
7
|
+
options?: {
|
|
8
|
+
duration?: Duration;
|
|
9
|
+
easing?: Easing;
|
|
10
|
+
delay?: string;
|
|
11
|
+
},
|
|
12
|
+
) => string;
|
|
13
|
+
|
|
14
|
+
export const transition: CreateTransitionFn = (props = ['all'], options = {}) =>
|
|
15
|
+
(Array.isArray(props) ? props : [props])
|
|
16
|
+
.map(
|
|
17
|
+
(animatedProp) =>
|
|
18
|
+
`${animatedProp} ${
|
|
19
|
+
options.duration
|
|
20
|
+
? getProp(sys.motion.duration, options.duration)
|
|
21
|
+
: sys.motion.duration.medium[1]
|
|
22
|
+
} ${options.easing ? getProp(sys.motion.easing, options.easing) : sys.motion.easing.standard} ${
|
|
23
|
+
options.delay || '0ms'
|
|
24
|
+
}`,
|
|
25
|
+
)
|
|
26
|
+
.join(',');
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { styleVariants } from '@vanilla-extract/css';
|
|
2
2
|
|
|
3
|
-
import { sys } from './system-contract.css';
|
|
4
|
-
|
|
5
|
-
type TypographySize = 'large' | 'medium' | 'small';
|
|
3
|
+
import { sys, TypographySize, TypographyVariant } from './system-contract.css';
|
|
6
4
|
|
|
7
5
|
export const typography = Object.entries(sys.typography).reduce(
|
|
8
6
|
(acc, [key, value]) => {
|
|
@@ -19,5 +17,5 @@ export const typography = Object.entries(sys.typography).reduce(
|
|
|
19
17
|
}),
|
|
20
18
|
};
|
|
21
19
|
},
|
|
22
|
-
{} as Record<
|
|
20
|
+
{} as Record<TypographyVariant, Record<TypographySize, string>>,
|
|
23
21
|
);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ComplexStyleRule } from '@vanilla-extract/css';
|
|
2
|
+
import { type RuntimeFn } from '@vanilla-extract/recipes';
|
|
3
|
+
|
|
4
|
+
type RecipeStyleRule = ComplexStyleRule | string;
|
|
5
|
+
type VariantDefinitions = Record<string, RecipeStyleRule>;
|
|
6
|
+
type VariantGroups = Record<string, VariantDefinitions>;
|
|
7
|
+
|
|
8
|
+
export function argTypesFromRecipe(
|
|
9
|
+
recipe: RuntimeFn<VariantGroups>,
|
|
10
|
+
excludes: string[] = [],
|
|
11
|
+
) {
|
|
12
|
+
return Object.entries(recipe.classNames.variants).reduce(
|
|
13
|
+
(acc, [name, variant]) => {
|
|
14
|
+
if (excludes.includes(name)) {
|
|
15
|
+
return acc;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const options = Object.keys(variant);
|
|
19
|
+
let control = options.length > 5 ? 'select' : 'radio';
|
|
20
|
+
|
|
21
|
+
if (options.length === 1 && options[0] === 'true') {
|
|
22
|
+
options.push('false');
|
|
23
|
+
control = 'boolean';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
...acc,
|
|
28
|
+
[name]: {
|
|
29
|
+
control,
|
|
30
|
+
options,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
{},
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { isObject } from '@kalink-ui/dibbly';
|
|
2
|
+
|
|
3
|
+
type ArgTypesFromSprinklesProps = {
|
|
4
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
5
|
+
props: Record<string, any>;
|
|
6
|
+
excludes?: string[];
|
|
7
|
+
category?: string;
|
|
8
|
+
} & {};
|
|
9
|
+
|
|
10
|
+
export function argTypesFromSprinkles({
|
|
11
|
+
props,
|
|
12
|
+
excludes = [],
|
|
13
|
+
category = 'Sprinkles props',
|
|
14
|
+
}: ArgTypesFromSprinklesProps) {
|
|
15
|
+
return Object.entries(props).reduce((acc, [name]) => {
|
|
16
|
+
if (Array.isArray(excludes) && excludes.includes(name)) {
|
|
17
|
+
return acc;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let options = props[name] || [];
|
|
21
|
+
let control = 'select';
|
|
22
|
+
|
|
23
|
+
if (options.length === 1 && options[0] === 'true') {
|
|
24
|
+
options.push('false');
|
|
25
|
+
control = 'boolean';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (isObject(options)) {
|
|
29
|
+
options = Object.fromEntries(
|
|
30
|
+
Object.keys(options).map((key) => [key, key]),
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
...acc,
|
|
36
|
+
[name]: {
|
|
37
|
+
control,
|
|
38
|
+
options,
|
|
39
|
+
table: { category },
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}, {});
|
|
43
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const polymorphic = {
|
|
2
|
+
use: {
|
|
3
|
+
control: false,
|
|
4
|
+
description:
|
|
5
|
+
'The component used to render the root node of the component. Either a string to use an `JSX.IntrinsicElements` or a component reference to use a `React.ComponentType`',
|
|
6
|
+
defaultValue: '',
|
|
7
|
+
table: {
|
|
8
|
+
category: 'Intrinsic props',
|
|
9
|
+
type: {
|
|
10
|
+
summary: 'ElementType',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const stylable = {
|
|
2
|
+
className: {
|
|
3
|
+
control: false,
|
|
4
|
+
description:
|
|
5
|
+
'A class name string passed to the component. Merged with the inner class names.',
|
|
6
|
+
defaultValue: '',
|
|
7
|
+
table: {
|
|
8
|
+
category: 'Intrinsic props',
|
|
9
|
+
type: {
|
|
10
|
+
summary: 'string',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* eslint-disable import/namespace */
|
|
2
|
+
import * as CommonArgDefs from './common';
|
|
3
|
+
|
|
4
|
+
export enum CommonArgs {
|
|
5
|
+
COMPOSABLE = 'composable',
|
|
6
|
+
POLYMORPHIC = 'polymorphic',
|
|
7
|
+
STYLABLE = 'stylable',
|
|
8
|
+
REFERABLE = 'referable',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function commonArgs(args: CommonArgs[]) {
|
|
12
|
+
const argTypes: Partial<Record<string, object>> = {};
|
|
13
|
+
const knownArgs = Object.values(CommonArgs);
|
|
14
|
+
|
|
15
|
+
for (const arg of args) {
|
|
16
|
+
if (!knownArgs.includes(arg)) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
for (const argDef in CommonArgDefs[arg]) {
|
|
21
|
+
argTypes[argDef] = (CommonArgDefs[arg] as Record<string, object>)[argDef];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return argTypes;
|
|
26
|
+
}
|