@kalink-ui/seedly 0.23.0 → 0.25.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @kalink-ui/seedly
2
2
 
3
+ ## 0.25.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f41d4a0: [Switcher] Correctly export types
8
+ - 810fdce: [Heading] Fix prop types definition
9
+
10
+ ## 0.24.0
11
+
12
+ ### Minor Changes
13
+
14
+ - 9072db5: [Heading] Allow for different pretitle and subtitle spacing
15
+
3
16
  ## 0.23.0
4
17
 
5
18
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kalink-ui/seedly",
3
- "version": "0.23.0",
3
+ "version": "0.25.0",
4
4
  "description": "A set of components for building UIs with React and TypeScript",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
@@ -39,12 +39,36 @@ export const headingRoot = recipe({
39
39
  },
40
40
  },
41
41
  },
42
+ justify: {
43
+ '@layer': {
44
+ [components]: {
45
+ alignItems: 'stretch',
46
+ textAlign: 'justify',
47
+ },
48
+ },
49
+ },
42
50
  },
51
+ },
52
+ });
53
+
54
+ export const pretitle = recipe({
55
+ variants: {
56
+ spacing: mapContractVars(sys.spacing, (key) => ({
57
+ '@layer': {
58
+ [components]: {
59
+ marginBlockEnd: sys.spacing[key],
60
+ },
61
+ },
62
+ })),
63
+ },
64
+ });
43
65
 
