@kalink-ui/seedly 0.7.0 → 0.8.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 (42) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +5 -16
  3. package/src/components/box/box.css.ts +13 -2
  4. package/src/components/box/box.tsx +8 -28
  5. package/src/components/button/button.css.ts +346 -13
  6. package/src/components/button/button.tsx +37 -22
  7. package/src/components/center/center.css.ts +10 -2
  8. package/src/components/center/center.tsx +6 -20
  9. package/src/components/cluster/cluster.css.ts +10 -2
  10. package/src/components/cluster/cluster.tsx +6 -21
  11. package/src/components/conditional-wrapper/conditional-wrapper.tsx +23 -0
  12. package/src/components/conditional-wrapper/index.ts +1 -0
  13. package/src/components/cover/cover.css.ts +4 -13
  14. package/src/components/cover/cover.tsx +12 -22
  15. package/src/components/frame/frame.css.ts +3 -0
  16. package/src/components/frame/frame.tsx +6 -10
  17. package/src/components/grid/grid.css.ts +4 -2
  18. package/src/components/grid/grid.tsx +11 -15
  19. package/src/components/heading/heading.css.ts +5 -0
  20. package/src/components/heading/heading.tsx +83 -0
  21. package/src/components/heading/index.ts +1 -0
  22. package/src/components/index.ts +14 -0
  23. package/src/{styles → components}/seed/seed.tsx +3 -6
  24. package/src/components/sidebar/sidebar.css.ts +7 -2
  25. package/src/components/sidebar/sidebar.tsx +6 -21
  26. package/src/components/stack/stack.css.ts +7 -2
  27. package/src/components/stack/stack.tsx +6 -15
  28. package/src/components/switcher/switcher.css.ts +1 -2
  29. package/src/components/switcher/switcher.tsx +6 -16
  30. package/src/components/text/index.ts +1 -1
  31. package/src/components/text/text.css.ts +12 -2
  32. package/src/components/text/text.tsx +41 -23
  33. package/src/index.ts +2 -0
  34. package/src/styles/index.ts +15 -2
  35. package/src/styles/reset.css.ts +1 -0
  36. package/src/styles/system-contract.css.ts +45 -31
  37. package/src/styles/transition.ts +26 -0
  38. package/src/styles/typography.css.ts +2 -4
  39. package/src/utils/index.ts +6 -2
  40. /package/src/{styles → components}/seed/index.ts +0 -0
  41. /package/src/{utils → styles}/extract-sprinkles-props.ts +0 -0
  42. /package/src/{utils → styles}/map-contract-vars.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @kalink-ui/seedly
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - fb11f86: Simplify package exports
8
+ - abdbfa3: Create new Header and Button components
9
+
3
10
  ## 0.7.0
4
11
 
5
12
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kalink-ui/seedly",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "A set of components for building UIs with React and TypeScript",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
@@ -10,22 +10,10 @@
10
10
  "url": "git+https://github.com/Kalink/kalink-ui.git"
11
11
  },
12
12
  "exports": {
13
- "./box": "./src/components/box/index.ts",
14
- "./button": "./src/components/button/index.ts",
15
- "./center": "./src/components/center/index.ts",
16
- "./cluster": "./src/components/cluster/index.ts",
17
- "./cover": "./src/components/cover/index.ts",
18
- "./frame": "./src/components/frame/index.ts",
19
- "./grid": "./src/components/grid/index.ts",
20
- "./sidebar": "./src/components/sidebar/index.ts",
21
- "./stack": "./src/components/stack/index.ts",
22
- "./switcher": "./src/components/switcher/index.ts",
13
+ ".": "./src/index.ts",
23
14
  "./styles": "./src/styles/index.ts",
24
15
  "./styles/reset": "./src/styles/reset.css.ts",
25
- "./styles/layers": "./src/styles/layers.css.ts",
26
- "./types": "./src/types/index.ts",
27
- "./text": "./src/components/text/index.ts",
28
- "./utils": "./src/utils/index.ts"
16
+ "./styles/layers": "./src/styles/layers.css.ts"
29
17
  },
