返回 presentation-ai
presentation-title-static.tsx
根目录 / src / components / notebook / presentation / editor / custom-elements / static / presentation-title-static.tsx
1 import { cva } from "class-variance-authority";
2 import { SlateElement, type SlateElementProps } from "platejs/static";
3
4 import { cn } from "@/lib/utils";
5 import { type TPresentationTitleElement } from "../../lib";
6
7 function getTextAlignClass(alignment: TPresentationTitleElement["alignment"]) {
8 if (alignment === "left") return "text-left";
9 if (alignment === "right") return "text-right";
10 return "text-center";
11 }
12
13 const titleVariants = cva(
14 "my-2 font-black leading-[0.95] tracking-normal text-(--presentation-heading)",
15 {
16 variants: {
17 variant: {
18 display: "text-[4.75rem]",
19 humongous: "text-[6.5rem]",
20 title: "text-[3.5rem]",
21 },
22 },
23 },
24 );
25
26 export function PresentationTitleStatic(
27 props: SlateElementProps<TPresentationTitleElement>,
28 ) {
29 const alignment = props.element.alignment ?? "left";
30 const color =
31 props.element.textColor ??
32 props.element.color ??
33 "var(--presentation-heading)";
34
35 return (
36 <SlateElement
37 {...props}
38 className={cn(
39 titleVariants({ variant: props.element.variant ?? "title" }),
40 getTextAlignClass(alignment),
41 "[font-family:var(--presentation-heading-font)]",
42 )}
43 style={{
44 backgroundColor: props.element.backgroundColor,
45 color,
46 }}
47 >
48 {props.children}
49 </SlateElement>
50 );
51 }
52
52 lines Plain Text