| 1 | import { cva, type VariantProps } from "class-variance-authority"; |
| 2 | import { SlateElement, type SlateElementProps } from "platejs/static"; |
| 3 | import type * as React from "react"; |
| 4 | |
| 5 | const headingVariants = cva("relative mb-1", { |
| 6 | variants: { |
| 7 | variant: { |
| 8 | h1: "font-heading mt-[1.6em] pb-1 text-4xl font-bold", |
| 9 | h2: "font-heading mt-[1.4em] pb-px text-2xl font-semibold tracking-tight", |
| 10 | h3: "font-heading mt-[1em] pb-px text-xl font-semibold tracking-tight", |
| 11 | h4: "font-heading mt-[0.75em] text-lg font-semibold tracking-tight", |
| 12 | h5: "mt-[0.75em] text-lg font-semibold tracking-tight", |
| 13 | h6: "mt-[0.75em] text-base font-semibold tracking-tight", |
| 14 | }, |
| 15 | }, |
| 16 | }); |
| 17 | |
| 18 | export function HeadingElementStatic({ |
| 19 | variant = "h1", |
| 20 | ...props |
| 21 | }: SlateElementProps & VariantProps<typeof headingVariants>) { |
| 22 | return ( |
| 23 | <SlateElement |
| 24 | as={variant!} |
| 25 | className={headingVariants({ variant })} |
| 26 | {...props} |
| 27 | > |
| 28 | {props.children} |
| 29 | </SlateElement> |
| 30 | ); |
| 31 | } |
| 32 | |
| 33 | export function H1ElementStatic(props: SlateElementProps) { |
| 34 | return <HeadingElementStatic variant="h1" {...props} />; |
| 35 | } |
| 36 | |
| 37 | export function H2ElementStatic( |
| 38 | props: React.ComponentProps<typeof HeadingElementStatic>, |
| 39 | ) { |
| 40 | return <HeadingElementStatic variant="h2" {...props} />; |
| 41 | } |
| 42 | |
| 43 | export function H3ElementStatic( |
| 44 | props: React.ComponentProps<typeof HeadingElementStatic>, |
| 45 | ) { |
| 46 | return <HeadingElementStatic variant="h3" {...props} />; |
| 47 | } |
| 48 | |
| 49 | export function H4ElementStatic( |
| 50 | props: React.ComponentProps<typeof HeadingElementStatic>, |
| 51 | ) { |
| 52 | return <HeadingElementStatic variant="h4" {...props} />; |
| 53 | } |
| 54 | |
| 55 | export function H5ElementStatic( |
| 56 | props: React.ComponentProps<typeof HeadingElementStatic>, |
| 57 | ) { |
| 58 | return <HeadingElementStatic variant="h5" {...props} />; |
| 59 | } |
| 60 | |
| 61 | export function H6ElementStatic( |
| 62 | props: React.ComponentProps<typeof HeadingElementStatic>, |
| 63 | ) { |
| 64 | return <HeadingElementStatic variant="h6" {...props} />; |
| 65 | } |
| 66 |