返回 presentation-ai
column.tsx
1 "use client";
2
3 import { cn } from "@/lib/utils";
4 import { PlateElement, type PlateElementProps } from "platejs/react";
5 import { type TColumnGroupElement } from "../plugins/column-plugin";
6 import { columnSizeVariant } from "../utils";
7
8 export default function ColumnGroup(
9 props: PlateElementProps<TColumnGroupElement>,
10 ) {
11 const {
12 columnSize,
13 columnType = "transparent",
14 alignment = "center",
15 } = props.element;
16
17 const getColumnTypeClass = () => {
18 switch (columnType) {
19 case "outline":
20 return "border-2 border-(--presentation-primary) bg-transparent";
21 case "solid":
22 return "bg-(--presentation-primary) bg-opacity-10 border border-(--presentation-primary)";
23 case "transparent":
24 return "bg-transparent border-none";
25 default:
26 return "bg-transparent border-2 border-(--presentation-primary)";
27 }
28 };
29
30 return (
31 <PlateElement {...props} className="mb-4">
32 <div
33 className={cn(
34 "max-w-full rounded-md p-4",
35 columnSizeVariant({ columnSize }),
36 getColumnTypeClass(),
37 // Only apply horizontal alignment, don't break the grid layout
38 alignment === "left" && "justify-start",
39 alignment === "right" && "justify-end",
40 alignment === "center" && "justify-center",
41 )}
42 >
43 {props.children}
44 </div>
45 </PlateElement>
46 );
47 }
48
48 lines Plain Text