Skip to content

Add card size modes and dynamic grid layout for deck builder - #48

Open
TimBest wants to merge 2 commits into
mainfrom
claude/deck-builder-size-options-x1xiwp
Open

Add card size modes and dynamic grid layout for deck builder#48
TimBest wants to merge 2 commits into
mainfrom
claude/deck-builder-size-options-x1xiwp

Conversation

@TimBest

@TimBest TimBest commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR introduces flexible card layout sizing and a new "Full Size" mode for the deck builder, allowing shapes to maintain uniform size across all cards in a deck. Previously, cards always sized shapes to fit their individual shape count. Now users can choose between "Full Size" (uniform sizing across the deck) and "Max Size" (each card sizes independently).

Key Changes

  • New cardLayout.ts module: Implements dynamic grid layout computation that:

    • Calculates optimal grid dimensions (cols × rows) for any capacity (1-9)
    • Maximizes cell size while maintaining non-overlapping slots
    • Preserves exact pixel-for-pixel compatibility with the legacy 3×3 layout for capacities 7-9
    • Fills slots from center outward, matching the original layout's aesthetic
  • CardSvg component enhancement:

    • Added optional capacity prop to decouple shape sizing from individual card shape count
    • When capacity is provided, shapes size off that shared grid capacity instead of the card's own count
    • Defaults to card's own numbers value for backward compatibility ("Max Size" behavior)
  • New CardSizeSelect UI component: Radio button control for choosing between "Full Size" and "Max Size" modes

  • GeometricDeckGenerator updates:

    • Added cardSizeMode property to track the selected sizing mode
    • Computes fullSizeCapacity as the maximum numbers value across all cards in the deck
    • Passes appropriate capacity to CardSvg based on the selected mode
  • Type system: Added CardSizeMode type ("full" | "max") and updated Deck interface to include optional cardSizeMode property

  • GameEditor integration: Wired up CardSizeSelect to control deck generation and persistence

Notable Implementation Details

  • The grid layout algorithm is deterministic: ties in cell size are resolved by favoring more square grids, then fewer columns
  • Slot overlap is mathematically guaranteed to never occur by construction—the algorithm only selects cell sizes where inter-slot pitch exceeds cell size
  • The legacy layout is preserved as a literal constant rather than derived, ensuring pixel-identical rendering for capacities 7-9
  • Comprehensive test coverage validates grid computation, layout generation, and non-overlapping slot guarantees across all capacity/count combinations

https://claude.ai/code/session_01YPLPk2pADJj4uStZuvu4Dy

CardSvg previously sized every shape with a fixed 35-unit box on an
implicit 3x3 grid, regardless of how many shapes a card had, wasting
space on cards with fewer shapes.

Adds a "Card Size" control to the Game Editor: "Full Size" sizes every
card's shapes off the deck's largest shape count so sizing stays
uniform across the deck (reduces to the original fixed layout when
that max is 9, so existing decks render unchanged), and "Max Size"
sizes each card independently off its own shape count. Both compute a
non-overlapping grid via the new cardLayout module and persist with
the saved deck.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YPLPk2pADJj4uStZuvu4Dy
@netlify

netlify Bot commented Aug 4, 2026

Copy link
Copy Markdown

Deploy Preview for imaginative-dieffenbachia-3400e7 ready!

Name Link
🔨 Latest commit aedc015
🔍 Latest deploy log https://app.netlify.com/projects/imaginative-dieffenbachia-3400e7/deploys/6a72783321682000080f33a2
😎 Deploy Preview https://deploy-preview-48--imaginative-dieffenbachia-3400e7.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Reduce the outer whitespace around each card's shapes (.card svg
margin 20px -> 8px). Shape size itself is driven by max-height, so
this only shrinks the surrounding padding, not the shapes.

Also fix a Full Size edge case: a card with exactly one shape now
always renders dead center, even when the deck's shared capacity grid
(e.g. 5, a 2x3 grid) has no single cell centered on both axes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YPLPk2pADJj4uStZuvu4Dy
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