@kalink-ui/seedly 0.5.0 → 0.7.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 (34) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +25 -14
  3. package/src/components/box/box.css.ts +34 -13
  4. package/src/components/box/box.tsx +1 -2
  5. package/src/components/button/button.tsx +4 -8
  6. package/src/components/center/center.css.ts +26 -9
  7. package/src/components/center/center.tsx +1 -2
  8. package/src/components/cluster/cluster.css.ts +69 -16
  9. package/src/components/cluster/cluster.tsx +1 -2
  10. package/src/components/cover/cover.css.ts +42 -13
  11. package/src/components/cover/cover.tsx +1 -2
  12. package/src/components/frame/frame.css.ts +54 -20
  13. package/src/components/frame/frame.tsx +1 -2
  14. package/src/components/grid/grid.css.ts +14 -5
  15. package/src/components/grid/grid.tsx +1 -2
  16. package/src/components/sidebar/sidebar.css.ts +43 -14
  17. package/src/components/sidebar/sidebar.tsx +1 -2
  18. package/src/components/stack/stack.css.ts +19 -6
  19. package/src/components/stack/stack.tsx +1 -2
  20. package/src/components/switcher/switcher.css.ts +45 -12
  21. package/src/components/switcher/switcher.tsx +1 -2
  22. package/src/components/text/index.ts +1 -0
  23. package/src/components/text/text.css.ts +15 -0
  24. package/src/components/text/text.tsx +43 -0
  25. package/src/styles/layers.css.ts +6 -0
  26. package/src/styles/reset.css.ts +116 -0
  27. package/src/styles/seed/seed.tsx +3 -3
  28. package/src/styles/system-contract.css.ts +2 -2
  29. package/src/styles/typography.css.ts +23 -0
  30. package/src/utils/extract-sprinkles-props.ts +1 -0
  31. package/src/utils/index.ts +0 -1
  32. package/src/types/index.ts +0 -5
  33. package/src/types/utils.types.ts +0 -15
  34. package/src/utils/is-object.ts +0 -3
@@ -1,6 +1,7 @@
1
1
  import { createVar } from '@vanilla-extract/css';
2
2
  import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
3
3
 
4
+ import { components } from '../../styles/layers.css';
4
5
  import { sys } from '../../styles/system-contract.css';
5
6
  import { mapContractVars } from '../../utils/map-contract-vars';
6
7
 
@@ -8,17 +9,25 @@ export const minSizeVar = createVar();
8
9
 
