Skip to content

Commit 50a40b4

Browse files
committed
Merge typography components into a single Typography component
1 parent ceb8cdb commit 50a40b4

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { cn } from "@/lib/utils";
2+
import { type VariantProps, cva } from "class-variance-authority";
3+
import type { HTMLAttributes } from "react";
4+
5+
const typographyVariants = cva("font-head", {
6+
variants: {
7+
variant: {
8+
h1: "text-5xl lg:text-6xl font-bold",
9+
h2: "text-3xl lg:text-4xl font-semibold",
10+
h3: "text-2xl font-medium",
11+
h4: "text-xl font-medium",
12+
h5: "text-lg font-medium",
13+
h6: "",
14+
},
15+
},
16+
defaultVariants: {
17+
variant: "h1",
18+
},
19+
});
20+
21+
interface TypographyProps
22+
extends HTMLAttributes<HTMLHeadingElement>,
23+
VariantProps<typeof typographyVariants> {
24+
className?: string;
25+
component?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
26+
}
27+
28+
export const Typography = ({
29+
className,
30+
component,
31+
variant,
32+
...props
33+
}: TypographyProps) => {
34+
const Component = component || "h1";
35+
return (
36+
<Component
37+
className={cn(typographyVariants({ variant }), className)}
38+
{...props}
39+
/>
40+
);
41+
};

0 commit comments

Comments
 (0)