@latte-macchiat-io/latte-vanilla-components 0.0.207 → 0.0.208
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/package.json
CHANGED
@@ -9,8 +9,18 @@ export type HeadingProps = React.HTMLAttributes<HTMLHeadingElement> &
|
|
9
9
|
children: React.ReactNode;
|
10
10
|
};
|
11
11
|
|
12
|
+
const levelToSize: Record<AllowedHeading, NonNullable<HeadingProps['size']>> = {
|
13
|
+
h1: 'xxl',
|
14
|
+
h2: 'xl',
|
15
|
+
h3: 'lg',
|
16
|
+
h4: 'md',
|
17
|
+
h5: 'sm',
|
18
|
+
h6: 'xs',
|
19
|
+
};
|
20
|
+
|
12
21
|
export const Heading = ({ as, size, align, className, children }: HeadingProps) => {
|
13
|
-
const Component = as
|
22
|
+
const Component = as;
|
23
|
+
const resolvedSize = size ?? levelToSize[as];
|
14
24
|
|
15
|
-
return <Component className={clsx(headingRecipe({ size, align }), className)}>{children}</Component>;
|
25
|
+
return <Component className={clsx(headingRecipe({ size: resolvedSize, align, as }), className)}>{children}</Component>;
|
16
26
|
};
|
@@ -12,7 +12,7 @@ export const headingRecipe = recipe({
|
|
12
12
|
}),
|
13
13
|
|
14
14
|
variants: {
|
15
|
-
|
15
|
+
as: {
|
16
16
|
h1: {
|
17
17
|
fontWeight: themeContract.heading.h1.fontWeight,
|
18
18
|
fontFamily: themeContract.heading.h1.fontFamily,
|
@@ -109,8 +109,8 @@ export const headingRecipe = recipe({
|
|
109
109
|
},
|
110
110
|
|
111
111
|
defaultVariants: {
|
112
|
+
as: 'h2',
|
112
113
|
size: 'xl',
|
113
|
-
level: 'h2',
|
114
114
|
align: 'left',
|
115
115
|
},
|
116
116
|
});
|