"use client"; /** * The media tiles inside a bubble. * * One item fills the bubble; several tile into a 2×2. Beyond four, the fourth * tile carries a "+N more" overlay rather than growing the bubble — a message * with twenty photos should still be one glanceable block. * * Every tile is square so the grid stays even regardless of what was sent; * portrait and landscape both crop to the same cell. */ import { Play } from "lucide-react"; import { attachmentUrl, type Attachment } from "@/lib/chat"; /** Tiles shown before the rest collapse into the "+N more" overlay. */ const MAX_TILES = 4; export function MediaGrid({ items, onOpen, }: { items: Attachment[]; /** Opens the lightbox at this index. */ onOpen: (index: number) => void; }) { if (items.length === 0) return null; const visible = items.slice(0, MAX_TILES); const hidden = items.length - visible.length; if (items.length === 1) { return ( ); } return ( // Two columns throughout: two items make a row, three or four make the // 2×2. A three-item grid deliberately leaves the fourth cell empty rather // than stretching one tile — an uneven crop reads worse than a gap.