Support grid layouts in the STACK flow component - #39
Conversation
📝 WalkthroughWalkthroughThe PR adds bounded CSS Grid rendering for embedded stack components, preserves flex fallback behavior for invalid configurations, adds coverage for the layout variants, and ignores Vitest attachment artifacts. ChangesStack grid layout
Vitest artifact ignoring
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
fcb9de7 to
774e089
Compare
Honor the items property on STACK flow elements so children can be laid out in an n-column grid (e.g. a 2 x 2 grid with items: 2). Non-numeric or absent values keep the existing flex layout. Refs thunder-id/thunderid#3703
774e089 to
ba92aa1
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/react/src/components/presentation/auth/AuthOptionFactory.tsx`:
- Around line 740-743: Update the slot-count validation in the items calculation
to require Number.isInteger(parsedItems) alongside the existing finite and
minimum checks, so fractional values retain the flex fallback before
MAX_STACK_ITEMS clamping. Add a regression case covering a fractional string
such as "2.5" and verify it does not enable grid mode.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 58b7f69a-a964-42a0-ba0c-5ab907f76eec
⛔ Files ignored due to path filters (3)
packages/react/.vitest-attachments/27677941df85b03d5d2cfa78a06ab03580dd9ac6.pngis excluded by!**/*.pngpackages/react/.vitest-attachments/3dab8c5a94eed1b7587e7dbb5fed1db2c644801d.pngis excluded by!**/*.pngpackages/react/.vitest-attachments/5a7d509e64e503baebcb9f280cb5bd323b6d722e.pngis excluded by!**/*.png
📒 Files selected for processing (3)
.gitignorepackages/react/src/components/presentation/auth/AuthOptionFactory.tsxpackages/react/src/components/presentation/auth/__tests__/AuthOptionFactory.test.tsx
Purpose
The STACK flow component in
@thunderid/reactalways renders its children as a flex row/column, so layouts like a 2 x 2 button grid (four login options, two per row) are impossible even though theEmbeddedFlowComponent.itemsproperty ("Number of items across the main axis (for Stack grid-like layouts)") already exists in@thunderid/javascript. This PR makes the renderer honoritems.Approach
AuthOptionFactory'sStackcase,itemsis the number of slots across the main axis anddirectionpicks that axis:row(default) makes it the column count (items: 2with four buttons renders a 2 x 2 grid), andcolumnmakes it the row count with children flowing into further columns.items >= 2. Stacks with a single slot or noitemskeep the existing flex layout unchanged, so flows authored before this change render exactly as before.itemsis parsed defensively from the SDK'sstring | numbertype: malformed values ("2invalid"), zero, and negatives fall back to flex, and the slot count is clamped so a mistyped value cannot render thousands of cells.getStackGridSxhelper in the companion PR.Related Issues
Related PRs
Checklist
Security checks
Summary by CodeRabbit
New Features
Chores