@kalink-ui/seedly 0.34.3 → 0.35.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.
Files changed (144) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +34 -0
  3. package/docs/component-theming.md +295 -0
  4. package/docs/theming-strategy.md +69 -0
  5. package/docs/tone-system.md +139 -0
  6. package/docs/value-and-scope.md +65 -0
  7. package/package.json +4 -3
  8. package/src/components/alert-dialog/alert-dialog-action.tsx +0 -2
  9. package/src/components/alert-dialog/alert-dialog-cancel.tsx +0 -1
  10. package/src/components/alert-dialog/alert-dialog-content.css.ts +1 -1
  11. package/src/components/alert-dialog/alert-dialog-content.tsx +13 -6
  12. package/src/components/alert-dialog/alert-dialog-footer.css.ts +3 -3
  13. package/src/components/alert-dialog/alert-dialog-footer.tsx +2 -2
  14. package/src/components/alert-dialog/alert-dialog-header.tsx +4 -4
  15. package/src/components/alert-dialog/index.ts +9 -0
  16. package/src/components/box/box.css.ts +137 -39
  17. package/src/components/box/box.responsive.ts +2 -2
  18. package/src/components/box/box.tsx +2 -3
  19. package/src/components/box/index.ts +1 -1
  20. package/src/components/button/button.css.ts +142 -149
  21. package/src/components/button/button.responsive.ts +2 -2
  22. package/src/components/button/button.tsx +44 -31
  23. package/src/components/button/index.ts +2 -2
  24. package/src/components/button-icon/button-icon.css.ts +26 -62
  25. package/src/components/button-icon/button-icon.responsive.ts +2 -2
  26. package/src/components/button-icon/button-icon.tsx +5 -7
  27. package/src/components/card/card.css.ts +1 -5
  28. package/src/components/card/card.tsx +11 -11
  29. package/src/components/center/center.css.ts +61 -21
  30. package/src/components/center/center.responsive.ts +2 -2
  31. package/src/components/center/center.tsx +4 -6
  32. package/src/components/center/index.ts +1 -1
  33. package/src/components/cluster/cluster.css.ts +37 -99
  34. package/src/components/cluster/cluster.responsive.ts +13 -2
  35. package/src/components/cluster/cluster.tsx +6 -5
  36. package/src/components/cluster/index.ts +5 -1
  37. package/src/components/command/command-empty.tsx +36 -4
  38. package/src/components/command/command-group.css.ts +23 -7
  39. package/src/components/command/command-group.tsx +30 -6
  40. package/src/components/command/command-input.css.ts +2 -2
  41. package/src/components/command/command-item.tsx +26 -2
  42. package/src/components/command/command-list.css.ts +2 -2
  43. package/src/components/command/command-list.responsive.ts +2 -2
  44. package/src/components/command/command-list.tsx +1 -2
  45. package/src/components/command/command-separator.tsx +7 -5
  46. package/src/components/cover/cover.css.ts +29 -8
  47. package/src/components/cover/cover.tsx +13 -13
  48. package/src/components/cover/index.ts +2 -2
  49. package/src/components/divider/divider.css.ts +9 -4
  50. package/src/components/form-field/form-field-context.ts +3 -0
  51. package/src/components/form-field/form-field-item.tsx +3 -3
  52. package/src/components/form-field/form-field-message.tsx +34 -3
  53. package/src/components/form-field/form-field.css.ts +78 -16
  54. package/src/components/form-field/form-field.tsx +5 -0
  55. package/src/components/form-field/index.ts +1 -1
  56. package/src/components/frame/frame.css.ts +96 -59
  57. package/src/components/frame/frame.responsive.ts +9 -0
  58. package/src/components/frame/frame.tsx +11 -5
  59. package/src/components/frame/index.ts +1 -1
  60. package/src/components/grid/grid-child.tsx +14 -10
  61. package/src/components/grid/grid.css.ts +56 -148
  62. package/src/components/grid/grid.tsx +40 -18
  63. package/src/components/grid/index.ts +4 -3
  64. package/src/components/heading/heading.css.ts +4 -4
  65. package/src/components/heading/heading.responsive.ts +6 -6
  66. package/src/components/heading/heading.tsx +3 -4
  67. package/src/components/heading/index.ts +1 -1
  68. package/src/components/input/index.ts +4 -1
  69. package/src/components/input/input-wrapper.tsx +20 -8
  70. package/src/components/input/input.css.ts +121 -93
  71. package/src/components/input/input.responsive.ts +9 -0
  72. package/src/components/input/input.tsx +7 -1
  73. package/src/components/label/label.css.ts +2 -2
  74. package/src/components/label/label.tsx +23 -3
  75. package/src/components/layout-maps.ts +120 -0
  76. package/src/components/loader/index.ts +2 -1
  77. package/src/components/loader/loader.css.ts +91 -54
  78. package/src/components/loader/moon-loader.responsive.ts +2 -2
  79. package/src/components/loader/moon-loader.tsx +4 -5
  80. package/src/components/loader-overlay/loader-overlay.css.ts +3 -3
  81. package/src/components/loader-overlay/loader-overlay.tsx +5 -2
  82. package/src/components/menu/index.ts +2 -2
  83. package/src/components/menu/menu-item.css.ts +102 -46
  84. package/src/components/menu/menu-separator.css.ts +27 -15
  85. package/src/components/menu/menu-separator.responsive.ts +2 -2
  86. package/src/components/overlay/overlay.css.ts +1 -1
  87. package/src/components/popover/index.ts +1 -1
  88. package/src/components/popover/popover-content.css.ts +69 -52
  89. package/src/components/popover/popover-content.tsx +22 -6
  90. package/src/components/scroll-area/scroll-area.css.ts +3 -3
  91. package/src/components/scroll-area/scroll-bar.tsx +2 -2
  92. package/src/components/select/index.ts +4 -5
  93. package/src/components/select/select-content.css.ts +1 -1
  94. package/src/components/select/select-content.tsx +2 -2
  95. package/src/components/select/select-item.tsx +11 -3
  96. package/src/components/select/select-trigger.css.ts +14 -18
  97. package/src/components/select/select-trigger.tsx +18 -8
  98. package/src/components/select/select.tsx +10 -6
  99. package/src/components/sheet/index.ts +12 -0
  100. package/src/components/sheet/sheet-content.css.ts +2 -2
  101. package/src/components/sheet/sheet-content.tsx +25 -7
  102. package/src/components/sheet/sheet-description.tsx +5 -7
  103. package/src/components/sheet/sheet-footer.tsx +3 -1
  104. package/src/components/sheet/sheet-header.css.ts +1 -1
  105. package/src/components/sheet/sheet-header.tsx +3 -3
  106. package/src/components/sheet/sheet-overlay.tsx +3 -4
  107. package/src/components/sheet/sheet-title.tsx +1 -1
  108. package/src/components/sidebar/index.ts +5 -1
  109. package/src/components/sidebar/sidebar.css.ts +35 -9
  110. package/src/components/sidebar/sidebar.tsx +7 -10
  111. package/src/components/skeleton/skeleton.css.ts +23 -14
  112. package/src/components/skeleton/skeleton.tsx +26 -7
  113. package/src/components/stack/index.ts +1 -1
  114. package/src/components/stack/stack.css.ts +18 -46
  115. package/src/components/stack/stack.tsx +1 -2
  116. package/src/components/switcher/index.ts +5 -1
  117. package/src/components/switcher/switcher.css.ts +105 -72
  118. package/src/components/switcher/switcher.responsive.ts +2 -2
  119. package/src/components/switcher/switcher.tsx +5 -5
  120. package/src/components/text/text.css.ts +93 -105
  121. package/src/components/text/text.responsive.ts +3 -63
  122. package/src/components/text/text.tsx +16 -28
  123. package/src/components/text-field/index.ts +1 -2
  124. package/src/components/text-field/text-field.tsx +5 -7
  125. package/src/components/textarea/textarea-input.tsx +30 -3
  126. package/src/components/textarea/textarea.css.ts +12 -7
  127. package/src/components/textarea/textarea.tsx +9 -3
  128. package/src/components/visually-hidden/visually-hidden.css.ts +16 -10
  129. package/src/styles/define-responsive-properties.ts +5 -1
  130. package/src/styles/index.ts +12 -0
  131. package/src/styles/responsive.ts +72 -43
  132. package/src/styles/system-contract.css.ts +22 -3
  133. package/src/styles/theme/sprout-ref.css.ts +107 -0
  134. package/src/styles/theme/sprout.css.ts +259 -0
  135. package/src/styles/tone.ts +69 -0
  136. package/src/styles/typography.responsive.css.ts +35 -0
  137. package/src/styles/typography.responsive.ts +104 -0
  138. package/src/utils/arg-types/index.ts +1 -0
  139. package/src/utils/arg-types/responsive-arg.ts +28 -0
  140. package/src/utils/index.ts +1 -0
  141. package/src/components/command/command-item.css.ts +0 -32
  142. package/src/components/select/select.css.ts +0 -3
  143. package/src/components/sheet/sheet-body.css.ts +0 -68
  144. package/src/components/text-field/text-field.css.ts +0 -3