66
+ export const subtitle = recipe({
67
+ variants: {
44
68
  spacing: mapContractVars(sys.spacing, (key) => ({
45
69
  '@layer': {
46
70
  [components]: {
47
- gap: sys.spacing[key],
71
+ marginBlockStart: sys.spacing[key],
48
72
  },
49
73
  },
50
74
  })),
@@ -1,52 +1,48 @@
1
+ import { PolymorphicComponentProps } from '@kalink-ui/dibbly';
1
2
  import { clsx } from 'clsx';
2
3
  import { ElementType, ReactElement, ReactNode } from 'react';
3
4
 
4
5
  import { Spacing, TypographySize, TypographyVariant } from '../../styles';
5
6
  import { ConditionalWrapper } from '../conditional-wrapper';
6
- import { Text, TextProps } from '../text';
7
+ import { Text, TextProps, TextVariants } from '../text';
7
8
 
8
- import { headingRoot } from './heading.css';
9
+ import { headingRoot, pretitle, subtitle } from './heading.css';
9
10
 
10
11
  export type HeadingTypes = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
11
12
 
12
- export type HeadingProps<TUse extends ElementType = 'h2'> = Omit<
13
- TextProps<TUse>,
14
- 'variant' | 'children' | 'align'
15
- > & {
16
- align?: Extract<
17
- Pick<TextProps<TUse>, 'align'>['align'],
18
- 'start' | 'center' | 'end'
19
- >;
20
- /**
21
- * The typography used to render the text.
22
- */
23
- variant: Extract<TypographyVariant, 'display' | 'headline' | 'title'>;
24
-
25
- /**
26
- * If provided, the text will be rendered before the title.
27
- */
28
- pretitle?: ReactElement<TextProps<'p'>>;
29
-
30
- /**
31
- * If provided, the text will be rendered after the title.
32
- */
33
- subtitle?: ReactElement<TextProps<'p'>>;
34
-
35
- /**
36
- * The spacing between the title and the pretitle or subtitle.
37
- */
38
- spacing?: Spacing;
39
-
40
- /**
41
- * The text to render.
42
- */
43
- children: ReactNode;
44
-
45
- /**
46
- * The class to pass to the root element.
47
- */
48
- rootClassName?: string;
49
- };
13
+ export type HeadingProps<TUse extends ElementType = 'h2'> =
14
+ PolymorphicComponentProps<TUse> &
15
+ TextVariants & {
16
+ /**
17
+ * The typography used to render the text.
18
+ */
19
+ variant: Extract<TypographyVariant, 'display' | 'headline' | 'title'>;
20
+
21
+ /**
22
+ * The size of the typography used to render the text.
23
+ */
24
+ size?: TypographySize;
25
+
26
+ /**
27
+ * If provided, the text will be rendered before the title.
28
+ */
29
+ pretitle?: ReactElement<TextProps<'p'>>;
30
+
31
+ /**
32
+ * If provided, the text will be rendered after the title.
33
+ */
34
+ subtitle?: ReactElement<TextProps<'p'>>;
35
+
36
+ /**
37
+ * The text to render.
38
+ */
39
+ children: ReactNode;
40
+
41
+ /**
42
+ * The class to pass to the root element.
43
+ */
44
+ rootClassName?: string;
45
+ };
50
46
 
51
47
  const headingMapping: Record<
52
48
  HeadingTypes,
@@ -60,31 +56,32 @@ const headingMapping: Record<
60
56
  h6: { variant: 'headline', size: 'small' },
61
57
  };
62
58
 
63
- export function Heading<TUse extends HeadingTypes>({
64
- children,
65
- use = 'h2',
66
- size,
67
- variant,
68
- align,
69
- spacing,
70
- pretitle,
71
- subtitle,
72
- rootClassName,
73
- ref,
74
- ...rest
75
- }: HeadingProps<TUse>) {
59
+ export function Heading<TUse extends HeadingTypes>(props: HeadingProps<TUse>) {
60
+ const {
61
+ children,
62
+ use = 'h2',
63
+ size,
64
+ variant,
65
+ align,
66
+ pretitle,
67
+ subtitle,
68
+ rootClassName,
69
+ ref,
70
+ ...rest
71
+ } = props;
72
+
76
73
  return (
77
74
  <ConditionalWrapper
78
75
  ref={ref}
79
76
  use={'hgroup'}
80
77
  condition={!!pretitle || !!subtitle}
81
- className={clsx(headingRoot({ align, spacing }), rootClassName)}
78
+ className={clsx(headingRoot({ align }), rootClassName)}
82
79
  >
83
80
  {pretitle}
84
81
 
85
82
  <Text
86
83
  {...(!pretitle && !subtitle && { ref })}
87
- use={use}
84
+ use={use as HeadingProps<TUse>['use']}
88
85
  align={align}
89
86
  variant={variant ?? headingMapping[use].variant}
90
87
  size={size ?? headingMapping[use].size}
@@ -100,17 +97,26 @@ export function Heading<TUse extends HeadingTypes>({
100
97
 
101
98
  export type HeadingPretitleProps = Omit<TextProps<'p'>, 'children'> & {
102
99
  children?: string | null;
100
+ spacing?: Spacing;
103
101
  };
104
102
 
105
103
  Heading.Pretitle = function HeadingPretitle({
106
104
  variant = 'title',
107
105
  size = 'medium',
106
+ spacing,
108
107
  children,
108
+ className,
109
109
  ...rest
110
110
  }: HeadingPretitleProps) {
111
111
  return (
112
112
  children && (
113
- <Text use="p" variant={variant} size={size} {...rest}>
113
+ <Text
114
+ use="p"
115
+ variant={variant}
116
+ size={size}
117
+ className={clsx(pretitle({ spacing }), className)}
118
+ {...rest}
119
+ >
114
120
  {children}
115
121
  </Text>
116
122
  )
@@ -119,17 +125,26 @@ Heading.Pretitle = function HeadingPretitle({
119
125
 
120
126
  export type HeadingSubtitleProps = Omit<TextProps<'p'>, 'children'> & {
121
127
  children?: string | null;
128
+ spacing?: Spacing;
122
129
  };
123
130
 
124
131
  Heading.Subtitle = function HeadingSubtitle({
125
132
  variant = 'title',
126
133
  size = 'medium',
134
+ spacing,
127
135
  children,
136
+ className,
128
137
  ...rest
129
138
  }: HeadingSubtitleProps) {
130
139
  return (
131
140
  children && (
132
- <Text use="p" variant={variant} size={size} {...rest}>
141
+ <Text
142
+ use="p"
143
+ variant={variant}
144
+ size={size}
145
+ className={clsx(subtitle({ spacing }), className)}
146
+ {...rest}
147
+ >
133
148
  {children}
134
149
  </Text>
135
150
  )
@@ -13,7 +13,18 @@ type SheetTitleProps<TUse extends HeadingTypes> = ComponentPropsWithRef<
13
13
  export function SheetTitle<TUse extends HeadingTypes>(
14
14
  props: SheetTitleProps<TUse>,
15
15
  ) {
16
- const { use = 'h2', className, children, variant, size, ...rest } = props;
16
+ const {
17
+ use = 'h2',
18
+ className,
19
+ children,
20
+ variant,
21
+ size,
22
+ align,
23
+ subtitle,
24
+ pretitle,
25
+ rootClassName,
26
+ ...rest
27
+ } = props;
17
28
 
18
29
  return (
19
30
  <Title asChild {...rest}>
@@ -22,6 +33,10 @@ export function SheetTitle<TUse extends HeadingTypes>(
22
33
  variant={variant}
23
34
  size={size}
24
35
  className={className}
36
+ align={align}
37
+ pretitle={pretitle}
38
+ subtitle={subtitle}
39
+ rootClassName={rootClassName}
25
40
  >
26
41
  {children}
27
42
  </Heading>
@@ -1,2 +1,2 @@
1
- export { Switcher } from './switcher';
1
+ export { Switcher, type SwitcherProps } from './switcher';
2
2
  export { switcherRecipe, type SwitcherVariants } from './switcher.css';
@@ -7,13 +7,14 @@ import { ElementType } from 'react';
7
7
 
8
8
  import { switcherRecipe, SwitcherVariants, thresholdVar } from './switcher.css';
9
9
 
10
- type SwitcherProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> &
11
- SwitcherVariants & {
12
- /**
13
- * The threshold at which to switch between horizontal and vertical layouts
14
- */
15
- threshold?: string;
16
- };
10
+ export type SwitcherProps<TUse extends ElementType> =
11
+ PolymorphicComponentProps<TUse> &
12
+ SwitcherVariants & {
13
+ /**
14
+ * The threshold at which to switch between horizontal and vertical layouts
15
+ */
16
+ threshold?: string;
17
+ };
17
18
 
18
19
  /**
19
20
  * Switch directly between horizontal and vertical layouts