// lib/layout.ts — bento tile sizing. Maps a source size to grid column/row spans. // The dashboard grid uses a fixed track height + dense auto-flow, so tiles of // different shapes pack together; card content scrolls inside its tile. import type { SourceSize } from "@/lib/schemas/source"; export const TILE_SPANS: Record = { sm: { col: 1, row: 1 }, md: { col: 1, row: 2 }, wide: { col: 2, row: 1 }, tall: { col: 1, row: 3 }, lg: { col: 2, row: 2 }, }; export function tileStyle(size: SourceSize): React.CSSProperties { const span = TILE_SPANS[size] ?? TILE_SPANS.md; return { gridColumn: `span ${span.col}`, gridRow: `span ${span.row}`, }; } // Free w×h bento: a card spans `cols` columns and `rows` rows directly. // The grid track is GRID_COL_MIN wide and GRID_ROW_PX tall (see Dashboard). export const GRID_COL_MIN = 280; // px — min column width (auto-fill minmax) export const GRID_ROW_PX = 128; // px — fixed row height export const GRID_GAP = 16; // px — grid gap export const MAX_ROWS = 8; // resize clamp for row span export function spanStyle(cols: number, rows: number): React.CSSProperties { return { gridColumn: `span ${Math.max(1, cols)}`, gridRow: `span ${Math.max(1, rows)}`, }; } export const SIZE_LABELS: Record = { sm: "Small", md: "Medium", wide: "Wide", tall: "Tall", lg: "Large", };