30
18
  "devDependencies": {
31
19
  "@chromatic-com/storybook": "^3.2.5",
@@ -50,6 +38,7 @@
50
38
  "@vitejs/plugin-react": "^4.3.4",
51
39
  "eslint": "^9.21.0",
52
40
  "react": "^19.0.0",
41
+ "react-docgen-typescript": "^2.2.2",
53
42
  "react-dom": "^19.0.0",
54
43
  "storybook": "^8.6.4",
55
44
  "type-fest": "^4.37.0",
@@ -58,7 +47,7 @@
58
47
  "vite-tsconfig-paths": "^5.1.4",
59
48
  "vitest": "^3.0.8",
60
49
  "@kalink-ui/dibbly": "0.2.0",
61
- "@kalink-ui/eslint-config": "0.5.0",
50
+ "@kalink-ui/eslint-config": "0.7.0",
62
51
  "@kalink-ui/typescript-config": "0.4.0"
63
52
  },
64
53
  "peerDependencies": {
@@ -1,15 +1,17 @@
1
1
  import { createVar } from '@vanilla-extract/css';
2
2
  import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
3
3
 
4
+ import { mapContractVars, sys } 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 colorForeground = createVar();
9
8
  export const colorBackground = createVar();
10
9
 
11
10
  export const boxRecipe = recipe({
12
11
  variants: {
12
+ /**
13
+ * The main variation of the box
14
+ */
13
15
  variant: {
14
16
  solid: {
15
17
  '@layer': {
@@ -39,6 +41,9 @@ export const boxRecipe = recipe({
39
41
  },
40
42
  },
41
43
 
44
+ /**
45
+ * The spacing between the box borders and its contents
46
+ */
42
47
  spacing: mapContractVars(sys.spacing, (key) => ({
43
48
  '@layer': {
44
49
  [components]: {
@@ -47,6 +52,9 @@ export const boxRecipe = recipe({
47
52
  },
48
53
  })),
49
54
 
55
+ /**
56
+ * The elevation of the box
57
+ */
50
58
  elevation: mapContractVars(sys.elevation, (key) => ({
51
59
  '@layer': {
52
60
  [components]: {
@@ -55,6 +63,9 @@ export const boxRecipe = recipe({
55
63
  },
56
64
  })),
57
65
 
66
+ /**
67
+ * The radius of the box
68
+ */
58
69
  radius: mapContractVars(sys.shape.corner, (key) => ({
59
70
  '@layer': {
60
71
  [components]: {
@@ -1,31 +1,11 @@
1
+ import { PolymorphicComponentProps } from '@kalink-ui/dibbly';
1
2
  import { clsx } from 'clsx';
3
+ import { ElementType } from 'react';
2
4
 
3
- import { boxRecipe, type BoxVariants } from './box.css';
5
+ import { BoxVariants, boxRecipe } from './box.css';
4
6
 
5
- import type { PolymorphicComponentProps } from '@kalink-ui/dibbly/types';
6
-
7
- type BoxProps<TUse extends React.ElementType> =
8
- PolymorphicComponentProps<TUse> & {
9
- /**
10
- * The main variation of the box
11
- */
12
- variant?: BoxVariants['variant'];
13
-
14
- /**
15
- * The spacing between the box borders and its contents
16
- */
17
- spacing?: BoxVariants['spacing'];
18
-
19
- /**
20
- * The elevation of the box
21
- */
22
- elevation?: BoxVariants['elevation'];
23
-
24
- /**
25
- * The radius of the box
26
- */
27
- radius?: BoxVariants['radius'];
28
- };
7
+ type BoxProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> &
8
+ BoxVariants;
29
9
 
30
10
  /**
31
11
  * A evenly spaced container for grouping related elements. Can
@@ -33,14 +13,14 @@ type BoxProps<TUse extends React.ElementType> =
33
13
  *
34
14
  * https://every-layout.dev/layouts/box
35
15
  */
36
- export const Box = <TUse extends React.ElementType = 'div'>({
16
+ export function Box<TUse extends ElementType = 'div'>({
37
17
  spacing,
38
18
  radius,
39
19
  elevation,
40
20
  className,
41
21
  variant,
42
22
  ...props
43
- }: BoxProps<TUse>) => {
23
+ }: BoxProps<TUse>) {
44
24
  const { use: Comp = 'div', ...rest } = props;
45
25
 
46
26
  return (
@@ -52,4 +32,4 @@ export const Box = <TUse extends React.ElementType = 'div'>({
52
32
  {...rest}
53
33
  />
54
34
  );
55
- };
35
+ }
@@ -1,33 +1,366 @@
1
- import { createTheme } from '@vanilla-extract/css';
1
+ import {
2
+ assignVars,
3
+ createThemeContract,
4
+ fallbackVar,
5
+ style,
6
+ } from '@vanilla-extract/css';
2
7
  import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
3
8
 
4
- import { sys } from '../../styles/system-contract.css';
9
+ import { sys, typography } from '../../styles';
10
+ import { components } from '../../styles/layers.css';
11
+ import { transition } from '../../styles/transition';
5
12
 
6
- export const [buttonTheme, buttonsys] = createTheme({
13
+ export const buttonVars = createThemeContract({
14
+ borderRadius: null,
15
+ textTransform: null,
16
+ });
17
+
18
+ const vars = createThemeContract({
7
19
  color: {
8
- light: sys.color.foreground,
9
- dark: sys.color.background,
20
+ text: null,
21
+ background: null,
22
+ },
23
+ spacing: {
24
+ block: null,
25
+ inline: null,
26
+ inner: null,
27
+ },
28
+ border: {
29
+ width: null,
30
+ style: null,
31
+ color: null,
32
+ },
33
+ shadow: {
34
+ level: null,
10
35
  },
11
36
  });
12
37
 
13
38
  export const buttonRecipe = recipe({
14
39
  base: {
15
- padding: '0',
40
+ '@layer': {
41
+ [components]: {
42
+ display: 'flex',
43
+ alignItems: 'center',
44
+ justifyContent: 'center',
45
+ gap: vars.spacing.inner,
46
+
47
+ paddingBlock: vars.spacing.block,
48
+ paddingInline: vars.spacing.inline,
49
+
50
+ color: vars.color.text,
51
+ textTransform: fallbackVar(buttonVars.textTransform, 'unset'),
52
+ backgroundColor: vars.color.background,
53
+ borderRadius: fallbackVar(
54
+ buttonVars.borderRadius,
55
+ sys.shape.corner.none,
56
+ ),
57
+ borderWidth: vars.border.width,
58
+ borderStyle: vars.border.style,
59
+ borderColor: vars.border.color,
60
+ boxShadow: vars.shadow.level,
16
61
 
17
- backgroundColor: 'unset',
18
- border: 'unset',
62
+ transition: transition(
63
+ ['background-color', 'box-shadow', 'border-color', 'color'],
64
+ { duration: 'short.3' },
65
+ ),
19
66
 
20
- cursor: 'pointer',
67
+ ':disabled': {
68
+ cursor: 'not-allowed',
69
+ },
70
+ },
71
+ },
21
72
  },
73
+
22
74
  variants: {
75
+ /**
76
+ * The main variation of the button
77
+ */
23
78
  variant: {
24
79
  bare: {},
25
- plain: {},
26
- outline: {},
27
- ghost: {},
28
- link: {},
80
+ plain: {
81
+ '@layer': {
82
+ [components]: {
83
+ vars: {
84
+ ...assignVars(vars.color, {
85
+ text: sys.color.background,
86
+ background: sys.color.foreground,
87
+ }),
88
+ ...assignVars(vars.border, {
89
+ width: '1px',
90
+ style: 'solid',
91
+ color: 'transparent',
92
+ }),
93
+ },
94
+ ':hover': {
95
+ vars: {
96
+ [vars.color.background]:
97
+ `color-mix(in srgb, ${sys.color.foreground}, ${sys.color.background} calc(100% * ${sys.state.hovered.opacity}))`,
98
+ [vars.shadow.level]: sys.elevation.minimal,
99
+ },
100
+ },
101
+ ':disabled': {
102
+ vars: {
103
+ ...assignVars(vars.color, {
104
+ text: `color-mix(in srgb, ${sys.color.background} calc(100% * ${sys.state.muted.light}), transparent)`,
105
+ background: `color-mix(in srgb, ${sys.color.foreground} calc(100% * ${sys.state.muted.dark}), transparent)`,
106
+ }),
107
+ [vars.shadow.level]: sys.elevation.none,
108
+ [vars.border.color]: `transparent`,
109
+ },
110
+ },
111
+ },
112
+ },
113
+ },
114
+ outline: {
115
+ '@layer': {
116
+ [components]: {
117
+ vars: {
118
+ ...assignVars(vars.color, {
119
+ text: sys.color.foreground,
120
+ background: 'unset',
121
+ }),
122
+ ...assignVars(vars.border, {
123
+ width: '1px',
124
+ style: 'solid',
125
+ color: sys.color.foreground,
126
+ }),
127
+ },
128
+ selectors: {
129
+ '&:hover': {
130
+ vars: {
131
+ [vars.color.background]:
132
+ `color-mix(in srgb, ${sys.color.foreground} calc(100% * ${sys.state.hovered.opacity}), transparent)`,
133
+ },
134
+ },
135
+ '&:disabled': {
136
+ vars: {
137
+ [vars.color.background]: 'unset',
138
+ [vars.color.text]:
139
+ `color-mix(in srgb, ${sys.color.foreground} calc(100% * ${sys.state.muted.dark}), transparent)`,
140
+ [vars.border.color]:
141
+ `color-mix(in srgb, ${sys.color.foreground} calc(100% * ${sys.state.muted.dark}), transparent)`,
142
+ },
143
+ },
144
+ },
145
+ },
146
+ },
147
+ },
148
+ ghost: {
149
+ '@layer': {
150
+ [components]: {
151
+ vars: {
152
+ ...assignVars(vars.color, {
153
+ text: sys.color.foreground,
154
+ background: 'unset',
155
+ }),
156
+ ...assignVars(vars.border, {
157
+ width: '1px',
158
+ style: 'solid',
159
+ color: 'transparent',
160
+ }),
161
+ },
162
+ selectors: {
163
+ '&:hover': {
164
+ vars: {
165
+ [vars.color.background]:
166
+ `color-mix(in srgb, ${sys.color.foreground} calc(100% * ${sys.state.hovered.opacity}), transparent)`,
167
+ },
168
+ },
169
+ '&:disabled': {
170
+ vars: {
171
+ [vars.color.background]: 'unset',
172
+ [vars.color.text]:
173
+ `color-mix(in srgb, ${sys.color.foreground} calc(100% * ${sys.state.muted.dark}), transparent)`,
174
+ },
175
+ },
176
+ },
177
+ },
178
+ },
179
+ },
180
+ link: {
181
+ '@layer': {
182
+ [components]: {
183
+ display: 'inline-flex',
184
+
185
+ textDecoration: 'none',
186
+
187
+ vars: {
188
+ ...assignVars(vars.color, {
189
+ text: sys.color.foreground,
190
+ background: 'unset',
191
+ }),
192
+ ...assignVars(vars.spacing, {
193
+ block: '0',
194
+ inline: '0',
195
+ inner: '0',
196
+ }),
197
+ },
198
+ selectors: {
199
+ '&:hover': {
200
+ textDecoration: 'underline',
201
+ },
202
+
203
+ '&:disabled': {
204
+ textDecoration: 'none',
205
+ vars: {
206
+ [vars.color.text]:
207
+ `color-mix(in srgb, ${sys.color.foreground} calc(100% * ${sys.state.muted.dark}), transparent)`,
208
+ },
209
+ },
210
+ },
211
+ },
212
+ },
213
+ },
214
+ },
215
+
216
+ size: {
217
+ sm: {
218
+ '@layer': {
219
+ [components]: {
220
+ vars: assignVars(vars.spacing, {
221
+ block: sys.spacing[2],
222
+ inline: sys.spacing[3],
223
+ inner: sys.spacing[3],
224
+ }),
225
+ },
226
+ },
227
+ },
228
+ md: {
229
+ '@layer': {
230
+ [components]: {
231
+ vars: assignVars(vars.spacing, {
232
+ block: sys.spacing[2],
233
+ inline: sys.spacing[4],
234
+ inner: sys.spacing[4],
235
+ }),
236
+ },
237
+ },
238
+ },
239
+ lg: {
240
+ '@layer': {
241
+ [components]: {
242
+ vars: assignVars(vars.spacing, {
243
+ block: sys.spacing[3],
244
+ inline: sys.spacing[6],
245
+ inner: sys.spacing[6],
246
+ }),
247
+ },
248
+ },
249
+ },
29
250
  },
30
251
  },
252
+
253
+ compoundVariants: [
254
+ {
255
+ variants: {
256
+ variant: 'bare',
257
+ size: 'sm',
258
+ },
259
+ style: {
260
+ '@layer': {
261
+ [components]: {
262
+ vars: {
263
+ [vars.spacing.block]: '0',
264
+ [vars.spacing.inline]: '0',
265
+ },
266
+ },
267
+ },
268
+ },
269
+ },
270
+ {
271
+ variants: {
272
+ variant: 'bare',
273
+ size: 'md',
274
+ },
275
+ style: {
276
+ '@layer': {
277
+ [components]: {
278
+ vars: {
279
+ [vars.spacing.block]: '0',
280
+ [vars.spacing.inline]: '0',
281
+ },
282
+ },
283
+ },
284
+ },
285
+ },
286
+ {
287
+ variants: {
288
+ variant: 'bare',
289
+ size: 'lg',
290
+ },
291
+ style: {
292
+ '@layer': {
293
+ [components]: {
294
+ vars: {
295
+ [vars.spacing.block]: '0',
296
+ [vars.spacing.inline]: '0',
297
+ },
298
+ },
299
+ },
300
+ },
301
+ },
302
+ {
303
+ variants: {
304
+ variant: 'link',
305
+ size: 'sm',
306
+ },
307
+ style: {
308
+ '@layer': {
309
+ [components]: {
310
+ vars: {
311
+ [vars.spacing.block]: '0',
312
+ [vars.spacing.inline]: '0',
313
+ },
314
+ },
315
+ },
316
+ },
317
+ },
318
+ {
319
+ variants: {
320
+ variant: 'link',
321
+ size: 'md',
322
+ },
323
+ style: {
324
+ '@layer': {
325
+ [components]: {
326
+ vars: {
327
+ [vars.spacing.block]: '0',
328
+ [vars.spacing.inline]: '0',
329
+ },
330
+ },
331
+ },
332
+ },
333
+ },
334
+ {
335
+ variants: {
336
+ variant: 'link',
337
+ size: 'lg',
338
+ },
339
+ style: {
340
+ '@layer': {
341
+ [components]: {
342
+ vars: {
343
+ [vars.spacing.block]: '0',
344
+ [vars.spacing.inline]: '0',
345
+ },
346
+ },
347
+ },
348
+ },
349
+ },
350
+ ],
31
351
  });
32
352
 
353
+ export const buttonLabel = recipe({
354
+ variants: {
355
+ size: {
356
+ sm: [typography.label.small],
357
+ md: [typography.label.medium],
358
+ lg: [typography.label.large],
359
+ },
360
+ },
361
+ });
362
+
363
+ export const buttonStartSlot = style({});
364
+ export const buttonEndSlot = style({});
365
+
33
366
  export type ButtonVariants = NonNullable<RecipeVariants<typeof buttonRecipe>>;
@@ -1,31 +1,46 @@
1
+ import { PolymorphicComponentProps } from '@kalink-ui/dibbly';
1
2
  import { clsx } from 'clsx';
3
+ import { ComponentType, ReactNode } from 'react';
2
4
 
3
- import { Box } from '../box';
5
+ import {
6
+ buttonEndSlot,
7
+ buttonLabel,
8
+ buttonRecipe,
9
+ buttonStartSlot,
10
+ ButtonVariants,
11
+ } from './button.css';
4
12
 
5
- import { buttonRecipe, type ButtonVariants } from './button.css';
13
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
14
+ type ButtonTypes = 'button' | 'a' | ComponentType<any>;
6
15
 
7
- import type { PolymorphicComponentProps } from '@kalink-ui/dibbly/types';
8
-
9
- type ButtonProps<TUse extends React.ElementType> =
10
- PolymorphicComponentProps<TUse> & {
11
- /**
12
- * The main variation of the button
13
- */
14
- variant?: ButtonVariants['variant'];
16
+ type ButtonProps<TUse extends ButtonTypes> = PolymorphicComponentProps<TUse> &
17
+ ButtonVariants & {
18
+ startSlot?: ReactNode;
19
+ endSlot?: ReactNode;
20
+ children?: string;
15
21
  };
16
22
 
17
- export const Button = <TUse extends React.ElementType = 'button'>({
18
- className,
19
- variant,
20
- ...props
21
- }: ButtonProps<TUse>) => {
22
- const { use: Comp = 'button', ...rest } = props;
23
+ export function Button<TUse extends ButtonTypes>(props: ButtonProps<TUse>) {
24
+ const {
25
+ use: Comp = 'button',
26
+ className,
27
+ variant,
28
+ children,
29
+ startSlot,
30
+ endSlot,
31
+ size = 'md',
32
+ ...rest
33
+ } = props;
23
34
 
24
35
  return (
25
- <Box
26
- use={Comp}
27
- className={clsx(buttonRecipe({ variant }), className)}
28
- {...rest}
29
- />
36
+ <Comp
37
+ className={clsx(buttonRecipe({ variant, size }), className)}
38
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
39
+ {...(rest as any)}
40
+ >
41
+ {startSlot && <span className={clsx(buttonStartSlot)}>{startSlot}</span>}
42
+ <span className={clsx(buttonLabel({ size }))}>{children}</span>
43
+ {endSlot && <span className={clsx(buttonEndSlot)}>{endSlot}</span>}
44
+ </Comp>
30
45
  );
31
- };
46
+ }
@@ -1,8 +1,7 @@
1
1
  import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
2
2
 
3
+ import { mapContractVars , sys } from '../../styles';
3
4
  import { components } from '../../styles/layers.css';
4
- import { sys } from '../../styles/system-contract.css';
5
- import { mapContractVars } from '../../utils/map-contract-vars';
6
5
 
7
6
  export const centerRecipe = recipe({
8
7
  base: {
@@ -17,6 +16,9 @@ export const centerRecipe = recipe({
17
16
  },
18
17
 
19
18
  variants: {
19
+ /**
20
+ * Center align the text too with `text-align: center`
21
+ */
20
22
  andText: {
21
23
  true: {
22
24
  '@layer': {
@@ -27,6 +29,9 @@ export const centerRecipe = recipe({
27
29
  },
28
30
  },
29
31
 
32
+ /**
33
+ * Center child elements based on their content width
34
+ */
30
35
  intrinsic: {
31
36
  true: {
32
37
  '@layer': {
@@ -39,6 +44,9 @@ export const centerRecipe = recipe({
39
44
  },
40
45
  },
41
46
 
47
+ /**
48
+ * The minimum space on either side of the content
49
+ */
42
50
  gutters: mapContractVars(sys.spacing, (key) => ({
43
51
  '@layer': {
44
52
  [components]: {