Add flexible cards-per-page support with dynamic grid layout

- Support common layouts: 1, 2, 3, 4, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 30
- Add fallback logic for arbitrary card counts using square root calculation
- Remove panic on unsupported values - now handles any reasonable number
- Enable layouts like 18 cards (3x6) for larger batches

Users can now specify any cards-per-page value and get a reasonable
grid layout automatically calculated.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock 2025-09-09 13:05:07 -05:00
parent 152c495c40
commit 0ab2a69b90
1 changed files with 31 additions and 3 deletions

View File

@ -270,16 +270,44 @@
let usable-height = page-height - margins.top - margins.bottom
// Determine grid layout
let (cols, rows) = if cards-per-page == 6 {
(2, 3)
let (cols, rows) = if cards-per-page == 1 {
(1, 1)
} else if cards-per-page == 2 {
(1, 2)
} else if cards-per-page == 3 {
(1, 3)
} else if cards-per-page == 4 {
(2, 2)
} else if cards-per-page == 6 {
(2, 3)
} else if cards-per-page == 8 {
(2, 4)
} else if cards-per-page == 9 {
(3, 3)
} else if cards-per-page == 10 {
(2, 5)
} else if cards-per-page == 12 {
(3, 4)
} else if cards-per-page == 15 {
(3, 5)
} else if cards-per-page == 16 {
(4, 4)
} else if cards-per-page == 18 {
(3, 6)
} else if cards-per-page == 20 {
(4, 5)
} else if cards-per-page == 24 {
(4, 6)
} else if cards-per-page == 25 {
(5, 5)
} else if cards-per-page == 30 {
(5, 6)
} else {
panic("Unsupported cards-per-page value")
// Try to find a reasonable grid for other values
let sqrt-cards = calc.sqrt(cards-per-page)
let cols-guess = calc.ceil(sqrt-cards)
let rows-guess = calc.ceil(cards-per-page / cols-guess)
(cols-guess, rows-guess)
}
let card-width = (usable-width - gutter * (cols - 1)) / cols