Skip to content

Lay out cells in a grid of equal columns - #101

Merged
czj merged 2 commits into
mainfrom
claude/confident-pasteur-jz0fj6
Nov 13, 2026
Merged

czj merged 2 commits into
mainfrom
claude/confident-pasteur-jz0fj6

Conversation

@czj

@czj czj commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Cards, catalogues and blocks of addresses side by side needed a row per line and widths computed by hand, and the last, shorter line came out with wider cells than the others. Part of #71.

grid(columns:) puts its cells columns to a line, all as wide, the last line's included. It is a box like the others, on the document or in a stack or a row.

  • Lines move whole: a line is as high as its tallest cell and goes whole to the next page; pages break between lines, never inside one.
  • Cards line up: a cell with a background or a border is drawn as high as its line, like a CSS grid's.
  • Two gaps: gap is one number, or [between lines, between columns].
  • Kept with the next: a cell with keep_with_next keeps its line with the next one, a heading in a cell for instance.
  • Wrong input raises: columns that is not a positive integer, a cell's width or grow, and gaps wider than the grid. Padding, background, border and keep_together work as on a stack.
Proof

test/native_grid_test.rb covers column positions, both gaps, line height, stretched decorations, page breaks between lines, keep_with_next, a decorated grid, a grid in a row, and the errors. The contract lists #grid on the document and on containers. A 40-card catalogue runs over two pages with whole lines and cards of equal height, and qpdf --check passes. rake test: 1333 runs, 0 failures; RuboCop is clean.

document.grid(columns: 3, gap: [16, 12]) puts its cells side by side, columns to a line, all as wide, the last line's included. A line is as high as its tallest cell and moves whole to the next page; pages break between lines. Cell widths and grow raise, a cell kept with the next keeps its line with the next one, and a grid with a background, a border or keep_together moves whole like a stack.

Assisted-by: Claude [Claude Code]
A cell with a background or a border reaches down to the bottom of its line, like a CSS grid's, so cards side by side line up.

Assisted-by: Claude [Claude Code]
@czj
czj merged commit bdbe1ec into main Nov 13, 2026
8 checks passed
@czj
czj deleted the claude/confident-pasteur-jz0fj6 branch November 13, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants