@kalink-ui/seedly 0.25.0 → 0.26.0
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 +17 -1
- package/package.json +3 -3
- package/src/components/box/box.css.ts +21 -8
- package/src/components/box/box.responsive.ts +9 -0
- package/src/components/box/box.tsx +9 -3
- package/src/components/button/button.css.ts +199 -177
- package/src/components/button/button.responsive.ts +11 -0
- package/src/components/button/button.tsx +31 -10
- package/src/components/card/card.tsx +3 -1
- package/src/components/center/center.css.ts +23 -10
- package/src/components/center/center.responsive.ts +9 -0
- package/src/components/center/center.tsx +12 -3
- package/src/components/cluster/cluster.css.ts +116 -89
- package/src/components/cluster/cluster.responsive.ts +9 -0
- package/src/components/cluster/cluster.tsx +14 -3
- package/src/components/command/command-list.css.ts +24 -10
- package/src/components/command/command-list.responsive.ts +9 -0
- package/src/components/command/command-list.tsx +2 -2
- package/src/components/command/command.tsx +2 -2
- package/src/components/cover/cover.css.ts +23 -10
- package/src/components/cover/cover.responsive.ts +9 -0
- package/src/components/cover/cover.tsx +7 -3
- package/src/components/grid/grid.css.ts +21 -8
- package/src/components/grid/grid.responsive.ts +9 -0
- package/src/components/grid/grid.tsx +7 -3
- package/src/components/heading/heading.css.ts +75 -49
- package/src/components/heading/heading.responsive.ts +28 -0
- package/src/components/heading/heading.tsx +18 -9
- package/src/components/loader/loader.css.ts +31 -18
- package/src/components/loader/moon-loader.responsive.ts +9 -0
- package/src/components/loader/moon-loader.tsx +12 -3
- package/src/components/menu/menu-separator.css.ts +26 -10
- package/src/components/menu/menu-separator.responsive.ts +9 -0
- package/src/components/sidebar/sidebar.css.ts +21 -8
- package/src/components/sidebar/sidebar.responsive.ts +9 -0
- package/src/components/sidebar/sidebar.tsx +6 -3
- package/src/components/stack/stack.css.ts +61 -39
- package/src/components/stack/stack.responsive.ts +9 -0
- package/src/components/stack/stack.tsx +10 -3
- package/src/components/switcher/switcher.css.ts +21 -8
- package/src/components/switcher/switcher.responsive.ts +9 -0
- package/src/components/switcher/switcher.tsx +7 -3
- package/src/components/text/text.css.ts +78 -39
- package/src/components/text/text.responsive.ts +62 -0
- package/src/components/text/text.tsx +35 -8
- package/src/styles/breakpoints.ts +25 -0
- package/src/styles/index.ts +12 -0
- package/src/styles/responsive.ts +180 -0
|
@@ -1,8 +1,48 @@
|
|
|
1
1
|
import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
createResponsiveVariants,
|
|
5
|
+
defaultMedia,
|
|
6
|
+
mapContractVars,
|
|
7
|
+
sys,
|
|
8
|
+
} from '../../styles';
|
|
4
9
|
import { components } from '../../styles/layers.css';
|
|
5
10
|
|
|
11
|
+
export const headingAlignStyles = {
|
|
12
|
+
start: {
|
|
13
|
+
'@layer': {
|
|
14
|
+
[components]: {
|
|
15
|
+
alignItems: 'flex-start',
|
|
16
|
+
textAlign: 'start',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
center: {
|
|
21
|
+
'@layer': {
|
|
22
|
+
[components]: {
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
textAlign: 'center',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
end: {
|
|
29
|
+
'@layer': {
|
|
30
|
+
[components]: {
|
|
31
|
+
alignItems: 'flex-end',
|
|
32
|
+
textAlign: 'end',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
justify: {
|
|
37
|
+
'@layer': {
|
|
38
|
+
[components]: {
|
|
39
|
+
alignItems: 'stretch',
|
|
40
|
+
textAlign: 'justify',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
} as const;
|
|
45
|
+
|
|
6
46
|
export const headingRoot = recipe({
|
|
7
47
|
base: {
|
|
8
48
|
'@layer': {
|
|
@@ -14,67 +54,53 @@ export const headingRoot = recipe({
|
|
|
14
54
|
},
|
|
15
55
|
|
|
16
56
|
variants: {
|
|
17
|
-
align:
|
|
18
|
-
start: {
|
|
19
|
-
'@layer': {
|
|
20
|
-
[components]: {
|
|
21
|
-
alignItems: 'flex-start',
|
|
22
|
-
textAlign: 'start',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
center: {
|
|
27
|
-
'@layer': {
|
|
28
|
-
[components]: {
|
|
29
|
-
alignItems: 'center',
|
|
30
|
-
textAlign: 'center',
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
end: {
|
|
35
|
-
'@layer': {
|
|
36
|
-
[components]: {
|
|
37
|
-
alignItems: 'flex-end',
|
|
38
|
-
textAlign: 'end',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
justify: {
|
|
43
|
-
'@layer': {
|
|
44
|
-
[components]: {
|
|
45
|
-
alignItems: 'stretch',
|
|
46
|
-
textAlign: 'justify',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
57
|
+
align: headingAlignStyles,
|
|
51
58
|
},
|
|
52
59
|
});
|
|
53
60
|
|
|
61
|
+
export const pretitleSpacingStyles = mapContractVars(sys.spacing, (key) => ({
|
|
62
|
+
'@layer': {
|
|
63
|
+
[components]: {
|
|
64
|
+
marginBlockEnd: sys.spacing[key],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
}));
|
|
68
|
+
|
|
54
69
|
export const pretitle = recipe({
|
|
55
70
|
variants: {
|
|
56
|
-
spacing:
|
|
57
|
-
'@layer': {
|
|
58
|
-
[components]: {
|
|
59
|
-
marginBlockEnd: sys.spacing[key],
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
})),
|
|
71
|
+
spacing: pretitleSpacingStyles,
|
|
63
72
|
},
|
|
64
73
|
});
|
|
65
74
|
|
|
75
|
+
export const subtitleSpacingStyles = mapContractVars(sys.spacing, (key) => ({
|
|
76
|
+
'@layer': {
|
|
77
|
+
[components]: {
|
|
78
|
+
marginBlockStart: sys.spacing[key],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
}));
|
|
82
|
+
|
|
66
83
|
export const subtitle = recipe({
|
|
67
84
|
variants: {
|
|
68
|
-
spacing:
|
|
69
|
-
'@layer': {
|
|
70
|
-
[components]: {
|
|
71
|
-
marginBlockStart: sys.spacing[key],
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
})),
|
|
85
|
+
spacing: subtitleSpacingStyles,
|
|
75
86
|
},
|
|
76
87
|
});
|
|
77
88
|
|
|
78
89
|
export type HeadingRootVariants = NonNullable<
|
|
79
90
|
RecipeVariants<typeof headingRoot>
|
|
80
91
|
>;
|
|
92
|
+
|
|
93
|
+
export const alignAt = createResponsiveVariants({
|
|
94
|
+
styles: headingAlignStyles,
|
|
95
|
+
media: defaultMedia,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
export const pretitleSpacingAt = createResponsiveVariants({
|
|
99
|
+
styles: pretitleSpacingStyles,
|
|
100
|
+
media: defaultMedia,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export const subtitleSpacingAt = createResponsiveVariants({
|
|
104
|
+
styles: subtitleSpacingStyles,
|
|
105
|
+
media: defaultMedia,
|
|
106
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defaultOrder, responsiveRecipe } from '../../styles/responsive';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
alignAt,
|
|
5
|
+
headingRoot,
|
|
6
|
+
pretitle,
|
|
7
|
+
pretitleSpacingAt,
|
|
8
|
+
subtitle,
|
|
9
|
+
subtitleSpacingAt,
|
|
10
|
+
} from './heading.css';
|
|
11
|
+
|
|
12
|
+
export const headingRootResponsive = responsiveRecipe({
|
|
13
|
+
recipe: headingRoot,
|
|
14
|
+
at: { align: alignAt },
|
|
15
|
+
order: defaultOrder,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const pretitleResponsive = responsiveRecipe({
|
|
19
|
+
recipe: pretitle,
|
|
20
|
+
at: { spacing: pretitleSpacingAt },
|
|
21
|
+
order: defaultOrder,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const subtitleResponsive = responsiveRecipe({
|
|
25
|
+
recipe: subtitle,
|
|
26
|
+
at: { spacing: subtitleSpacingAt },
|
|
27
|
+
order: defaultOrder,
|
|
28
|
+
});
|
|
@@ -6,22 +6,30 @@ import { Spacing, TypographySize, TypographyVariant } from '../../styles';
|
|
|
6
6
|
import { ConditionalWrapper } from '../conditional-wrapper';
|
|
7
7
|
import { Text, TextProps, TextVariants } from '../text';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
headingRootResponsive,
|
|
11
|
+
pretitleResponsive,
|
|
12
|
+
subtitleResponsive,
|
|
13
|
+
} from './heading.responsive';
|
|
14
|
+
|
|
15
|
+
import type { Responsive } from '../../styles/responsive';
|
|
10
16
|
|
|
11
17
|
export type HeadingTypes = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
12
18
|
|
|
13
19
|
export type HeadingProps<TUse extends ElementType = 'h2'> =
|
|
14
20
|
PolymorphicComponentProps<TUse> &
|
|
15
|
-
TextVariants & {
|
|
21
|
+
Omit<TextVariants, 'align'> & {
|
|
16
22
|
/**
|
|
17
23
|
* The typography used to render the text.
|
|
18
24
|
*/
|
|
19
|
-
variant
|
|
25
|
+
variant?: Responsive<
|
|
26
|
+
Extract<TypographyVariant, 'display' | 'headline' | 'title'>
|
|
27
|
+
>;
|
|
20
28
|
|
|
21
29
|
/**
|
|
22
30
|
* The size of the typography used to render the text.
|
|
23
31
|
*/
|
|
24
|
-
size?: TypographySize
|
|
32
|
+
size?: Responsive<TypographySize>;
|
|
25
33
|
|
|
26
34
|
/**
|
|
27
35
|
* If provided, the text will be rendered before the title.
|
|
@@ -42,6 +50,7 @@ export type HeadingProps<TUse extends ElementType = 'h2'> =
|
|
|
42
50
|
* The class to pass to the root element.
|
|
43
51
|
*/
|
|
44
52
|
rootClassName?: string;
|
|
53
|
+
align?: Responsive<NonNullable<TextVariants['align']>>;
|
|
45
54
|
};
|
|
46
55
|
|
|
47
56
|
const headingMapping: Record<
|
|
@@ -75,7 +84,7 @@ export function Heading<TUse extends HeadingTypes>(props: HeadingProps<TUse>) {
|
|
|
75
84
|
ref={ref}
|
|
76
85
|
use={'hgroup'}
|
|
77
86
|
condition={!!pretitle || !!subtitle}
|
|
78
|
-
className={clsx(
|
|
87
|
+
className={clsx(headingRootResponsive({ align }), rootClassName)}
|
|
79
88
|
>
|
|
80
89
|
{pretitle}
|
|
81
90
|
|
|
@@ -97,7 +106,7 @@ export function Heading<TUse extends HeadingTypes>(props: HeadingProps<TUse>) {
|
|
|
97
106
|
|
|
98
107
|
export type HeadingPretitleProps = Omit<TextProps<'p'>, 'children'> & {
|
|
99
108
|
children?: string | null;
|
|
100
|
-
spacing?: Spacing
|
|
109
|
+
spacing?: Responsive<Spacing>;
|
|
101
110
|
};
|
|
102
111
|
|
|
103
112
|
Heading.Pretitle = function HeadingPretitle({
|
|
@@ -114,7 +123,7 @@ Heading.Pretitle = function HeadingPretitle({
|
|
|
114
123
|
use="p"
|
|
115
124
|
variant={variant}
|
|
116
125
|
size={size}
|
|
117
|
-
className={clsx(
|
|
126
|
+
className={clsx(pretitleResponsive({ spacing }), className)}
|
|
118
127
|
{...rest}
|
|
119
128
|
>
|
|
120
129
|
{children}
|
|
@@ -125,7 +134,7 @@ Heading.Pretitle = function HeadingPretitle({
|
|
|
125
134
|
|
|
126
135
|
export type HeadingSubtitleProps = Omit<TextProps<'p'>, 'children'> & {
|
|
127
136
|
children?: string | null;
|
|
128
|
-
spacing?: Spacing
|
|
137
|
+
spacing?: Responsive<Spacing>;
|
|
129
138
|
};
|
|
130
139
|
|
|
131
140
|
Heading.Subtitle = function HeadingSubtitle({
|
|
@@ -142,7 +151,7 @@ Heading.Subtitle = function HeadingSubtitle({
|
|
|
142
151
|
use="p"
|
|
143
152
|
variant={variant}
|
|
144
153
|
size={size}
|
|
145
|
-
className={clsx(
|
|
154
|
+
className={clsx(subtitleResponsive({ spacing }), className)}
|
|
146
155
|
{...rest}
|
|
147
156
|
>
|
|
148
157
|
{children}
|
|
@@ -2,7 +2,12 @@ import { createVar, keyframes, style } from '@vanilla-extract/css';
|
|
|
2
2
|
import { calc } from '@vanilla-extract/css-utils';
|
|
3
3
|
import { recipe, RecipeVariants } from '@vanilla-extract/recipes';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
createResponsiveVariants,
|
|
7
|
+
defaultMedia,
|
|
8
|
+
sys,
|
|
9
|
+
transition,
|
|
10
|
+
} from '../../styles';
|
|
6
11
|
|
|
7
12
|
export const loader = recipe({
|
|
8
13
|
variants: {
|
|
@@ -32,6 +37,25 @@ const loaderAnimation = keyframes({
|
|
|
32
37
|
},
|
|
33
38
|
});
|
|
34
39
|
|
|
40
|
+
// Shared size variant styles for responsive overrides
|
|
41
|
+
const loaderWrapperSizeStyles = {
|
|
42
|
+
sm: {
|
|
43
|
+
vars: {
|
|
44
|
+
[size]: sys.spacing[4],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
md: {
|
|
48
|
+
vars: {
|
|
49
|
+
[size]: sys.spacing[5],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
lg: {
|
|
53
|
+
vars: {
|
|
54
|
+
[size]: sys.spacing[6],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
} as const;
|
|
58
|
+
|
|
35
59
|
export const loaderWrapper = recipe({
|
|
36
60
|
base: {
|
|
37
61
|
overflow: 'hidden',
|
|
@@ -53,23 +77,7 @@ export const loaderWrapper = recipe({
|
|
|
53
77
|
},
|
|
54
78
|
|
|
55
79
|
variants: {
|
|
56
|
-
size:
|
|
57
|
-
sm: {
|
|
58
|
-
vars: {
|
|
59
|
-
[size]: sys.spacing[4],
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
md: {
|
|
63
|
-
vars: {
|
|
64
|
-
[size]: sys.spacing[5],
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
lg: {
|
|
68
|
-
vars: {
|
|
69
|
-
[size]: sys.spacing[6],
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
},
|
|
80
|
+
size: loaderWrapperSizeStyles,
|
|
73
81
|
},
|
|
74
82
|
});
|
|
75
83
|
|
|
@@ -107,3 +115,8 @@ export type LoaderVariants = NonNullable<RecipeVariants<typeof loader>>;
|
|
|
107
115
|
export type MoonLoaderVariants = NonNullable<
|
|
108
116
|
RecipeVariants<typeof loaderWrapper>
|
|
109
117
|
>;
|
|
118
|
+
|
|
119
|
+
export const sizeAt = createResponsiveVariants({
|
|
120
|
+
styles: loaderWrapperSizeStyles,
|
|
121
|
+
media: defaultMedia,
|
|
122
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defaultOrder, responsiveRecipe } from '../../styles/responsive';
|
|
2
|
+
|
|
3
|
+
import { loaderWrapper, sizeAt } from './loader.css';
|
|
4
|
+
|
|
5
|
+
export const moonLoaderResponsive = responsiveRecipe({
|
|
6
|
+
recipe: loaderWrapper,
|
|
7
|
+
at: { size: sizeAt },
|
|
8
|
+
order: defaultOrder,
|
|
9
|
+
});
|
|
@@ -6,11 +6,13 @@ import { Box, BoxProps } from '../box';
|
|
|
6
6
|
import {
|
|
7
7
|
ellipse,
|
|
8
8
|
moon,
|
|
9
|
-
loaderWrapper,
|
|
10
9
|
loader,
|
|
11
10
|
LoaderVariants,
|
|
12
11
|
MoonLoaderVariants,
|
|
13
12
|
} from './loader.css';
|
|
13
|
+
import { moonLoaderResponsive } from './moon-loader.responsive';
|
|
14
|
+
|
|
15
|
+
import type { Responsive } from '../../styles/responsive';
|
|
14
16
|
|
|
15
17
|
export type LoaderProps<TUse extends ElementType> = BoxProps<TUse> & {
|
|
16
18
|
forceMount?: boolean;
|
|
@@ -26,14 +28,21 @@ export function MoonLoader<TUse extends ElementType>({
|
|
|
26
28
|
forceMount = false,
|
|
27
29
|
className,
|
|
28
30
|
...props
|
|
29
|
-
}: LoaderProps<TUse> &
|
|
31
|
+
}: LoaderProps<TUse> &
|
|
32
|
+
Omit<MoonLoaderVariants, 'size'> & {
|
|
33
|
+
size?: Responsive<NonNullable<MoonLoaderVariants['size']>>;
|
|
34
|
+
}) {
|
|
30
35
|
if (!active && !forceMount) {
|
|
31
36
|
return null;
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
return (
|
|
35
40
|
<Box
|
|
36
|
-
className={clsx(
|
|
41
|
+
className={clsx(
|
|
42
|
+
moonLoaderResponsive({ size }),
|
|
43
|
+
loader({ active }),
|
|
44
|
+
className,
|
|
45
|
+
)}
|
|
37
46
|
{...props}
|
|
38
47
|
>
|
|
39
48
|
<span className={ellipse} />
|
|
@@ -2,11 +2,30 @@ import { createVar } from '@vanilla-extract/css';
|
|
|
2
2
|
import { calc } from '@vanilla-extract/css-utils';
|
|
3
3
|
import { recipe, RecipeVariants } from '@vanilla-extract/recipes';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
createResponsiveVariants,
|
|
7
|
+
defaultMedia,
|
|
8
|
+
mapContractVars,
|
|
9
|
+
sys,
|
|
10
|
+
} from '../../styles';
|
|
6
11
|
import { components } from '../../styles/layers.css';
|
|
7
12
|
|
|
8
13
|
const spaceVar = createVar();
|
|
9
14
|
|
|
15
|
+
// Shared spacing styles for responsive overrides
|
|
16
|
+
export const menuSeparatorSpacingStyles = mapContractVars(
|
|
17
|
+
sys.spacing,
|
|
18
|
+
(key) => ({
|
|
19
|
+
'@layer': {
|
|
20
|
+
[components]: {
|
|
21
|
+
vars: {
|
|
22
|
+
[spaceVar]: sys.spacing[key],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
|
+
|
|
10
29
|
export const menuSeparator = recipe({
|
|
11
30
|
base: {
|
|
12
31
|
paddingBlock: spaceVar,
|
|
@@ -37,18 +56,15 @@ export const menuSeparator = recipe({
|
|
|
37
56
|
},
|
|
38
57
|
},
|
|
39
58
|
|
|
40
|
-
spacing:
|
|
41
|
-
'@layer': {
|
|
42
|
-
[components]: {
|
|
43
|
-
vars: {
|
|
44
|
-
[spaceVar]: sys.spacing[key],
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
})),
|
|
59
|
+
spacing: menuSeparatorSpacingStyles,
|
|
49
60
|
},
|
|
50
61
|
});
|
|
51
62
|
|
|
52
63
|
export type MenuSeparatorVariants = NonNullable<
|
|
53
64
|
RecipeVariants<typeof menuSeparator>
|
|
54
65
|
>;
|
|
66
|
+
|
|
67
|
+
export const spacingAt = createResponsiveVariants({
|
|
68
|
+
styles: menuSeparatorSpacingStyles,
|
|
69
|
+
media: defaultMedia,
|
|
70
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defaultOrder, responsiveRecipe } from '../../styles/responsive';
|
|
2
|
+
|
|
3
|
+
import { menuSeparator, spacingAt } from './menu-separator.css';
|
|
4
|
+
|
|
5
|
+
export const menuSeparatorResponsive = responsiveRecipe({
|
|
6
|
+
recipe: menuSeparator,
|
|
7
|
+
at: { spacing: spacingAt },
|
|
8
|
+
order: defaultOrder,
|
|
9
|
+
});
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import { createVar, globalStyle } from '@vanilla-extract/css';
|
|
2
2
|
import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
createResponsiveVariants,
|
|
6
|
+
defaultMedia,
|
|
7
|
+
sys,
|
|
8
|
+
mapContractVars,
|
|
9
|
+
} from '../../styles';
|
|
5
10
|
import { components } from '../../styles/layers.css';
|
|
6
11
|
|
|
7
12
|
export const sideWidthVar = createVar();
|
|
8
13
|
export const contentMinWidthVar = createVar();
|
|
9
14
|
|
|
15
|
+
// Shared variant styles to support responsive overrides
|
|
16
|
+
export const sidebarSpacingStyles = mapContractVars(sys.spacing, (key) => ({
|
|
17
|
+
'@layer': {
|
|
18
|
+
[components]: {
|
|
19
|
+
gap: sys.spacing[key],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
}));
|
|
23
|
+
|
|
10
24
|
export const sidebarRecipe = recipe({
|
|
11
25
|
base: {
|
|
12
26
|
'@layer': {
|
|
@@ -25,13 +39,7 @@ export const sidebarRecipe = recipe({
|
|
|
25
39
|
/**
|
|
26
40
|
* The spacing between the sidebar and main content elements
|
|
27
41
|
*/
|
|
28
|
-
spacing:
|
|
29
|
-
'@layer': {
|
|
30
|
-
[components]: {
|
|
31
|
-
gap: sys.spacing[key],
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
})),
|
|
42
|
+
spacing: sidebarSpacingStyles,
|
|
35
43
|
|
|
36
44
|
/**
|
|
37
45
|
* Whether the sidebar should stretch to fill the available space
|
|
@@ -100,3 +108,8 @@ globalStyle(`${sidebarRecipe.classNames.variants.side.right} > :first-child`, {
|
|
|
100
108
|
});
|
|
101
109
|
|
|
102
110
|
export type SidebarVariants = NonNullable<RecipeVariants<typeof sidebarRecipe>>;
|
|
111
|
+
|
|
112
|
+
export const spacingAt = createResponsiveVariants({
|
|
113
|
+
styles: sidebarSpacingStyles,
|
|
114
|
+
media: defaultMedia,
|
|
115
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defaultOrder, responsiveRecipe } from '../../styles/responsive';
|
|
2
|
+
|
|
3
|
+
import { sidebarRecipe, spacingAt } from './sidebar.css';
|
|
4
|
+
|
|
5
|
+
export const sidebarResponsive = responsiveRecipe({
|
|
6
|
+
recipe: sidebarRecipe,
|
|
7
|
+
at: { spacing: spacingAt },
|
|
8
|
+
order: defaultOrder,
|
|
9
|
+
});
|
|
@@ -7,13 +7,15 @@ import { ElementType } from 'react';
|
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
contentMinWidthVar,
|
|
10
|
-
sidebarRecipe,
|
|
11
10
|
SidebarVariants,
|
|
12
11
|
sideWidthVar,
|
|
13
12
|
} from './sidebar.css';
|
|
13
|
+
import { sidebarResponsive } from './sidebar.responsive';
|
|
14
|
+
|
|
15
|
+
import type { Responsive } from '../../styles/responsive';
|
|
14
16
|
|
|
15
17
|
type SidebarProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> &
|
|
16
|
-
Omit<SidebarVariants, 'sideWidth'> & {
|
|
18
|
+
Omit<SidebarVariants, 'sideWidth' | 'spacing'> & {
|
|
17
19
|
/**
|
|
18
20
|
* The size of the side element
|
|
19
21
|
*/
|
|
@@ -24,6 +26,7 @@ type SidebarProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> &
|
|
|
24
26
|
* Should be a percentage.
|
|
25
27
|
*/
|
|
26
28
|
contentMinWidth?: string;
|
|
29
|
+
spacing?: Responsive<NonNullable<SidebarVariants['spacing']>>;
|
|
27
30
|
};
|
|
28
31
|
|
|
29
32
|
/**
|
|
@@ -48,7 +51,7 @@ export function Sidebar<TUse extends ElementType>({
|
|
|
48
51
|
return (
|
|
49
52
|
<Comp
|
|
50
53
|
className={clsx(
|
|
51
|
-
|
|
54
|
+
sidebarResponsive({ side, sideWidth: !!sideWidth, spacing, noStretch }),
|
|
52
55
|
className,
|
|
53
56
|
)}
|
|
54
57
|
style={assignInlineVars({
|
|
@@ -3,6 +3,10 @@ import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
|
|
|
3
3
|
|
|
4
4
|
import { sys, mapContractVars } from '../../styles';
|
|
5
5
|
import { components } from '../../styles/layers.css';
|
|
6
|
+
import {
|
|
7
|
+
createResponsiveVariants,
|
|
8
|
+
defaultMedia,
|
|
9
|
+
} from '../../styles/responsive';
|
|
6
10
|
|
|
7
11
|
const spacing = createVar({
|
|
8
12
|
syntax: '<length>',
|
|
@@ -10,6 +14,48 @@ const spacing = createVar({
|
|
|
10
14
|
inherits: false,
|
|
11
15
|
});
|
|
12
16
|
|
|
17
|
+
// Shared variant style maps so we can reuse them for responsive overrides
|
|
18
|
+
export const stackSpacingStyles = mapContractVars(sys.spacing, (key) => ({
|
|
19
|
+
'@layer': {
|
|
20
|
+
[components]: {
|
|
21
|
+
vars: {
|
|
22
|
+
[spacing]: sys.spacing[key],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
export const stackAlignStyles = {
|
|
29
|
+
start: {
|
|
30
|
+
'@layer': {
|
|
31
|
+
[components]: {
|
|
32
|
+
alignItems: 'flex-start',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
center: {
|
|
37
|
+
'@layer': {
|
|
38
|
+
[components]: {
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
end: {
|
|
44
|
+
'@layer': {
|
|
45
|
+
[components]: {
|
|
46
|
+
alignItems: 'flex-end',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
stretch: {
|
|
51
|
+
'@layer': {
|
|
52
|
+
[components]: {
|
|
53
|
+
alignItems: 'stretch',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
} as const;
|
|
58
|
+
|
|
13
59
|
export const stackRecipe = recipe({
|
|
14
60
|
base: {
|
|
15
61
|
'@layer': {
|
|
@@ -26,47 +72,23 @@ export const stackRecipe = recipe({
|
|
|
26
72
|
/**
|
|
27
73
|
* The spacing between items
|
|
28
74
|
*/
|
|
29
|
-
spacing:
|
|
30
|
-
'@layer': {
|
|
31
|
-
[components]: {
|
|
32
|
-
vars: {
|
|
33
|
-
[spacing]: sys.spacing[key],
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
})),
|
|
75
|
+
spacing: stackSpacingStyles,
|
|
38
76
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
alignItems: 'flex-start',
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
center: {
|
|
48
|
-
'@layer': {
|
|
49
|
-
[components]: {
|
|
50
|
-
alignItems: 'center',
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
end: {
|
|
55
|
-
'@layer': {
|
|
56
|
-
[components]: {
|
|
57
|
-
alignItems: 'flex-end',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
stretch: {
|
|
62
|
-
'@layer': {
|
|
63
|
-
[components]: {
|
|
64
|
-
alignItems: 'stretch',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
77
|
+
/**
|
|
78
|
+
* The alignment of items along the cross axis
|
|
79
|
+
*/
|
|
80
|
+
align: stackAlignStyles,
|
|
69
81
|
},
|
|
70
82
|
});
|
|
71
83
|
|
|
72
84
|
export type StackVariants = NonNullable<RecipeVariants<typeof stackRecipe>>;
|
|
85
|
+
|
|
86
|
+
export const spacingAt = createResponsiveVariants({
|
|
87
|
+
styles: stackSpacingStyles,
|
|
88
|
+
media: defaultMedia,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export const alignAt = createResponsiveVariants({
|
|
92
|
+
styles: stackAlignStyles,
|
|
93
|
+
media: defaultMedia,
|
|
94
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defaultOrder, responsiveRecipe } from '../../styles/responsive';
|
|
2
|
+
|
|
3
|
+
import { alignAt, spacingAt, stackRecipe } from './stack.css';
|
|
4
|
+
|
|
5
|
+
export const stackResponsive = responsiveRecipe({
|
|
6
|
+
recipe: stackRecipe,
|
|
7
|
+
at: { spacing: spacingAt, align: alignAt },
|
|
8
|
+
order: defaultOrder,
|
|
9
|
+
});
|