Skip to content

add Masonry component#36

Open
bemky wants to merge 4 commits into
mainfrom
masonry
Open

add Masonry component#36
bemky wants to merge 4 commits into
mainfrom
masonry

Conversation

@bemky
Copy link
Copy Markdown
Owner

@bemky bemky commented May 6, 2026

Summary

  • New Masonry component (komp-masonry): a managed CSS-Grid layout where cellPattern declares per-row cell column counts and rowPattern declares repeating row track heights. gridCount defaults to the LCM of cellPattern row sums.
  • resizable adds drag handles between cells (snap to integer grid columns) and between rows (pixel-snapped row heights).
  • reorderable lets the user drag a cell into a different row; the destination row redistributes its cells evenly across gridCount and the source row redistributes too. The new layout is encoded back into cellPattern so it survives subsequent re-renders.

For the example cellPattern="3 3 6, 6 6, 7 5, 12", dragging the 7 cell into the second row produces "3 3 6, 4 4 4, 12, 12" — destination row evenly redistributes 3 cells across the 12-col grid; the orphaned 5 becomes a full-width row.

Test plan

  • Open /demo/masonry — initial 8-cell layout matches 3 3 6, 6 6, 7 5, 12
  • Drag right edge of a cell to resize; adjacent cell shrinks; snaps to integer columns
  • Drag a row divider to resize row height
  • Drag a cell into a different row; destination row redistributes evenly; source row redistributes
  • Drag a cell to between-row drop zone; new row of full width is inserted
  • After interaction, inspect cellPattern attribute reflects the new layout
  • npm test still passes
  • npm run docs builds without warnings

🤖 Generated with Claude Code

Pattern-driven CSS Grid layout. cellPattern declares per-row column
counts (e.g. "3 3 6, 6 6, 7 5, 12") and rowPattern declares row track
heights; both repeat to cover all children. gridCount derives from the
LCM of cellPattern row sums by default.

With resizable, drag handles snap cell widths to integer grid columns
and row heights to pixels. With reorderable, dropping a cell into a row
redistributes that row evenly across gridCount; the source row also
redistributes. After interaction the layout is encoded back into
cellPattern so it survives subsequent re-renders.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
bemky and others added 3 commits May 7, 2026 11:42
* main:
  fix scanPrototypesFor cache when class init is in flight (#37)
The last handle in each row was hidden because it had no neighbor to
resize against. Now it's visible and resizes the last cell against the
row's column budget — the row can shrink below columnCount, leaving
empty columns on the right. columnCount is pinned on first such drag
so the LCM recompute doesn't re-normalize the row back to full width.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant