This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
Théo LUDWIG 33b57bf173
All checks were successful
Chromatic / chromatic (push) Successful in 4m47s
CI / ci (push) Successful in 3m50s
CI / commitlint (push) Successful in 18s
Release / release (push) Successful in 1m0s
refactor: components struture
2024-07-31 15:46:01 +02:00

46 lines
1.2 KiB
TypeScript

import { classNames } from "@repo/config-tailwind/classNames"
import type { VariantProps } from "cva"
import { cva } from "cva"
const typographyVariants = cva({
variants: {
variant: {
h1: "text-4xl font-semibold",
h2: "text-3xl font-semibold",
h3: "text-2xl font-semibold",
h4: "text-xl font-semibold",
h5: "text-xl font-medium",
h6: "text-lg font-medium",
text1: "break-words text-base",
text2: "break-words text-sm",
},
},
})
export type TypographyProps<Component extends React.ElementType = "p"> = {
as?: Component
} & React.ComponentPropsWithoutRef<Component> &
VariantProps<typeof typographyVariants>
/**
* Typography and styling abstraction component used to ensure consistency and standardize text throughout your application.
* @param props
* @returns
*/
export const Typography = <Component extends React.ElementType = "p">(
props: TypographyProps<Component>,
): React.ReactNode => {
const { variant = "text1", as = "p", children, className, ...rest } = props
const ComponentAs = as
return (
<ComponentAs
className={classNames(typographyVariants({ variant }), className)}
{...rest}
>
{children}
</ComponentAs>
)
}