▍ humdrum codex / soft
1.4 KB raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// 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<SourceSize, { col: number; row: number }> = {
  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<SourceSize, string> = {
  sm: "Small",
  md: "Medium",
  wide: "Wide",
  tall: "Tall",
  lg: "Large",
};