@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
@@ -1,20 +1,11 @@
1
- import { PolymorphicComponentProps } from '@kalink-ui/dibbly/types';
1
+ import { PolymorphicComponentProps } from '@kalink-ui/dibbly';
2
2
  import { clsx } from 'clsx';
3
3
  import { ElementType } from 'react';
4
4
 
5
5
  import { stackRecipe, StackVariants } from './stack.css';
6
6
 
7
- type StackProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> & {
8
- /**
9
- * Whether the stack spacing should be applied recursively
10
- */
11
- recursive?: StackVariants['recursive'];
12
-
13
- /**
14
- * The spacing between items
15
- */
16
- spacing?: StackVariants['spacing'];
17
- };
7
+ type StackProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> &
8
+ StackVariants;
18
9
 
19
10
  /**
20
11
  * A custom element for injecting white space (margin) between flow
@@ -26,12 +17,12 @@ type StackProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> & {
26
17
  *
27
18
  * https://every-layout.dev/layouts/stack
28
19
  */
29
- export const Stack = <TUse extends ElementType = 'div'>({
20
+ export function Stack<TUse extends ElementType = 'div'>({
30
21
  recursive,
31
22
  spacing,
32
23
  className,
33
24
  ...props
34
- }: StackProps<TUse>) => {
25
+ }: StackProps<TUse>) {
35
26
  const { use: Comp = 'div', ...rest } = props;
36
27
 
37
28
  return (
@@ -40,4 +31,4 @@ export const Stack = <TUse extends ElementType = 'div'>({
40
31
  {...rest}
41
32
  />
42
33
  );
43
- };
34
+ }
@@ -1,9 +1,8 @@
1
1
  import { createVar, globalStyle } from '@vanilla-extract/css';
2
2
  import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
3
3
 
4
+ import { sys, mapContractVars } from '../../styles';
4
5
  import { components } from '../../styles/layers.css';
5
- import { sys } from '../../styles/system-contract.css';
6
- import { mapContractVars } from '../../utils/map-contract-vars';
7
6
 
8
7
  export const thresholdVar = createVar();
9
8
  export const limitVar = createVar();
@@ -1,28 +1,18 @@
1
1
  'use client';
2
2
 
3
- import { PolymorphicComponentProps } from '@kalink-ui/dibbly/types';
3
+ import { PolymorphicComponentProps } from '@kalink-ui/dibbly';
4
4
  import { assignInlineVars } from '@vanilla-extract/dynamic';
5
5
  import { clsx } from 'clsx';
6
6
  import { ElementType } from 'react';
7
7
 
8
8
  import { switcherRecipe, SwitcherVariants, thresholdVar } from './switcher.css';
9
9
 
10
- type SwitcherProps<TUse extends ElementType> =
11
- PolymorphicComponentProps<TUse> & {
12
- /**
13
- * The gap between items
14
- */
15
- spacing?: SwitcherVariants['spacing'];
16
-
10
+ type SwitcherProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> &
11
+ SwitcherVariants & {
17
12
  /**
18
13
  * The threshold at which to switch between horizontal and vertical layouts
19
14
  */
20
15
  threshold?: string;
21
-
22
- /**
23
- * The maximum number of elements allowed to appear in the horizontal configuration
24
- */
25
- limit?: SwitcherVariants['limit'];
26
16
  };
27
17
 
28
18
  /**
@@ -31,13 +21,13 @@ type SwitcherProps<TUse extends ElementType> =
31
21
  *
32
22
  * https://every-layout.dev/layouts/switcher
33
23
  */
34
- export const Switcher = <TUse extends ElementType>({
24
+ export function Switcher<TUse extends ElementType>({
35
25
  spacing,
36
26
  threshold,
37
27
  limit,
38
28
  className,
39
29
  ...props
40
- }: SwitcherProps<TUse>) => {
30
+ }: SwitcherProps<TUse>) {
41
31
  const { use: Comp = 'div' } = props;
42
32
 
43
33
  return (
@@ -49,4 +39,4 @@ export const Switcher = <TUse extends ElementType>({
49
39
  {...props}
50
40
  />
51
41
  );
52
- };
42
+ }
@@ -1 +1 @@
1
- export { Text } from './text';
1
+ export { Text, type TextProps } from './text';
@@ -1,15 +1,25 @@
1
+ import { style } from '@vanilla-extract/css';
1
2
  import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
2
3
 
3
4
  export const textRecipe = recipe({
4
5
  variants: {
6
+ /**
7
+ * If true, use an ellipsis when the text overflows the element.
8
+ */
5
9
  ellipsis: {
6
10
  true: {
7
- whiteSpace: 'nowrap',
8
- textOverflow: 'ellipsis',
11
+ display: 'inline-block',
12
+ maxWidth: '100%',
9
13
  overflow: 'hidden',
14
+
15
+ textOverflow: 'ellipsis',
10
16
  },
11
17
  },
12
18
  },
13
19
  });
14
20
 
21
+ export const textEllipsisWrapper = style({
22
+ whiteSpace: 'nowrap',
23
+ });
24
+
15
25
  export type TextVariants = NonNullable<RecipeVariants<typeof textRecipe>>;
@@ -1,43 +1,61 @@
1
- import { getProp } from '@kalink-ui/dibbly';
2
- import { PathsOf, PolymorphicComponentProps } from '@kalink-ui/dibbly/types';
1
+ import {
2
+ DistributiveOmit,
3
+ PolymorphicComponentProps,
4
+ getProp,
5
+ } from '@kalink-ui/dibbly';
3
6
  import { clsx } from 'clsx';
4
7
  import { ElementType } from 'react';
5
8
 
6
- import { typography as typographyVariants } from '../../styles/typography.css';
7
- import { Box } from '../box';
9
+ import { TypographySize, TypographyVariant, typography } from '../../styles';
8
10
 
9
- import { textRecipe, type TextVariants } from './text.css';
11
+ import { TextVariants, textRecipe, textEllipsisWrapper } from './text.css';
10
12
 
11
- type TextProps<TUse extends React.ElementType> =
12
- PolymorphicComponentProps<TUse> & {
13
+ export type TextProps<TUse extends React.ElementType> = DistributiveOmit<
14
+ PolymorphicComponentProps<TUse>,
15
+ 'children'
16
+ > &
17
+ TextVariants & {
13
18
  /**
14
- * The typography used to render the text.
19
+ * The size of the typography used to render the text.
15
20
  */
16
- typography?: PathsOf<typeof typographyVariants>;
21
+ size?: TypographySize;
22
+
17
23
  /**
18
- * If true, use an ellipsis when the text overflows the element.
24
+ * The typography variant used to render the text.
19
25
  */
20
- ellipsis?: TextVariants['ellipsis'];
26
+ variant?: Extract<TypographyVariant, 'body' | 'caption' | 'label'>;
27
+
28
+ /**
29
+ * The text to render.
30
+ */
31
+ children: string;
21
32
  };
22
33
 
23
- export function Text<TUse extends ElementType>({
24
- className,
25
- typography,
26
- ellipsis,
27
- ...props
28
- }: TextProps<TUse>) {
29
- const { use = 'span', ...rest } = props;
34
+ export function Text<TUse extends ElementType>(props: TextProps<TUse>) {
35
+ const {
36
+ children,
37
+ className,
38
+ ellipsis,
39
+ size = 'medium',
40
+ use: Comp = 'span',
41
+ variant = 'body',
42
+ ...rest
43
+ } = props;
30
44
 
31
45
  return (
32
- <Box
33
- // See `frontend/components/box/box.types.ts` for why the cast is required
34
- use={use as TextProps<TUse>['use']}
46
+ <Comp
35
47
  className={clsx(
36
48
  textRecipe({ ellipsis }),
37
- typography && getProp(typographyVariants, typography),
49
+ getProp(typography, `${variant}.${size}`),
38
50
  className,
39
51
  )}
40
52
  {...rest}
41
- />
53
+ >
54
+ {ellipsis ? (
55
+ <span className={textEllipsisWrapper}>{children}</span>
56
+ ) : (
57
+ children
58
+ )}
59
+ </Comp>
42
60
  );
43
61
  }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './components';
2
+ export * from './utils';
@@ -1,2 +1,15 @@
1
- export { sys } from './system-contract.css';
2
- export { plantSeed } from './seed';
1
+ export {
2
+ sys,
3
+ type Spacing,
4
+ type TypographySize,
5
+ type TypographyVariant,
6
+ } from './system-contract.css';
7
+ export { typography } from './typography.css';
8
+
9
+ export {
10
+ extractSprinklesProps,
11
+ type GetSprinkles,
12
+ type SprinklesFnBase,
13
+ } from './extract-sprinkles-props';
14
+
15
+ export { mapContractVars } from './map-contract-vars';
@@ -75,6 +75,7 @@ globalStyle('button', {
75
75
  '@layer': {
76
76
  [base]: {
77
77
  border: 'none',
78
+ backgroundColor: 'transparent',
78
79
 
79
80
  cursor: 'pointer',
80
81
  },
@@ -1,4 +1,5 @@
1
1
  import { createThemeContract } from '@vanilla-extract/css';
2
+ import { ArrayValues } from 'type-fest';
2
3
 
3
4
  export const typeContract = {
4
5
  font: null,
@@ -8,6 +9,16 @@ export const typeContract = {
8
9
  size: null,
9
10
  } as const;
10
11
 
12
+ const typographyVariants = [
13
+ 'display',
14
+ 'headline',
15
+ 'title',
16
+ 'label',
17
+ 'body',
18
+ ] as const;
19
+
20
+ const typographySizes = ['large', 'medium', 'small'] as const;
21
+
11
22
  export const sys = createThemeContract({
12
23
  layout: {
13
24
  direction: null,
@@ -31,6 +42,10 @@ export const sys = createThemeContract({
31
42
  pressed: {
32
43
  opacity: null,
33
44
  },
45
+ muted: {
46
+ light: null,
47
+ dark: null,
48
+ },
34
49
  },
35
50
 
36
51
  shape: {
@@ -88,37 +103,22 @@ export const sys = createThemeContract({
88
103
  },
89
104
  },
90
105
 
91
- typography: {
92
- display: {
93
- large: typeContract,
94
- medium: typeContract,
95
- small: typeContract,
96
- },
97
-
98
- headline: {
99
- large: typeContract,
100
- medium: typeContract,
101
- small: typeContract,
102
- },
103
-
104
- title: {
105
- large: typeContract,
106
- medium: typeContract,
107
- small: typeContract,
108
- },
109
-
110
- label: {
111
- large: typeContract,
112
- medium: typeContract,
113
- small: typeContract,
114
- },
115
-
116
- body: {
117
- large: typeContract,
118
- medium: typeContract,
119
- small: typeContract,
120
- },
121
- },
106
+ typography: typographyVariants.reduce(
107
+ (acc, variant) => ({
108
+ ...acc,
109
+ [variant]: typographySizes.reduce(
110
+ (acc, size) => ({
111
+ ...acc,
112
+ [size]: typeContract,
113
+ }),
114
+ {} as Record<TypographySize, typeof typeContract>,
115
+ ),
116
+ }),
117
+ {} as Record<
118
+ TypographyVariant,
119
+ Record<TypographySize, typeof typeContract>
120
+ >,
121
+ ),
122
122
 
123
123
  spacing: {
124
124
  0: null,
@@ -142,3 +142,17 @@ export const sys = createThemeContract({
142
142
  18: null,
143
143
  },
144
144
  });
145
+
146
+ export type Spacing = keyof typeof sys.spacing;
147
+ export type TypographyVariant = ArrayValues<typeof typographyVariants>;
148
+ export type TypographySize = ArrayValues<typeof typographySizes>;
149
+
150
+ export type Duration = {
151
+ [K in keyof typeof sys.motion.duration]: `${K}.${Extract<keyof (typeof sys.motion.duration)[K], string | number>}`;
152
+ }[keyof typeof sys.motion.duration];
153
+
154
+ export type Easing = {
155
+ [K in keyof typeof sys.motion.easing]: (typeof sys.motion.easing)[K] extends string
156
+ ? K
157
+ : `${K}.${Extract<keyof (typeof sys.motion.easing)[K], string | number>}`;
158
+ }[keyof typeof sys.motion.easing];
@@ -0,0 +1,26 @@
1
+ import { getProp } from '@kalink-ui/dibbly';
2
+
3
+ import { type Duration, type Easing, sys } from './system-contract.css';
4
+
5
+ export type CreateTransitionFn = (
6
+ props: string | string[],
7
+ options?: {
8
+ duration?: Duration;
9
+ easing?: Easing;
10
+ delay?: string;
11
+ },
12
+ ) => string;
13
+
14
+ export const transition: CreateTransitionFn = (props = ['all'], options = {}) =>
15
+ (Array.isArray(props) ? props : [props])
16
+ .map(
17
+ (animatedProp) =>
18
+ `${animatedProp} ${
19
+ options.duration
20
+ ? getProp(sys.motion.duration, options.duration)
21
+ : sys.motion.duration.medium[1]
22
+ } ${options.easing ? getProp(sys.motion.easing, options.easing) : sys.motion.easing.standard} ${
23
+ options.delay || '0ms'
24
+ }`,
25
+ )
26
+ .join(',');
@@ -1,8 +1,6 @@
1
1
  import { styleVariants } from '@vanilla-extract/css';
2
2
 
3
- import { sys } from './system-contract.css';
4
-
5
- type TypographySize = 'large' | 'medium' | 'small';
3
+ import { sys, TypographySize, TypographyVariant } from './system-contract.css';
6
4
 
7
5
  export const typography = Object.entries(sys.typography).reduce(
8
6
  (acc, [key, value]) => {
@@ -19,5 +17,5 @@ export const typography = Object.entries(sys.typography).reduce(
19
17
  }),
20
18
  };
21
19
  },
22
- {} as Record<keyof typeof sys.typography, Record<TypographySize, string>>,
20
+ {} as Record<TypographyVariant, Record<TypographySize, string>>,
23
21
  );
@@ -1,2 +1,6 @@
1
- export { extractSprinklesProps } from './extract-sprinkles-props';
2
- export { mapContractVars } from './map-contract-vars';
1
+ export {
2
+ argTypesFromRecipe,
3
+ argTypesFromSprinkles,
4
+ commonArgs,
5
+ CommonArgs,
6
+ } from './arg-types';
File without changes
File without changes