import { Children, isValidElement, type ReactNode } from "react"; import { cn } from "@/lib/utils"; import { gridSizeStyle, type GridSize } from "@/components/panel-layout"; import { SeamlessTileContext } from "./context"; import { BottomEdge } from "./edge"; /** * A fixed grid of tiles edge to edge with one line between neighbours, for * stat strips and card lists. `size` is tiles per row ("auto" fits as many as * `minWidth` allows). Use TileGrid when people should move and resize tiles. */ export function TileWall({ size = "auto", minWidth = 280, gridClassName, className, children, }: { size?: GridSize; minWidth?: number; /** Column classes (like "grid-cols-1 md:grid-cols-3") in place of size. */ gridClassName?: string; className?: string; children: ReactNode; }) { const tiles = Children.toArray(children); return ( {/* The grid sits a pixel wider so the right edge line is cut off. */}
{tiles.map((tile, index) => (
{tile}
))}
); } function keyOf(node: ReactNode, index: number): string | number { return isValidElement(node) && node.key !== null ? node.key : index; }