| 1 | import { SlateElement, type SlateElementProps } from "platejs/static"; |
| 2 | |
| 3 | import { cn } from "@/lib/utils"; |
| 4 | import { getDefaultColumnSize } from "../../utils"; |
| 5 | |
| 6 | function getStaticComparisonGridColumns(columnSize: "sm" | "md" | "lg" | "xl") { |
| 7 | if (columnSize === "sm") return "grid-cols-4"; |
| 8 | if (columnSize === "md") return "grid-cols-3"; |
| 9 | if (columnSize === "lg") return "grid-cols-2"; |
| 10 | return "grid-cols-1"; |
| 11 | } |
| 12 | |
| 13 | export default function BeforeAfterGroupStatic(props: SlateElementProps) { |
| 14 | const { alignment = "center" } = props.element as { |
| 15 | alignment?: "left" | "center" | "right"; |
| 16 | columnSize?: "sm" | "md" | "lg" | "xl"; |
| 17 | }; |
| 18 | const columnSize = |
| 19 | (props.element.columnSize as "sm" | "md" | "lg" | "xl" | undefined) ?? |
| 20 | getDefaultColumnSize(props.element.children?.length ?? 0); |
| 21 | |
| 22 | return ( |
| 23 | <SlateElement {...props} className="mb-4"> |
| 24 | <div |
| 25 | className={cn( |
| 26 | "relative grid max-w-full auto-rows-fr items-stretch gap-6 *:min-w-0", |
| 27 | getStaticComparisonGridColumns(columnSize), |
| 28 | alignment === "left" && "justify-start", |
| 29 | alignment === "right" && "justify-end", |
| 30 | alignment === "center" && "justify-center", |
| 31 | )} |
| 32 | > |
| 33 | {props.children} |
| 34 | </div> |
| 35 | </SlateElement> |
| 36 | ); |
| 37 | } |
| 38 |