Skip to content

feat(widgets): 4×5 grid, allowed block sizes and corner resize - #22

Merged
TheGeniusOfEternity merged 7 commits into
mainfrom
feat/grid-4x5
Oct 3, 2026
Merged

TheGeniusOfEternity merged 7 commits into
mainfrom
feat/grid-4x5

Conversation

@TheGeniusOfEternity

Copy link
Copy Markdown
Owner

Step 2 of the grid refactor. Stacked on #21.

Draft — merge together with step 3 (block size variants). Until blocks get 1×1 / 2×1 variants, every block's smallest size is 2×2, so a new 4×5 widget fits only 4 blocks: a 2×2 block can't use the odd 5th row, and the limit of 8 isn't reachable.

Summary

Grid (shared/widget/geometry.ts): 4 columns × up to 5 editable rows, 129px cells, 12px gap and block padding, 16px block radius. 4×4 = 600×600, 4×5 = 600×741.

Block sizes (shared/widget/blockSizes.ts): each type declares its sizes. For now that's the old sizes doubled (2×2, 2×4, 4×2, 4×4), so blocks keep their current look; variants come in step 3. snapToAllowedSize drives the editor.

Server:

  • validateLayouts rejects sizes the type doesn't support and layouts taller than 5 rows. Widgets migrated from the old grid that are already taller stay editable as long as a change doesn't make them taller.
  • MAX_WIDGET_BLOCKS = 8.
  • New blocks default to 2×2 at the first free spot; presets pack two per row.

Migration 20261003145347_grid_4_columns (data only):

  • every block layout ×2, so widgets look the same;
  • grid.columns = 4;
  • heights recomputed.

Verified on local data: all 8 widgets doubled exactly, heights match the formula. 5 of 8 ended up taller than 5 rows, because old widgets often stacked blocks in one column.

Editor:

  • corner resize with a snapped preview (size buttons removed);
  • a notice when a change would exceed 5 rows;
  • for migrated tall widgets, a notice with "Fit into 5 rows", which re-places blocks at their sizes or explains that they don't fit;
  • draft cache key bumped to v5; limit 8.

Fixes:

Docs: docs/design/grid-and-blocks.md covers the grid spec, the planned variant matrix and plan tiers (free 8 / paid 16 / special 20; only free is implemented). AGENTS.md and CHANGELOG.md updated.

Test plan

  • Migration on a local DB copy: layouts ×2, heights, columns (scripted before/after comparison)
  • Browser: migrated widget renders the same layout; corner resize 4×2 → 2×2 with neighbours repacking; "Fit into 5 rows" reports when blocks can't fit; no sideways shift
  • Tests: geometry (129px, 318/600/741 heights, free spot), block size snapping, server size/row rules incl. the migrated-widget exception, editor row limit and packing
  • format:check, lint, typecheck, test (54 client + 69 server), build, typecheck:api

- Geometry: 4 columns, 129px cells, 12px gap/padding, 16px block radius,
  max 5 editable rows; findFreeSpot/layoutsOverlap shared
- Shared BLOCK_SIZES registry (legacy sizes doubled for now),
  snapToAllowedSize; server rejects unsupported sizes and layouts taller
  than 5 rows (migrated taller widgets stay editable if they don't grow)
- Data migration: double every block layout, grid columns 4, recompute
  heights (widgets look the same)
- Editor: corner resize with snapped preview, row-limit notice, 'Fit into
  5 rows' for migrated widgets, draft cache v5, limit 8 blocks
- New blocks default to 2x2 at the first free spot
- Fix: FLIP animation lost in the SVG renderer switch; page shifting
  sideways on scrollIntoView (overflow-x: clip)
- docs/design/grid-and-blocks.md: grid spec, variant matrix, plan tiers
@vercel

vercel Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
widgecode Ignored Ignored Preview Oct 3, 2026 3:33pm UTC

The layout update schema still capped the list at 5, so the editor could
not save a widget with more blocks. Also update the 5-block messages.
- Per-type renderers in shared/widget/blocks/ chosen by size family
  (tiny 1x1, strip 2-3x1, wide 4x1, card, large); the previous designs
  become the card variant
- New layouts: 1x1, 2x1 and 4x1 for every data block, 4x2 for the GitHub
  profile and LeetCode; text fits itself to any size
- Shared parts: BigStat, SegmentBar, Avatar, fitFontSize, wrapText;
  compact 'add a username' state for small blocks
- BLOCK_SIZES gains compact sizes (legacy sizes kept for migrated
  widgets); text defaults to 2x1; new blocks fall back to smaller sizes
  when the default does not fit
- Fix: layout updates were capped at 5 blocks
- Tests render every block in every allowed size
Base automatically changed from refactor/single-svg-renderer to main October 3, 2026 15:29
@TheGeniusOfEternity
TheGeniusOfEternity marked this pull request as ready for review October 3, 2026 15:33
feat(widgets): size-aware block variants
@TheGeniusOfEternity
TheGeniusOfEternity merged commit 9feea52 into main Oct 3, 2026
3 checks passed
@TheGeniusOfEternity
TheGeniusOfEternity deleted the feat/grid-4x5 branch October 3, 2026 15:33
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