@@ -4,6 +4,8 @@ import { useState, useCallback, ReactNode } from 'react';
4
4
 
5
5
  import { FormFieldContextProvider } from './form-field-context';
6
6
 
7
+ import type { Tone } from '../../styles';
8
+
7
9
  export interface FormFieldProps {
8
10
  name: string;
9
11
  label: string;
@@ -12,6 +14,7 @@ export interface FormFieldProps {
12
14
  hideErrorMessage: boolean;
13
15
  hideLabel: boolean;
14
16
  disabled?: boolean;
17
+ tone?: Tone;
15
18
  }
16
19
 
17
20
  export function FormField({
@@ -22,6 +25,7 @@ export function FormField({
22
25
  hideErrorMessage = false,
23
26
  hideLabel = false,
24
27
  disabled,
28
+ tone,
25
29
  }: FormFieldProps) {
26
30
  const [messageIds, setMessageIds] = useState<string[]>([]);
27
31
 
@@ -48,6 +52,7 @@ export function FormField({
48
52
  label,
49
53
  disabled,
50
54
  hideLabel,
55
+ tone,
51
56
  }}
52
57
  >
53
58
  {children}
@@ -1,6 +1,6 @@
1
1
  export { useFormFieldContext } from './form-field-context';
2
2
  export { useFormFieldItemContext } from './form-field-item-context';
3
- export { formFieldStyle, formFieldVars } from './form-field.css';
3
+ export { formFieldRecipe, formFieldVars } from './form-field.css';
4
4
  export { FormFieldControl } from './form-field-control';
5
5
  export { FormFieldDescription } from './form-field-description';
6
6
  export { FormFieldError } from './form-field-error';
@@ -1,9 +1,92 @@
1
- import { createVar, globalStyle, style } from '@vanilla-extract/css';
1
+ import {
2
+ assignVars,
3
+ createThemeContract,
4
+ globalStyle,
5
+ style,
6
+ } from '@vanilla-extract/css';
2
7
  import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
3
8
 
9
+ import { createResponsiveVariants, defaultMedia } from '../../styles';
4
10
  import { components } from '../../styles/layers.css';
5
11
 
6
- export const frameRatioVar = createVar();
12
+ export const frameVars = createThemeContract({
13
+ layout: {
14
+ ratio: null,
15
+ },
16
+ });
17
+
18
+ const frameLayoutDefaults = assignVars(frameVars.layout, {
19
+ ratio: 'auto',
20
+ });
21
+
22
+ export const frameRatioStyles = {
23
+ '1:1': {
24
+ '@layer': {
25
+ [components]: {
26
+ vars: {
27
+ ...assignVars(frameVars.layout, {
28
+ ratio: '1 / 1',
29
+ }),
30
+ },
31
+ },
32
+ },
33
+ },
34
+ '3:2': {
35
+ '@layer': {
36
+ [components]: {
37
+ vars: {
38
+ ...assignVars(frameVars.layout, {
39
+ ratio: '3 / 2',
40
+ }),
41
+ },
42
+ },
43
+ },
44
+ },
45
+ '2:3': {
46
+ '@layer': {
47
+ [components]: {
48
+ vars: {
49
+ ...assignVars(frameVars.layout, {
50
+ ratio: '2 / 3',
51
+ }),
52
+ },
53
+ },
54
+ },
55
+ },
56
+ '4:3': {
57
+ '@layer': {
58
+ [components]: {
59
+ vars: {
60
+ ...assignVars(frameVars.layout, {
61
+ ratio: '4 / 3',
62
+ }),
63
+ },
64
+ },
65
+ },
66
+ },
67
+ '16:9': {
68
+ '@layer': {
69
+ [components]: {
70
+ vars: {
71
+ ...assignVars(frameVars.layout, {
72
+ ratio: '16 / 9',
73
+ }),
74
+ },
75
+ },
76
+ },
77
+ },
78
+ '9:16': {
79
+ '@layer': {
80
+ [components]: {
81
+ vars: {
82
+ ...assignVars(frameVars.layout, {
83
+ ratio: '9 / 16',
84
+ }),
85
+ },
86
+ },
87
+ },
88
+ },
89
+ } as const;
7
90
 
8
91
  const baseFrame = style({
9
92
  '@layer': {
@@ -14,7 +97,11 @@ const baseFrame = style({
14
97
 
15
98
  overflow: 'hidden',
16
99
 
17
- aspectRatio: frameRatioVar,
100
+ aspectRatio: frameVars.layout.ratio,
101
+
102
+ vars: {
103
+ ...frameLayoutDefaults,
104
+ },
18
105
  },
19
106
  },
20
107
  });
@@ -26,62 +113,7 @@ export const frameRecipe = recipe({
26
113
  /**
27
114
  * The ratio of the frame
28
115
  */
29
- ratio: {
30
- '1:1': {
31
- '@layer': {
32
- [components]: {
33
- vars: {
34
- [frameRatioVar]: '1 / 1',
35
- },
36
- },
37
- },
38
- },
39
- '3:2': {
40
- '@layer': {
41
- [components]: {
42
- vars: {
43
- [frameRatioVar]: '3 / 2',
44
- },
45
- },
46
- },
47
- },
48
- '2:3': {
49
- '@layer': {
50
- [components]: {
51
- vars: {
52
- [frameRatioVar]: '2 / 3',
53
- },
54
- },
55
- },
56
- },
57
- '4:3': {
58
- '@layer': {
59
- [components]: {
60
- vars: {
61
- [frameRatioVar]: '4 / 3',
62
- },
63
- },
64
- },
65
- },
66
- '16:9': {
67
- '@layer': {
68
- [components]: {
69
- vars: {
70
- [frameRatioVar]: '16 / 9',
71
- },
72
- },
73
- },
74
- },
75
- '9:16': {
76
- '@layer': {
77
- [components]: {
78
- vars: {
79
- [frameRatioVar]: '9 / 16',
80
- },
81
- },
82
- },
83
- },
84
- },
116
+ ratio: frameRatioStyles,
85
117
  },
86
118
  });
87
119
 
@@ -96,3 +128,8 @@ globalStyle(`${baseFrame} > img, ${baseFrame} > video`, {
96
128
  });
97
129
 
98
130
  export type FrameVariants = NonNullable<RecipeVariants<typeof frameRecipe>>;
131
+
132
+ export const ratioAt = createResponsiveVariants({
133
+ styles: frameRatioStyles,
134
+ media: defaultMedia,
135
+ });
@@ -0,0 +1,9 @@
1
+ import { defaultOrder, responsiveRecipe } from '../../styles/responsive';
2
+
3
+ import { frameRecipe, ratioAt } from './frame.css';
4
+
5
+ export const frameResponsive = responsiveRecipe({
6
+ recipe: frameRecipe,
7
+ at: { ratio: ratioAt },
8
+ order: defaultOrder,
9
+ });
@@ -1,19 +1,25 @@
1
1
  import { PolymorphicComponentProps } from '@kalink-ui/dibbly';
2
- import { clsx } from 'clsx';
3
2
  import { ElementType } from 'react';
4
3
 
5
- import { frameRecipe, FrameVariants } from './frame.css';
4
+ import { FrameVariants } from './frame.css';
5
+ import { frameResponsive } from './frame.responsive';
6
+
7
+ import type { Responsive } from '../../styles/responsive';
6
8
 
7
9
  type FrameProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> &
8
- FrameVariants;
10
+ Omit<FrameVariants, 'ratio'> & {
11
+ ratio?: Responsive<NonNullable<FrameVariants['ratio']>>;
12
+ };
9
13
 
10
14
  /**
11
15
  * A custom element for augmenting image ratios
12
16
  *
13
17
  * https://every-layout.dev/layouts/frame
14
18
  */
15
- export function Frame<TUse extends ElementType>(props: FrameProps<TUse>) {
19
+ export function Frame<TUse extends ElementType = 'div'>(
20
+ props: FrameProps<TUse>,
21
+ ) {
16
22
  const { use: Comp = 'div', className, ratio, ...rest } = props;
17
23
 
18
- return <Comp className={clsx(frameRecipe({ ratio }), className)} {...rest} />;
24
+ return <Comp className={frameResponsive({ ratio }, className)} {...rest} />;
19
25
  }
@@ -1,2 +1,2 @@
1
1
  export { Frame } from './frame';
2
- export { frameRecipe, frameRatioVar, type FrameVariants } from './frame.css';
2
+ export { frameRecipe, frameVars, type FrameVariants } from './frame.css';
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
 
3
3
  import { PolymorphicComponentProps } from '@kalink-ui/dibbly';
4
- import { clsx } from 'clsx';
5
4
  import { ElementType } from 'react';
6
5
 
7
6
  import { gridChildResponsive } from './grid-child.responsive';
@@ -9,13 +8,18 @@ import { gridChildResponsive } from './grid-child.responsive';
9
8
  import type { GridChildVariants } from './grid-child.css';
10
9
  import type { Responsive } from '../../styles/responsive';
11
10
 
12
- type GridChildVariantResponsive = {
13
- [K in keyof GridChildVariants]?: Responsive<
14
- NonNullable<GridChildVariants[K]>
15
- >;
16
- };
11
+ interface GridChildVariantResponsive {
12
+ colSpan?: Responsive<NonNullable<GridChildVariants['colSpan']>>;
13
+ rowSpan?: Responsive<NonNullable<GridChildVariants['rowSpan']>>;
14
+ colStart?: Responsive<NonNullable<GridChildVariants['colStart']>>;
15
+ colEnd?: Responsive<NonNullable<GridChildVariants['colEnd']>>;
16
+ rowStart?: Responsive<NonNullable<GridChildVariants['rowStart']>>;
17
+ rowEnd?: Responsive<NonNullable<GridChildVariants['rowEnd']>>;
18
+ justifySelf?: Responsive<NonNullable<GridChildVariants['justifySelf']>>;
19
+ alignSelf?: Responsive<NonNullable<GridChildVariants['alignSelf']>>;
20
+ }
17
21
 
18
- type GridChildProps<TUse extends ElementType> =
22
+ export type GridChildProps<TUse extends ElementType> =
19
23
  PolymorphicComponentProps<TUse> & GridChildVariantResponsive;
20
24
 
21
25
  export function GridChild<TUse extends ElementType>({
@@ -38,8 +42,8 @@ export function GridChild<TUse extends ElementType>({
38
42
 
39
43
  return (
40
44
  <Comp
41
- className={clsx(
42
- gridChildResponsive({
45
+ className={gridChildResponsive(
46
+ {
43
47
  colSpan,
44
48
  rowSpan,
45
49
  colStart,
@@ -48,7 +52,7 @@ export function GridChild<TUse extends ElementType>({
48
52
  rowEnd,
49
53
  justifySelf,
50
54
  alignSelf,
51
- }),
55
+ },
52
56
  className,
53
57
  )}
54
58
  {...(domProps as Record<string, unknown>)}
@@ -1,157 +1,65 @@
1
- import { createVar, type StyleRule } from '@vanilla-extract/css';
1
+ import {
2
+ assignVars,
3
+ createThemeContract,
4
+ type StyleRule,
5
+ } from '@vanilla-extract/css';
2
6
  import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
3
7
 
4
- import {
5
- createResponsiveVariants,
6
- defaultMedia,
7
- mapContractVars,
8
- sys,
9
- } from '../../styles';
8
+ import { createResponsiveVariants, defaultMedia, sys } from '../../styles';
10
9
  import { components } from '../../styles/layers.css';
10
+ import {
11
+ createSpacingVarStyles,
12
+ gridAlignContentStyles,
13
+ gridAlignItemsStyles,
14
+ gridJustifyContentStyles,
15
+ gridJustifyItemsStyles,
16
+ } from '../layout-maps';
11
17
 
12
- export const minSizeVar = createVar();
13
-
14
- // Shared variant style maps so we can reuse them for responsive overrides
15
- export const gridSpacingStyles = mapContractVars(sys.spacing, (key) => ({
16
- '@layer': {
17
- [components]: {
18
- gap: sys.spacing[key],
19
- },
18
+ export const gridVars = createThemeContract({
19
+ spacing: {
20
+ gap: null,
20
21
  },
21
- }));
22
-
23
- export const gridColumnSpacingStyles = mapContractVars(sys.spacing, (key) => ({
24
- '@layer': {
25
- [components]: {
26
- columnGap: sys.spacing[key],
27
- },
22
+ columnSpacing: {
23
+ gap: null,
28
24
  },
29
- }));
30
-
31
- export const gridRowSpacingStyles = mapContractVars(sys.spacing, (key) => ({
32
- '@layer': {
33
- [components]: {
34
- rowGap: sys.spacing[key],
35
- },
25
+ rowSpacing: {
26
+ gap: null,
36
27
  },
37
- }));
38
-
39
- export const gridJustifyItemsStyles = {
40
- start: {
41
- '@layer': {
42
- [components]: { justifyItems: 'start' },
43
- },
44
- },
45
- end: {
46
- '@layer': {
47
- [components]: { justifyItems: 'end' },
48
- },
28
+ layout: {
29
+ minCellSize: null,
49
30
  },
50
- center: {
51
- '@layer': {
52
- [components]: { justifyItems: 'center' },
53
- },
54
- },
55
- stretch: {
56
- '@layer': {
57
- [components]: { justifyItems: 'stretch' },
58
- },
59
- },
60
- } as const;
31
+ });
61
32
 
62
- export const gridAlignItemsStyles = {
63
- start: {
64
- '@layer': {
65
- [components]: { alignItems: 'start' },
66
- },
67
- },
68
- end: {
69
- '@layer': {
70
- [components]: { alignItems: 'end' },
71
- },
72
- },
73
- center: {
74
- '@layer': {
75
- [components]: { alignItems: 'center' },
76
- },
77
- },
78
- stretch: {
79
- '@layer': {
80
- [components]: { alignItems: 'stretch' },
81
- },
82
- },
83
- } as const;
33
+ const gridSpacingDefaults = assignVars(gridVars.spacing, {
34
+ gap: sys.spacing[0],
35
+ });
84
36
 
85
- export const gridJustifyContentStyles = {
86
- start: {
87
- '@layer': {
88
- [components]: { justifyContent: 'start' },
89
- },
90
- },
91
- end: {
92
- '@layer': {
93
- [components]: { justifyContent: 'end' },
94
- },
95
- },
96
- center: {
97
- '@layer': {
98
- [components]: { justifyContent: 'center' },
99
- },
100
- },
101
- spaceBetween: {
102
- '@layer': {
103
- [components]: { justifyContent: 'space-between' },
104
- },
105
- },
106
- spaceAround: {
107
- '@layer': {
108
- [components]: { justifyContent: 'space-around' },
109
- },
110
- },
111
- spaceEvenly: {
112
- '@layer': {
113
- [components]: { justifyContent: 'space-evenly' },
114
- },
115
- },
116
- } as const;
37
+ const gridLayoutDefaults = assignVars(gridVars.layout, {
38
+ minCellSize: '250px',
39
+ });
117
40
 
118
- export const gridAlignContentStyles = {
119
- start: {
120
- '@layer': {
121
- [components]: { alignContent: 'start' },
122
- },
123
- },
124
- end: {
125
- '@layer': {
126
- [components]: { alignContent: 'end' },
127
- },
128
- },
129
- center: {
130
- '@layer': {
131
- [components]: { alignContent: 'center' },
132
- },
133
- },
134
- spaceBetween: {
135
- '@layer': {
136
- [components]: { alignContent: 'space-between' },
137
- },
138
- },
139
- spaceAround: {
140
- '@layer': {
141
- [components]: { alignContent: 'space-around' },
142
- },
143
- },
144
- spaceEvenly: {
145
- '@layer': {
146
- [components]: { alignContent: 'space-evenly' },
147
- },
148
- },
149
- stretch: {
150
- '@layer': {
151
- [components]: { alignContent: 'stretch' },
152
- },
153
- },
154
- } as const;
41
+ // Shared variant style maps so we can reuse them for responsive overrides
42
+ export const gridSpacingStyles = createSpacingVarStyles(
43
+ gridVars.spacing,
44
+ 'gap',
45
+ );
46
+
47
+ export const gridColumnSpacingStyles = createSpacingVarStyles(
48
+ gridVars.columnSpacing,
49
+ 'columnGap',
50
+ );
51
+
52
+ export const gridRowSpacingStyles = createSpacingVarStyles(
53
+ gridVars.rowSpacing,
54
+ 'rowGap',
55
+ );
56
+
57
+ export {
58
+ gridAlignContentStyles,
59
+ gridAlignItemsStyles,
60
+ gridJustifyContentStyles,
61
+ gridJustifyItemsStyles,
62
+ };
155
63
 
156
64
  const columnCountValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] as const;
157
65
  type ColumnCount = (typeof columnCountValues)[number];
@@ -176,14 +84,14 @@ export const autoLayoutStyles = {
176
84
  fill: {
177
85
  '@layer': {
178
86
  [components]: {
179
- gridTemplateColumns: `repeat(auto-fill, minmax(min(${minSizeVar}, 100%), 1fr))`,
87
+ gridTemplateColumns: `repeat(auto-fill, minmax(min(${gridVars.layout.minCellSize}, 100%), 1fr))`,
180
88
  },
181
89
  },
182
90
  },
183
91
  fit: {
184
92
  '@layer': {
185
93
  [components]: {
186
- gridTemplateColumns: `repeat(auto-fit, minmax(min(${minSizeVar}, 100%), 1fr))`,
94
+ gridTemplateColumns: `repeat(auto-fit, minmax(min(${gridVars.layout.minCellSize}, 100%), 1fr))`,
187
95
  },
188
96
  },
189
97
  },
@@ -194,9 +102,11 @@ export const gridRecipe = recipe({
194
102
  '@layer': {
195
103
  [components]: {
196
104
  display: 'grid',
105
+ gap: gridVars.spacing.gap,
197
106
 
198
107
  vars: {
199
- [minSizeVar]: '250px',
108
+ ...gridSpacingDefaults,
109
+ ...gridLayoutDefaults,
200
110
  },
201
111
  },
202
112
  },
@@ -257,8 +167,6 @@ export const spacingAt = createResponsiveVariants({
257
167
  media: defaultMedia,
258
168
  });
259
169
 
260
- // gridFitStyles now declared above for reuse
261
-
262
170
  export const columnSpacingAt = createResponsiveVariants({
263
171
  styles: gridColumnSpacingStyles,
264
172
  media: defaultMedia,
@@ -2,25 +2,35 @@
2
2
 
3
3
  import { PolymorphicComponentProps } from '@kalink-ui/dibbly';
4
4
  import { assignInlineVars } from '@vanilla-extract/dynamic';
5
- import { clsx } from 'clsx';
6
5
  import { ElementType } from 'react';
7
6
 
8
- import { GridVariants, minSizeVar } from './grid.css';
7
+ import { defaultOrder, resolveResponsive } from '../../styles/responsive';
8
+
9
+ import { gridVars, GridVariants } from './grid.css';
9
10
  import { gridResponsive } from './grid.responsive';
10
11
 
11
12
  import type { Responsive } from '../../styles/responsive';
12
13
 
13
- type GridVariantResponsive = {
14
- [K in keyof GridVariants]?: Responsive<NonNullable<GridVariants[K]>>;
15
- };
14
+ interface GridVariantResponsive {
15
+ spacing?: Responsive<NonNullable<GridVariants['spacing']>>;
16
+ columnSpacing?: Responsive<NonNullable<GridVariants['columnSpacing']>>;
17
+ rowSpacing?: Responsive<NonNullable<GridVariants['rowSpacing']>>;
18
+ columns?: Responsive<NonNullable<GridVariants['columns']>>;
19
+ autoLayout?: Responsive<NonNullable<GridVariants['autoLayout']>>;
20
+ justifyItems?: Responsive<NonNullable<GridVariants['justifyItems']>>;
21
+ alignItems?: Responsive<NonNullable<GridVariants['alignItems']>>;
22
+ justifyContent?: Responsive<NonNullable<GridVariants['justifyContent']>>;
23
+ alignContent?: Responsive<NonNullable<GridVariants['alignContent']>>;
24
+ }
16
25
 
17
- type GridProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> &
18
- GridVariantResponsive & {
19
- /**
20
- * The minimum size of a grid cell
21
- */
22
- minSize?: string;
23
- };
26
+ export type GridProps<TUse extends ElementType> =
27
+ PolymorphicComponentProps<TUse> &
28
+ GridVariantResponsive & {
29
+ /**
30
+ * The minimum size of a grid cell
31
+ */
32
+ minSize?: string;
33
+ };
24
34
 
25
35
  /**
26
36
  * The Grid layout provides a flexible, responsive grid system. It can also
@@ -30,7 +40,7 @@ type GridProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> &
30
40
  *
31
41
  * https://every-layout.dev/layouts/grid/
32
42
  */
33
- export function Grid<TUse extends ElementType>(props: GridProps<TUse>) {
43
+ export function Grid<TUse extends ElementType = 'div'>(props: GridProps<TUse>) {
34
44
  const {
35
45
  use: Comp = 'div',
36
46
  minSize,
@@ -47,24 +57,36 @@ export function Grid<TUse extends ElementType>(props: GridProps<TUse>) {
47
57
  ...rest
48
58
  } = props;
49
59
 
60
+ const autoLayoutMap = resolveResponsive(autoLayout, defaultOrder);
61
+ const columnsMap = resolveResponsive(columns, defaultOrder);
62
+ const columnsEntries = Object.entries(columnsMap).filter(
63
+ ([breakpoint]) =>
64
+ autoLayoutMap[breakpoint as keyof typeof autoLayoutMap] == null,
65
+ );
66
+ const columnsForLayout = columnsEntries.length
67
+ ? (Object.fromEntries(columnsEntries) as Responsive<
68
+ NonNullable<GridVariants['columns']>
69
+ >)
70
+ : undefined;
71
+
50
72
  return (
51
73
  <Comp
52
- className={clsx(
53
- gridResponsive({
74
+ className={gridResponsive(
75
+ {
54
76
  spacing,
55
77
  columnSpacing,
56
78
  rowSpacing,
57
- columns: autoLayout ? undefined : columns,
79
+ columns: columnsForLayout,
58
80
  autoLayout,
59
81
  justifyItems,
60
82
  alignItems,
61
83
  justifyContent,
62
84
  alignContent,
63
- }),
85
+ },
64
86
  className,
65
87
  )}
66
88
  style={assignInlineVars({
67
- ...(minSize && { [minSizeVar]: minSize }),
89
+ ...(minSize && { [gridVars.layout.minCellSize]: minSize }),
68
90
  })}
69
91
  {...(rest as Record<string, unknown>)}
70
92
  />
@@ -1,3 +1,4 @@
1
- export { Grid } from './grid';
2
- export { GridChild } from './grid-child';
3
- export { gridRecipe, type GridVariants } from './grid.css';
1
+ export { Grid, type GridProps } from './grid';
2
+ export { GridChild, type GridChildProps } from './grid-child';
3
+ export { gridRecipe, gridVars, type GridVariants } from './grid.css';
4
+ export type { GridChildVariants } from './grid-child.css';