9
10
  export const gridRecipe = recipe({
10
11
  base: {
11
- display: 'grid',
12
- gridTemplateColumns: `repeat(auto-fill, minmax(min(${minSizeVar}, 100%), 1fr))`,
12
+ '@layer': {
13
+ [components]: {
14
+ display: 'grid',
15
+ gridTemplateColumns: `repeat(auto-fill, minmax(min(${minSizeVar}, 100%), 1fr))`,
13
16
 
14
- vars: {
15
- [minSizeVar]: '250px',
17
+ vars: {
18
+ [minSizeVar]: '250px',
19
+ },
20
+ },
16
21
  },
17
22
  },
18
23
 
19
24
  variants: {
20
25
  spacing: mapContractVars(sys.spacing, (key) => ({
21
- gridGap: sys.spacing[key],
26
+ '@layer': {
27
+ [components]: {
28
+ gridGap: sys.spacing[key],
29
+ },
30
+ },
22
31
  })),
23
32
  },
24
33
  });
@@ -1,11 +1,10 @@
1
1
  'use client';
2
2
 
3
+ import { PolymorphicComponentProps } from '@kalink-ui/dibbly/types';
3
4
  import { assignInlineVars } from '@vanilla-extract/dynamic';
4
5
  import { clsx } from 'clsx';
5
6
  import { ElementType } from 'react';
6
7
 
7
- import { PolymorphicComponentProps } from '../../types/utils.types';
8
-
9
8
  import { gridRecipe, GridVariants, minSizeVar } from './grid.css';
10
9
 
11
10
  type GridProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> & {
@@ -1,6 +1,7 @@
1
1
  import { createVar, globalStyle } from '@vanilla-extract/css';
2
2
  import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
3
3
 
4
+ import { components } from '../../styles/layers.css';
4
5
  import { sys } from '../../styles/system-contract.css';
5
6
  import { mapContractVars } from '../../utils/map-contract-vars';
6
7
 
@@ -9,22 +10,34 @@ export const contentMinWidthVar = createVar();
9
10
 
10
11
  export const sidebarRecipe = recipe({
11
12
  base: {
12
- display: 'flex',
13
- flexWrap: 'wrap',
13
+ '@layer': {
14
+ [components]: {
15
+ display: 'flex',
16
+ flexWrap: 'wrap',
14
17
 
15
- vars: {
16
- [contentMinWidthVar]: '50%',
18
+ vars: {
19
+ [contentMinWidthVar]: '50%',
20
+ },
21
+ },
17
22
  },
18
23
  },
19
24
 
20
25
  variants: {
21
26
  spacing: mapContractVars(sys.spacing, (key) => ({
22
- gap: sys.spacing[key],
27
+ '@layer': {
28
+ [components]: {
29
+ gap: sys.spacing[key],
30
+ },
31
+ },
23
32
  })),
24
33
 
25
34
  noStretch: {
26
35
  true: {
27
- alignItems: 'flex-start',
36
+ '@layer': {
37
+ [components]: {
38
+ alignItems: 'flex-start',
39
+ },
40
+ },
28
41
  },
29
42
  },
30
43
 
@@ -46,23 +59,39 @@ export const sidebarRecipe = recipe({
46
59
  });
47
60
 
48
61
  globalStyle(`${sidebarRecipe.classNames.base} > *`, {
49
- flexGrow: 1,
62
+ '@layer': {
63
+ [components]: {
64
+ flexGrow: 1,
65
+ },
66
+ },
50
67
  });
51
68
 
52
69
  globalStyle(`${sidebarRecipe.classNames.variants.sideWidth.true} > *`, {
53
- flexBasis: sideWidthVar,
70
+ '@layer': {
71
+ [components]: {
72
+ flexBasis: sideWidthVar,
73
+ },
74
+ },
54
75
  });
55
76
 
56
77
  globalStyle(`${sidebarRecipe.classNames.variants.side.left} > :last-child`, {
57
- flexBasis: 0,
58
- flexGrow: 999,
59
- minInlineSize: contentMinWidthVar,
78
+ '@layer': {
79
+ [components]: {
80
+ flexBasis: 0,
81
+ flexGrow: 999,
82
+ minInlineSize: contentMinWidthVar,
83
+ },
84
+ },
60
85
  });
61
86
 
62
87
  globalStyle(`${sidebarRecipe.classNames.variants.side.right} > :first-child`, {
63
- flexBasis: 0,
64
- flexGrow: 999,
65
- minInlineSize: contentMinWidthVar,
88
+ '@layer': {
89
+ [components]: {
90
+ flexBasis: 0,
91
+ flexGrow: 999,
92
+ minInlineSize: contentMinWidthVar,
93
+ },
94
+ },
66
95
  });
67
96
 
68
97
  export type SidebarVariants = NonNullable<RecipeVariants<typeof sidebarRecipe>>;
@@ -1,11 +1,10 @@
1
1
  'use client';
2
2
 
3
+ import { PolymorphicComponentProps } from '@kalink-ui/dibbly/types';
3
4
  import { assignInlineVars } from '@vanilla-extract/dynamic';
4
5
  import { clsx } from 'clsx';
5
6
  import { ElementType } from 'react';
6
7
 
7
- import { PolymorphicComponentProps } from '../../types/utils.types';
8
-
9
8
  import {
10
9
  contentMinWidthVar,
11
10
  sidebarRecipe,
@@ -1,6 +1,7 @@
1
1
  import { createVar, globalStyle } from '@vanilla-extract/css';
2
2
  import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
3
3
 
4
+ import { components } from '../../styles/layers.css';
4
5
  import { sys } from '../../styles/system-contract.css';
5
6
  import { mapContractVars } from '../../utils/map-contract-vars';
6
7
 
@@ -8,9 +9,13 @@ const spacing = createVar();
8
9
 
9
10
  export const stackRecipe = recipe({
10
11
  base: {
11
- display: 'flex',
12
- flexDirection: 'column',
13
- justifyContent: 'flex-start',
12
+ '@layer': {
13
+ [components]: {
14
+ display: 'flex',
15
+ flexDirection: 'column',
16
+ justifyContent: 'flex-start',
17
+ },
18
+ },
14
19
  },
15
20
 
16
21
  variants: {
@@ -19,8 +24,12 @@ export const stackRecipe = recipe({
19
24
  },
20
25
 
21
26
  spacing: mapContractVars(sys.spacing, (key) => ({
22
- vars: {
23
- [spacing]: sys.spacing[key],
27
+ '@layer': {
28
+ [components]: {
29
+ vars: {
30
+ [spacing]: sys.spacing[key],
31
+ },
32
+ },
24
33
  },
25
34
  })),
26
35
  },
@@ -29,7 +38,11 @@ export const stackRecipe = recipe({
29
38
  globalStyle(
30
39
  `${stackRecipe.classNames.base} > * + *, ${stackRecipe.classNames.variants.recursive.true} * + *`,
31
40
  {
32
- marginBlockStart: spacing,
41
+ '@layer': {
42
+ [components]: {
43
+ marginBlockStart: spacing,
44
+ },
45
+ },
33
46
  },
34
47
  );
35
48
 
@@ -1,8 +1,7 @@
1
+ import { PolymorphicComponentProps } from '@kalink-ui/dibbly/types';
1
2
  import { clsx } from 'clsx';
2
3
  import { ElementType } from 'react';
3
4
 
4
- import { PolymorphicComponentProps } from '../../types/utils.types';
5
-
6
5
  import { stackRecipe, StackVariants } from './stack.css';
7
6
 
8
7
  type StackProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> & {
@@ -1,6 +1,7 @@
1
1
  import { createVar, globalStyle } from '@vanilla-extract/css';
2
2
  import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
3
3
 
4
+ import { components } from '../../styles/layers.css';
4
5
  import { sys } from '../../styles/system-contract.css';
5
6
  import { mapContractVars } from '../../utils/map-contract-vars';
6
7
 
@@ -9,11 +10,15 @@ export const limitVar = createVar();
9
10
 
10
11
  export const switcherRecipe = recipe({
11
12
  base: {
12
- display: 'flex',
13
- flexWrap: 'wrap',
13
+ '@layer': {
14
+ [components]: {
15
+ display: 'flex',
16
+ flexWrap: 'wrap',
14
17
 
15
- vars: {
16
- [thresholdVar]: sys.layout.measure,
18
+ vars: {
19
+ [thresholdVar]: sys.layout.measure,
20
+ },
21
+ },
17
22
  },
18
23
  },
19
24
 
@@ -22,7 +27,11 @@ export const switcherRecipe = recipe({
22
27
  * The space (margin) between the child elements
23
28
  */
24
29
  spacing: mapContractVars(sys.spacing, (key) => ({
25
- gap: sys.spacing[key],
30
+ '@layer': {
31
+ [components]: {
32
+ gap: sys.spacing[key],
33
+ },
34
+ },
26
35
  })),
27
36
 
28
37
  /**
@@ -39,8 +48,12 @@ export const switcherRecipe = recipe({
39
48
  });
40
49
 
41
50
  globalStyle(`${switcherRecipe.classNames.base} > *`, {
42
- flexBasis: `calc((${thresholdVar} - 100%) * 999)`,
43
- flexGrow: 1,
51
+ '@layer': {
52
+ [components]: {
53
+ flexBasis: `calc((${thresholdVar} - 100%) * 999)`,
54
+ flexGrow: 1,
55
+ },
56
+ },
44
57
  });
45
58
 
46
59
  globalStyle(
@@ -48,7 +61,11 @@ globalStyle(
48
61
  switcherRecipe.classNames.variants.limit[2]
49
62
  } > :nth-last-child(n+3) ~ *`,
50
63
  {
51
- flexBasis: '100%',
64
+ '@layer': {
65
+ [components]: {
66
+ flexBasis: '100%',
67
+ },
68
+ },
52
69
  },
53
70
  );
54
71
 
@@ -57,7 +74,11 @@ globalStyle(
57
74
  switcherRecipe.classNames.variants.limit[3]
58
75
  } > :nth-last-child(n+4) ~ *`,
59
76
  {
60
- flexBasis: '100%',
77
+ '@layer': {
78
+ [components]: {
79
+ flexBasis: '100%',
80
+ },
81
+ },
61
82
  },
62
83
  );
63
84
 
@@ -66,7 +87,11 @@ globalStyle(
66
87
  switcherRecipe.classNames.variants.limit[4]
67
88
  } > :nth-last-child(n+5) ~ *`,
68
89
  {
69
- flexBasis: '100%',
90
+ '@layer': {
91
+ [components]: {
92
+ flexBasis: '100%',
93
+ },
94
+ },
70
95
  },
71
96
  );
72
97
 
@@ -75,7 +100,11 @@ globalStyle(
75
100
  switcherRecipe.classNames.variants.limit[5]
76
101
  } > :nth-last-child(n+6) ~ *`,
77
102
  {
78
- flexBasis: '100%',
103
+ '@layer': {
104
+ [components]: {
105
+ flexBasis: '100%',
106
+ },
107
+ },
79
108
  },
80
109
  );
81
110
 
@@ -84,7 +113,11 @@ globalStyle(
84
113
  switcherRecipe.classNames.variants.limit[6]
85
114
  } > :nth-last-child(n+7) ~ *`,
86
115
  {
87
- flexBasis: '100%',
116
+ '@layer': {
117
+ [components]: {
118
+ flexBasis: '100%',
119
+ },
120
+ },
88
121
  },
89
122
  );
90
123
 
@@ -1,11 +1,10 @@
1
1
  'use client';
2
2
 
3
+ import { PolymorphicComponentProps } from '@kalink-ui/dibbly/types';
3
4
  import { assignInlineVars } from '@vanilla-extract/dynamic';
4
5
  import { clsx } from 'clsx';
5
6
  import { ElementType } from 'react';
6
7
 
7
- import { PolymorphicComponentProps } from '../../types/utils.types';
8
-
9
8
  import { switcherRecipe, SwitcherVariants, thresholdVar } from './switcher.css';
10
9
 
11
10
  type SwitcherProps<TUse extends ElementType> =
@@ -0,0 +1 @@
1
+ export { Text } from './text';
@@ -0,0 +1,15 @@
1
+ import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
2
+
3
+ export const textRecipe = recipe({
4
+ variants: {
5
+ ellipsis: {
6
+ true: {
7
+ whiteSpace: 'nowrap',
8
+ textOverflow: 'ellipsis',
9
+ overflow: 'hidden',
10
+ },
11
+ },
12
+ },
13
+ });
14
+
15
+ export type TextVariants = NonNullable<RecipeVariants<typeof textRecipe>>;
@@ -0,0 +1,43 @@
1
+ import { getProp } from '@kalink-ui/dibbly';
2
+ import { PathsOf, PolymorphicComponentProps } from '@kalink-ui/dibbly/types';
3
+ import { clsx } from 'clsx';
4
+ import { ElementType } from 'react';
5
+
6
+ import { typography as typographyVariants } from '../../styles/typography.css';
7
+ import { Box } from '../box';
8
+
9
+ import { textRecipe, type TextVariants } from './text.css';
10
+
11
+ type TextProps<TUse extends React.ElementType> =
12
+ PolymorphicComponentProps<TUse> & {
13
+ /**
14
+ * The typography used to render the text.
15
+ */
16
+ typography?: PathsOf<typeof typographyVariants>;
17
+ /**
18
+ * If true, use an ellipsis when the text overflows the element.
19
+ */
20
+ ellipsis?: TextVariants['ellipsis'];
21
+ };
22
+
23
+ export function Text<TUse extends ElementType>({
24
+ className,
25
+ typography,
26
+ ellipsis,
27
+ ...props
28
+ }: TextProps<TUse>) {
29
+ const { use = 'span', ...rest } = props;
30
+
31
+ return (
32
+ <Box
33
+ // See `frontend/components/box/box.types.ts` for why the cast is required
34
+ use={use as TextProps<TUse>['use']}
35
+ className={clsx(
36
+ textRecipe({ ellipsis }),
37
+ typography && getProp(typographyVariants, typography),
38
+ className,
39
+ )}
40
+ {...rest}
41
+ />
42
+ );
43
+ }
@@ -0,0 +1,6 @@
1
+ import { globalLayer } from '@vanilla-extract/css';
2
+
3
+ export const base = globalLayer('base');
4
+ export const components = globalLayer('components');
5
+ export const utilities = globalLayer('utilities');
6
+ export const overrides = globalLayer('overrides');
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Minimal reset based on Josh's Custom CSS Reset
3
+ * https://www.joshwcomeau.com/css/custom-css-reset/
4
+ */
5
+ import { globalStyle } from '@vanilla-extract/css';
6
+
7
+ import { base } from './layers.css';
8
+
9
+ globalStyle('*, *::before, *::after', {
10
+ '@layer': {
11
+ [base]: {
12
+ boxSizing: 'border-box',
13
+ },
14
+ },
15
+ });
16
+
17
+ globalStyle('*', {
18
+ '@layer': {
19
+ [base]: {
20
+ margin: 0,
21
+ },
22
+ },
23
+ });
24
+
25
+ globalStyle('body', {
26
+ '@layer': {
27
+ [base]: {
28
+ WebkitFontSmoothing: 'antialiased',
29
+ },
30
+ },
31
+ });
32
+
33
+ globalStyle('img, picture, video, canvas, svg', {
34
+ '@layer': {
35
+ [base]: {
36
+ display: 'block',
37
+ maxWidth: '100%',
38
+ },
39
+ },
40
+ });
41
+
42
+ globalStyle('input, button, textarea, select', {
43
+ '@layer': {
44
+ [base]: {
45
+ font: 'inherit',
46
+ },
47
+ },
48
+ });
49
+
50
+ globalStyle('p, h1, h2, h3, h4, h5, h6', {
51
+ '@layer': {
52
+ [base]: {
53
+ overflowWrap: 'break-word',
54
+ },
55
+ },
56
+ });
57
+
58
+ globalStyle('p', {
59
+ '@layer': {
60
+ [base]: {
61
+ textWrap: 'pretty',
62
+ },
63
+ },
64
+ });
65
+
66
+ globalStyle('h1, h2, h3, h4, h5, h6', {
67
+ '@layer': {
68
+ [base]: {
69
+ textWrap: 'balance',
70
+ },
71
+ },
72
+ });
73
+
74
+ globalStyle('button', {
75
+ '@layer': {
76
+ [base]: {
77
+ border: 'none',
78
+
79
+ cursor: 'pointer',
80
+ },
81
+ },
82
+ });
83
+
84
+ globalStyle('a', {
85
+ '@layer': {
86
+ [base]: {
87
+ textDecoration: 'none',
88
+ },
89
+ },
90
+ });
91
+
92
+ globalStyle('fieldset', {
93
+ '@layer': {
94
+ [base]: {
95
+ padding: 0,
96
+
97
+ border: 'none',
98
+ },
99
+ },
100
+ });
101
+
102
+ globalStyle('legend', {
103
+ '@layer': {
104
+ [base]: {
105
+ width: '100%',
106
+ },
107
+ },
108
+ });
109
+
110
+ globalStyle('pre', {
111
+ '@layer': {
112
+ [base]: {
113
+ whiteSpace: 'pre-wrap',
114
+ },
115
+ },
116
+ });
@@ -6,7 +6,7 @@ import {
6
6
  type SprinklesFnBase,
7
7
  } from '../../utils/extract-sprinkles-props';
8
8
 
9
- import type { PolymorphicComponentProps } from '../../types/utils.types';
9
+ import type { PolymorphicComponentProps } from '@kalink-ui/dibbly/types';
10
10
  import type { ElementType } from 'react';
11
11
 
12
12
  /**
@@ -22,10 +22,10 @@ export type SeedProps<
22
22
  TSprinklesFn extends SprinklesFnBase,
23
23
  > = PolymorphicComponentProps<TUse> & GetSprinkles<TSprinklesFn>;
24
24
 
25
- export interface CreateSeedParams<SprinklesFn> {
25
+ export type CreateSeedParams<SprinklesFn> = {
26
26
  sprinkles: SprinklesFn;
27
27
  defaultClassName?: string;
28
- }
28
+ };
29
29
 
30
30
  export function plantSeed<SprinklesFn extends SprinklesFnBase>({
31
31
  sprinkles,
@@ -1,12 +1,12 @@
1
1
  import { createThemeContract } from '@vanilla-extract/css';
2
2
 
3
- const typeContract = {
3
+ export const typeContract = {
4
4
  font: null,
5
5
  weight: null,
6
6
  lineHeight: null,
7
7
  tracking: null,
8
8
  size: null,
9
- };
9
+ } as const;
10
10
 
11
11
  export const sys = createThemeContract({
12
12
  layout: {
@@ -0,0 +1,23 @@
1
+ import { styleVariants } from '@vanilla-extract/css';
2
+
3
+ import { sys } from './system-contract.css';
4
+
5
+ type TypographySize = 'large' | 'medium' | 'small';
6
+
7
+ export const typography = Object.entries(sys.typography).reduce(
8
+ (acc, [key, value]) => {
9
+ return {
10
+ ...acc,
11
+ [key]: styleVariants(value, (variant) => {
12
+ return {
13
+ fontFamily: variant.font,
14
+ fontWeight: variant.weight,
15
+ lineHeight: variant.lineHeight,
16
+ letterSpacing: variant.tracking,
17
+ fontSize: variant.size,
18
+ };
19
+ }),
20
+ };
21
+ },
22
+ {} as Record<keyof typeof sys.typography, Record<TypographySize, string>>,
23
+ );
@@ -1,6 +1,7 @@
1
1
  import type { SprinklesProperties } from '@vanilla-extract/sprinkles';
2
2
  import type { UnknownRecord } from 'type-fest';
3
3
 
4
+ /* eslint-disable-next-line @typescript-eslint/consistent-type-definitions */
4
5
  export interface SprinklesFnBase {
5
6
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
6
7
  (...args: any): string;
@@ -1,3 +1,2 @@
1
1
  export { extractSprinklesProps } from './extract-sprinkles-props';
2
- export { isObject } from './is-object';
3
2
  export { mapContractVars } from './map-contract-vars';
@@ -1,5 +0,0 @@
1
- export {
2
- type PolymorphicComponentProps,
3
- type DistributiveOmit,
4
- type UnwrapArray,
5
- } from './utils.types';
@@ -1,15 +0,0 @@
1
- import type { ComponentPropsWithRef, ElementType } from 'react';
2
-
3
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4
- export type DistributiveOmit<T, TOmitted extends PropertyKey> = T extends any
5
- ? Omit<T, TOmitted>
6
- : never;
7
-
8
- export type UnwrapArray<R> = R extends unknown[] ? UnwrapArray<R[number]> : R;
9
-
10
- export type PolymorphicComponentProps<TUse extends ElementType> = {
11
- use?: TUse;
12
- } & DistributiveOmit<
13
- ComponentPropsWithRef<ElementType extends TUse ? 'div' : TUse>,
14
- 'use'
15
- >;
@@ -1,3 +0,0 @@
1
- export const isObject = <T extends object>(value: unknown): value is T => {
2
- return !!value && typeof value === "object" && !Array.isArray(value);
3
- };