@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
@@ -43,7 +43,7 @@ export const headingAlignStyles = {
43
43
  },
44
44
  } as const;
45
45
 
46
- export const headingRoot = recipe({
46
+ export const headingRootRecipe = recipe({
47
47
  base: {
48
48
  '@layer': {
49
49
  [components]: {
@@ -66,7 +66,7 @@ export const pretitleSpacingStyles = mapContractVars(sys.spacing, (key) => ({
66
66
  },
67
67
  }));
68
68
 
69
- export const pretitle = recipe({
69
+ export const pretitleRecipe = recipe({
70
70
  variants: {
71
71
  spacing: pretitleSpacingStyles,
72
72
  },
@@ -80,14 +80,14 @@ export const subtitleSpacingStyles = mapContractVars(sys.spacing, (key) => ({
80
80
  },
81
81
  }));
82
82
 
83
- export const subtitle = recipe({
83
+ export const subtitleRecipe = recipe({
84
84
  variants: {
85
85
  spacing: subtitleSpacingStyles,
86
86
  },
87
87
  });
88
88
 
89
89
  export type HeadingRootVariants = NonNullable<
90
- RecipeVariants<typeof headingRoot>
90
+ RecipeVariants<typeof headingRootRecipe>
91
91
  >;
92
92
 
93
93
  export const alignAt = createResponsiveVariants({
@@ -2,27 +2,27 @@ import { defaultOrder, responsiveRecipe } from '../../styles/responsive';
2
2
 
3
3
  import {
4
4
  alignAt,
5
- headingRoot,
6
- pretitle,
5
+ headingRootRecipe,
6
+ pretitleRecipe,
7
7
  pretitleSpacingAt,
8
- subtitle,
8
+ subtitleRecipe,
9
9
  subtitleSpacingAt,
10
10
  } from './heading.css';
11
11
 
12
12
  export const headingRootResponsive = responsiveRecipe({
13
- recipe: headingRoot,
13
+ recipe: headingRootRecipe,
14
14
  at: { align: alignAt },
15
15
  order: defaultOrder,
16
16
  });
17
17
 
18
18
  export const pretitleResponsive = responsiveRecipe({
19
- recipe: pretitle,
19
+ recipe: pretitleRecipe,
20
20
  at: { spacing: pretitleSpacingAt },
21
21
  order: defaultOrder,
22
22
  });
23
23
 
24
24
  export const subtitleResponsive = responsiveRecipe({
25
- recipe: subtitle,
25
+ recipe: subtitleRecipe,
26
26
  at: { spacing: subtitleSpacingAt },
27
27
  order: defaultOrder,
28
28
  });
@@ -1,5 +1,4 @@
1
1
  import { PolymorphicComponentProps } from '@kalink-ui/dibbly';
2
- import { clsx } from 'clsx';
3
2
  import { ElementType, ReactElement, ReactNode } from 'react';
4
3
 
5
4
  import { Spacing, TypographySize, TypographyVariant } from '../../styles';
@@ -84,7 +83,7 @@ export function Heading<TUse extends HeadingTypes>(props: HeadingProps<TUse>) {
84
83
  ref={ref}
85
84
  use={'hgroup'}
86
85
  condition={!!pretitle || !!subtitle}
87
- className={clsx(headingRootResponsive({ align }), rootClassName)}
86
+ className={headingRootResponsive({ align }, rootClassName)}
88
87
  >
89
88
  {pretitle}
90
89
 
@@ -123,7 +122,7 @@ Heading.Pretitle = function HeadingPretitle({
123
122
  use="p"
124
123
  variant={variant}
125
124
  size={size}
126
- className={clsx(pretitleResponsive({ spacing }), className)}
125
+ className={pretitleResponsive({ spacing }, className)}
127
126
  {...rest}
128
127
  >
129
128
  {children}
@@ -151,7 +150,7 @@ Heading.Subtitle = function HeadingSubtitle({
151
150
  use="p"
152
151
  variant={variant}
153
152
  size={size}
154
- className={clsx(subtitleResponsive({ spacing }), className)}
153
+ className={subtitleResponsive({ spacing }, className)}
155
154
  {...rest}
156
155
  >
157
156
  {children}
@@ -5,4 +5,4 @@ export {
5
5
  type HeadingSubtitleProps,
6
6
  type HeadingPretitleProps,
7
7
  } from './heading';
8
- export { headingRoot, type HeadingRootVariants } from './heading.css';
8
+ export { headingRootRecipe, type HeadingRootVariants } from './heading.css';
@@ -1,2 +1,5 @@
1
1
  export { Input, type InputProps } from './input';
2
- export { inputAppearance, type InputAppearanceVariants } from './input.css';
2
+ export {
3
+ inputAppearanceRecipe,
4
+ type InputAppearanceVariants,
5
+ } from './input.css';
@@ -1,4 +1,3 @@
1
- import { clsx } from 'clsx';
2
1
  import {
3
2
  ComponentPropsWithRef,
4
3
  ForwardedRef,
@@ -9,17 +8,22 @@ import {
9
8
  } from 'react';
10
9
 
11
10
  import {
12
- inputAppearance,
13
- InputAppearanceVariants,
14
- inputWrapper,
15
- } from './input.css';
11
+ buildTypographyOverrides,
12
+ mapResponsiveSizeToTypography,
13
+ type Responsive,
14
+ } from '../../styles';
15
+
16
+ import { InputAppearanceVariants, inputWrapper } from './input.css';
17
+ import { inputAppearanceResponsive } from './input.responsive';
16
18
 
17
19
  export type InputWrapperProps = ComponentPropsWithRef<'div'> & {
18
20
  children: ReactNode;
19
21
  className?: string;
20
22
  inputRef: RefObject<HTMLInputElement | null>;
21
23
  disabled?: boolean;
22
- } & InputAppearanceVariants;
24
+ } & Omit<InputAppearanceVariants, 'size'> & {
25
+ size?: Responsive<NonNullable<InputAppearanceVariants['size']>>;
26
+ };
23
27
 
24
28
  export function InputWrapper({
25
29
  children,
@@ -28,8 +32,15 @@ export function InputWrapper({
28
32
  disabled,
29
33
  variant = 'outlined',
30
34
  size = 'md',
35
+ tone = 'neutral',
31
36
  ref,
32
37
  }: InputWrapperProps) {
38
+ const typographySize = mapResponsiveSizeToTypography(size);
39
+ const typographyOverrides = buildTypographyOverrides({
40
+ variant: 'body',
41
+ size: typographySize,
42
+ });
43
+
33
44
  const handleInputFocus = useCallback<MouseEventHandler<HTMLElement>>(
34
45
  (e) => {
35
46
  if (disabled || !inputRef?.current || e.target === inputRef.current) {
@@ -45,8 +56,9 @@ export function InputWrapper({
45
56
  return (
46
57
  <div
47
58
  ref={ref as ForwardedRef<HTMLDivElement>}
48
- className={clsx(
49
- inputAppearance({ variant, size }),
59
+ className={inputAppearanceResponsive(
60
+ { variant, size, tone },
61
+ typographyOverrides,
50
62
  inputWrapper,
51
63
  className,
52
64
  )}
@@ -3,13 +3,19 @@ import {
3
3
  globalStyle,
4
4
  createThemeContract,
5
5
  assignVars,
6
- fallbackVar,
6
+ type StyleRule,
7
7
  } from '@vanilla-extract/css';
8
8
  import { recipe, RecipeVariants } from '@vanilla-extract/recipes';
9
9
 
10
- import { sys, transition, typography } from '../../styles';
10
+ import {
11
+ createToneAssignments,
12
+ createToneStyles,
13
+ createResponsiveVariants,
14
+ defaultMedia,
15
+ sys,
16
+ transition,
17
+ } from '../../styles';
11
18
  import { components } from '../../styles/layers.css';
12
- import { formFieldVars } from '../form-field';
13
19
 
14
20
  export const inputVars = createThemeContract({
15
21
  color: {
@@ -28,7 +34,95 @@ export const inputVars = createThemeContract({
28
34
  },
29
35
  });
30
36
 
31
- export const inputAppearance = recipe({
37
+ const inputToneVars = createThemeContract({
38
+ base: null,
39
+ onBase: null,
40
+ });
41
+
42
+ const inputColorDefaults = assignVars(inputVars.color, {
43
+ foreground: sys.surface.foreground,
44
+ background: sys.surface.background,
45
+ outline: sys.surface.foreground,
46
+ });
47
+
48
+ const inputToneAssignments = createToneAssignments(inputToneVars);
49
+ const inputToneDefaults = inputToneAssignments.neutral;
50
+
51
+ const inputToneStyles = createToneStyles(inputToneVars, ({ base }) => ({
52
+ ...inputColorDefaults,
53
+ [inputVars.color.foreground]: base,
54
+ [inputVars.color.outline]: base,
55
+ }));
56
+
57
+ const inputSizeStyles = {
58
+ sm: {
59
+ '@layer': {
60
+ [components]: {
61
+ fontFamily: sys.typography.body.small.font,
62
+ fontWeight: sys.typography.body.small.weight,
63
+ lineHeight: sys.typography.body.small.lineHeight,
64
+ letterSpacing: sys.typography.body.small.tracking,
65
+ /**
66
+ * Force the font size to 16px to avoid zooming on mobile
67
+ */
68
+ fontSize: `max(16px, ${sys.typography.body.small.size})`,
69
+
70
+ vars: {
71
+ ...assignVars(inputVars.spacing, {
72
+ block: sys.spacing[1],
73
+ inline: sys.spacing[1],
74
+ }),
75
+ },
76
+ },
77
+ },
78
+ },
79
+
80
+ md: {
81
+ '@layer': {
82
+ [components]: {
83
+ fontFamily: sys.typography.body.medium.font,
84
+ fontWeight: sys.typography.body.medium.weight,
85
+ lineHeight: sys.typography.body.medium.lineHeight,
86
+ letterSpacing: sys.typography.body.medium.tracking,
87
+ /**
88
+ * Force the font size to 16px to avoid zooming on mobile
89
+ */
90
+ fontSize: `max(16px, ${sys.typography.body.medium.size})`,
91
+
92
+ vars: {
93
+ ...assignVars(inputVars.spacing, {
94
+ block: sys.spacing[2],
95
+ inline: sys.spacing[2],
96
+ }),
97
+ },
98
+ },
99
+ },
100
+ },
101
+
102
+ lg: {
103
+ '@layer': {
104
+ [components]: {
105
+ fontFamily: sys.typography.body.large.font,
106
+ fontWeight: sys.typography.body.large.weight,
107
+ lineHeight: sys.typography.body.large.lineHeight,
108
+ letterSpacing: sys.typography.body.large.tracking,
109
+ /**
110
+ * Force the font size to 16px to avoid zooming on mobile
111
+ */
112
+ fontSize: `max(16px, ${sys.typography.body.large.size})`,
113
+
114
+ vars: {
115
+ ...assignVars(inputVars.spacing, {
116
+ block: sys.spacing[3],
117
+ inline: sys.spacing[3],
118
+ }),
119
+ },
120
+ },
121
+ },
122
+ },
123
+ } satisfies Record<'sm' | 'md' | 'lg', StyleRule | StyleRule[]>;
124
+
125
+ export const inputAppearanceRecipe = recipe({
32
126
  base: [
33
127
  {
34
128
  '@layer': {
@@ -52,11 +146,13 @@ export const inputAppearance = recipe({
52
146
 
53
147
  selectors: {
54
148
  '&:disabled, &:has(:disabled)': {
55
- backgroundColor: `color-mix(in srgb, ${inputVars.color.foreground} calc(${sys.state.muted.dark} * 100%), transparent)`,
149
+ backgroundColor: `color-mix(in srgb, ${inputToneVars.base} calc(${sys.state.disabled.background} * 100%), transparent)`,
56
150
 
57
151
  vars: {
58
152
  [inputVars.color.foreground]:
59
- `color(from ${sys.color.foreground} srgb r g b / 0.38)`,
153
+ `color-mix(in srgb, ${inputToneVars.base} calc(${sys.state.disabled.text} * 100%), transparent)`,
154
+ [inputVars.color.outline]:
155
+ `color-mix(in srgb, ${inputToneVars.base} calc(${sys.state.disabled.border} * 100%), transparent)`,
60
156
  },
61
157
  },
62
158
 
@@ -67,36 +163,23 @@ export const inputAppearance = recipe({
67
163
 
68
164
  '&[aria-invalid], &:has([aria-invalid])': {
69
165
  vars: {
70
- [inputVars.color.foreground]: fallbackVar(
71
- formFieldVars.color.foreground,
72
- 'red',
73
- ),
166
+ ...inputColorDefaults,
167
+ [inputVars.color.foreground]: sys.tone.destructive,
168
+ [inputVars.color.outline]: sys.tone.destructive,
169
+ ...inputToneAssignments.destructive,
74
170
  },
75
171
  },
76
172
  },
77
173
 
78
174
  vars: {
79
- ...assignVars(inputVars.color, {
80
- foreground: fallbackVar(
81
- formFieldVars.color.foreground,
82
- sys.color.foreground,
83
- ),
84
- background: fallbackVar(
85
- formFieldVars.color.background,
86
- sys.color.background,
87
- 'transparent',
88
- ),
89
- outline: fallbackVar(
90
- formFieldVars.color.outline,
91
- sys.color.foreground,
92
- ),
93
- }),
94
-
175
+ ...inputColorDefaults,
176
+ [inputVars.color.foreground]: inputToneVars.base,
177
+ [inputVars.color.outline]: inputToneVars.base,
178
+ ...inputToneDefaults,
95
179
  ...assignVars(inputVars.spacing, {
96
180
  block: sys.spacing[2],
97
181
  inline: sys.spacing[4],
98
182
  }),
99
-
100
183
  ...assignVars(inputVars.shape, {
101
184
  corner: sys.shape.corner.none,
102
185
  }),
@@ -132,7 +215,7 @@ export const inputAppearance = recipe({
132
215
 
133
216
  vars: {
134
217
  [inputVars.color.background]:
135
- `color-mix(in srgb, ${inputVars.color.foreground} calc(${sys.state.muted.dark} * 100%), transparent)`,
218
+ `color-mix(in srgb, ${inputVars.color.foreground} calc(${sys.state.muted.surface} * 100%), transparent)`,
136
219
  },
137
220
  },
138
221
  },
@@ -141,75 +224,15 @@ export const inputAppearance = recipe({
141
224
  bare: {},
142
225
  },
143
226
 
144
- size: {
145
- sm: [
146
- typography.body.small,
147
- {
148
- '@layer': {
149
- [components]: {
150
- /**
151
- * Force the font size to 16px to avoid zooming on mobile
152
- */
153
- fontSize: `max(16px, ${sys.typography.body.small.size})`,
227
+ tone: inputToneStyles,
154
228
 
155
- vars: {
156
- ...assignVars(inputVars.spacing, {
157
- block: sys.spacing[1],
158
- inline: sys.spacing[1],
159
- }),
160
- },
161
- },
162
- },
163
- },
164
- ],
165
-
166
- md: [
167
- typography.body.medium,
168
- {
169
- '@layer': {
170
- [components]: {
171
- /**
172
- * Force the font size to 16px to avoid zooming on mobile
173
- */
174
- fontSize: `max(16px, ${sys.typography.body.medium.size})`,
175
-
176
- vars: {
177
- ...assignVars(inputVars.spacing, {
178
- block: sys.spacing[2],
179
- inline: sys.spacing[2],
180
- }),
181
- },
182
- },
183
- },
184
- },
185
- ],
186
-
187
- lg: [
188
- typography.body.large,
189
- {
190
- '@layer': {
191
- [components]: {
192
- /**
193
- * Force the font size to 16px to avoid zooming on mobile
194
- */
195
- fontSize: `max(16px, ${sys.typography.body.large.size})`,
196
-
197
- vars: {
198
- ...assignVars(inputVars.spacing, {
199
- block: sys.spacing[3],
200
- inline: sys.spacing[3],
201
- }),
202
- },
203
- },
204
- },
205
- },
206
- ],
207
- },
229
+ size: inputSizeStyles,
208
230
  },
209
231
 
210
232
  defaultVariants: {
211
233
  variant: 'outlined',
212
234
  size: 'md',
235
+ tone: 'neutral',
213
236
  },
214
237
  });
215
238
 
@@ -267,7 +290,7 @@ export const inputAddornment = style({
267
290
  });
268
291
 
269
292
  globalStyle(
270
- `${inputAppearance.classNames.base} input:is(:focus, :focus-visible)`,
293
+ `${inputAppearanceRecipe.classNames.base} input:is(:focus, :focus-visible)`,
271
294
  {
272
295
  '@layer': {
273
296
  [components]: {
@@ -278,5 +301,10 @@ globalStyle(
278
301
  );
279
302
 
280
303
  export type InputAppearanceVariants = NonNullable<
281
- RecipeVariants<typeof inputAppearance>
304
+ RecipeVariants<typeof inputAppearanceRecipe>
282
305
  >;
306
+
307
+ export const sizeAt = createResponsiveVariants({
308
+ styles: inputSizeStyles,
309
+ media: defaultMedia,
310
+ });
@@ -0,0 +1,9 @@
1
+ import { defaultOrder, responsiveRecipe } from '../../styles/responsive';
2
+
3
+ import { inputAppearanceRecipe, sizeAt } from './input.css';
4
+
5
+ export const inputAppearanceResponsive = responsiveRecipe({
6
+ recipe: inputAppearanceRecipe,
7
+ at: { size: sizeAt },
8
+ order: defaultOrder,
9
+ });
@@ -9,11 +9,15 @@ import { useFormFieldContext } from '../form-field/form-field-context';
9
9
  import { InputWrapper } from './input-wrapper';
10
10
  import { InputAppearanceVariants, input, inputAddornment } from './input.css';
11
11
 
12
+ import type { Responsive } from '../../styles';
13
+
12
14
  export type InputProps = Omit<ComponentPropsWithRef<'input'>, 'size'> & {
13
15
  startAdornment?: ReactNode;
14
16
  endAdornment?: ReactNode;
15
17
  inputRef?: RefObject<HTMLInputElement>;
16
- } & InputAppearanceVariants;
18
+ } & Omit<InputAppearanceVariants, 'size'> & {
19
+ size?: Responsive<NonNullable<InputAppearanceVariants['size']>>;
20
+ };
17
21
 
18
22
  export function Input({
19
23
  className,
@@ -25,6 +29,7 @@ export function Input({
25
29
  children,
26
30
  variant,
27
31
  size,
32
+ tone,
28
33
  ref,
29
34
  ...props
30
35
  }: InputProps) {
@@ -38,6 +43,7 @@ export function Input({
38
43
  disabled={disabled}
39
44
  variant={variant}
40
45
  size={size}
46
+ tone={tone}
41
47
  >
42
48
  {startAdornment && (
43
49
  <div className={inputAddornment}>{startAdornment}</div>
@@ -3,7 +3,7 @@ import { recipe, RecipeVariants } from '@vanilla-extract/recipes';
3
3
  import { typography } from '../../styles';
4
4
  import { components } from '../../styles/layers.css';
5
5
 
6
- export const label = recipe({
6
+ export const labelRecipe = recipe({
7
7
  base: {
8
8
  '@layer': {
9
9
  [components]: {
@@ -34,4 +34,4 @@ export const label = recipe({
34
34
  },
35
35
  });
36
36
 
37
- export type LabelVariants = NonNullable<RecipeVariants<typeof label>>;
37
+ export type LabelVariants = NonNullable<RecipeVariants<typeof labelRecipe>>;
@@ -1,11 +1,20 @@
1
1
  import { clsx } from 'clsx';
2
2
  import { ComponentPropsWithRef } from 'react';
3
3
 
4
- import { label, LabelVariants } from './label.css';
4
+ import {
5
+ buildTypographyOverrides,
6
+ getResponsiveBase,
7
+ mapResponsiveSizeToTypography,
8
+ type Responsive,
9
+ } from '../../styles';
10
+
11
+ import { labelRecipe, LabelVariants } from './label.css';
5
12
 
6
13
  export type LabelProps = ComponentPropsWithRef<'label'> & {
7
14
  required?: boolean;
8
- } & LabelVariants;
15
+ } & Omit<LabelVariants, 'size'> & {
16
+ size?: Responsive<NonNullable<LabelVariants['size']>>;
17
+ };
9
18
 
10
19
  export function Label({
11
20
  className,
@@ -14,9 +23,20 @@ export function Label({
14
23
  size = 'md',
15
24
  ...props
16
25
  }: LabelProps) {
26
+ const baseSize = getResponsiveBase(size) ?? 'md';
27
+ const typographySize = mapResponsiveSizeToTypography(size);
28
+ const typographyOverrides = buildTypographyOverrides({
29
+ variant: 'label',
30
+ size: typographySize,
31
+ });
32
+
17
33
  return (
18
34
  <label
19
- className={clsx(label({ disabled, error, size }), className)}
35
+ className={clsx(
36
+ labelRecipe({ disabled, error, size: baseSize }),
37
+ typographyOverrides,
38
+ className,
39
+ )}
20
40
  {...props}
21
41
  />
22
42
  );
@@ -0,0 +1,120 @@
1
+ import { assignVars, type StyleRule } from '@vanilla-extract/css';
2
+
3
+ import { mapContractVars, sys } from '../styles';
4
+ import { components } from '../styles/layers.css';
5
+
6
+ interface GapVars {
7
+ gap: string;
8
+ }
9
+
10
+ export const createSpacingVarStyles = (
11
+ vars: GapVars,
12
+ property?: 'gap' | 'columnGap' | 'rowGap',
13
+ ) =>
14
+ mapContractVars(sys.spacing, (key) => ({
15
+ '@layer': {
16
+ [components]: {
17
+ ...(property ? { [property]: vars.gap } : {}),
18
+ vars: assignVars(
19
+ vars as never,
20
+ {
21
+ gap: sys.spacing[key],
22
+ } as never,
23
+ ),
24
+ },
25
+ },
26
+ }));
27
+
28
+ const createLayeredStyleMap = <T extends string>(
29
+ property: string,
30
+ values: Record<T, string>,
31
+ ) =>
32
+ Object.fromEntries(
33
+ Object.entries(values).map(([key, value]) => [
34
+ key,
35
+ {
36
+ '@layer': {
37
+ [components]: {
38
+ [property]: value,
39
+ },
40
+ },
41
+ },
42
+ ]),
43
+ ) as Record<T, StyleRule>;
44
+
45
+ const flexAlignItemsValues = {
46
+ start: 'flex-start',
47
+ center: 'center',
48
+ end: 'flex-end',
49
+ stretch: 'stretch',
50
+ } as const;
51
+
52
+ const flexAlignItemsBaselineValues = {
53
+ ...flexAlignItemsValues,
54
+ baseline: 'baseline',
55
+ } as const;
56
+
57
+ const flexJustifyContentValues = {
58
+ start: 'flex-start',
59
+ end: 'flex-end',
60
+ center: 'center',
61
+ spaceBetween: 'space-between',
62
+ spaceAround: 'space-around',
63
+ spaceEvenly: 'space-evenly',
64
+ } as const;
65
+
66
+ const gridAxisValues = {
67
+ start: 'start',
68
+ end: 'end',
69
+ center: 'center',
70
+ stretch: 'stretch',
71
+ } as const;
72
+
73
+ const gridContentValues = {
74
+ start: 'start',
75
+ end: 'end',
76
+ center: 'center',
77
+ spaceBetween: 'space-between',
78
+ spaceAround: 'space-around',
79
+ spaceEvenly: 'space-evenly',
80
+ } as const;
81
+
82
+ const gridContentStretchValues = {
83
+ ...gridContentValues,
84
+ stretch: 'stretch',
85
+ } as const;
86
+
87
+ export const flexAlignItemsStyles = createLayeredStyleMap(
88
+ 'alignItems',
89
+ flexAlignItemsValues,
90
+ );
91
+
92
+ export const flexAlignItemsWithBaselineStyles = createLayeredStyleMap(
93
+ 'alignItems',
94
+ flexAlignItemsBaselineValues,
95
+ );
96
+
97
+ export const flexJustifyContentStyles = createLayeredStyleMap(
98
+ 'justifyContent',
99
+ flexJustifyContentValues,
100
+ );
101
+
102
+ export const gridAlignItemsStyles = createLayeredStyleMap(
103
+ 'alignItems',
104
+ gridAxisValues,
105
+ );
106
+
107
+ export const gridJustifyItemsStyles = createLayeredStyleMap(
108
+ 'justifyItems',
109
+ gridAxisValues,
110
+ );
111
+
112
+ export const gridJustifyContentStyles = createLayeredStyleMap(
113
+ 'justifyContent',
114
+ gridContentValues,
115
+ );
116
+
117
+ export const gridAlignContentStyles = createLayeredStyleMap(
118
+ 'alignContent',
119
+ gridContentStretchValues,
120
+ );
@@ -1 +1,2 @@
1
- export { MoonLoader } from './moon-loader';
1
+ export { MoonLoader, type LoaderProps } from './moon-loader';
2
+ export type { LoaderVariants, MoonLoaderVariants } from './loader.css';