| 1 | "use client"; |
| 2 | |
| 3 | // Import IconItem and constants |
| 4 | import { PlateElement, type PlateElementProps } from "platejs/react"; |
| 5 | |
| 6 | import { cn } from "@/lib/utils"; |
| 7 | import { type TIconListElement } from "../plugins/icon-list-plugin"; |
| 8 | import { |
| 9 | getDefaultColumnSize, |
| 10 | getIconListOrientation, |
| 11 | iconListColumnSizeVariant, |
| 12 | } from "../utils"; |
| 13 | |
| 14 | export function IconList({ |
| 15 | element, |
| 16 | children, |
| 17 | className, |
| 18 | ref, |
| 19 | ...props |
| 20 | }: PlateElementProps<TIconListElement>) { |
| 21 | const columnSize = |
| 22 | element.columnSize ?? getDefaultColumnSize(element.children.length); |
| 23 | const orientation = getIconListOrientation( |
| 24 | element.orientation, |
| 25 | element.children.length, |
| 26 | ); |
| 27 | |
| 28 | return ( |
| 29 | <PlateElement |
| 30 | ref={ref} |
| 31 | element={element} |
| 32 | className={cn("my-6", className)} |
| 33 | {...props} |
| 34 | > |
| 35 | <div className="@container/icon-list max-w-full"> |
| 36 | <div |
| 37 | data-icon-list-grid="true" |
| 38 | className={cn( |
| 39 | "gap-6", |
| 40 | orientation === "top" && "items-start", |
| 41 | iconListColumnSizeVariant({ |
| 42 | columnSize: columnSize as "sm" | "md" | "lg" | "xl", |
| 43 | }), |
| 44 | )} |
| 45 | > |
| 46 | {children} |
| 47 | </div> |
| 48 | </div> |
| 49 | </PlateElement> |
| 50 | ); |
| 51 | } |
| 52 |