-
Notifications
You must be signed in to change notification settings - Fork 0
[CDX-327] Pass callbacks to ProductCard #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for passing callback functions to ProductCard components within a Carousel. The change enables parent components to handle product interactions (clicks, add to cart, add to wishlist) from carousel items.
Changes:
- Added
CarouselItemCallbackstype definition with three optional callback functions - Updated Carousel component to accept and pass through
itemCallbacksto ProductCard instances - Added comprehensive test coverage for all three callback scenarios plus the no-callbacks case
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/types/carouselTypes.ts | Defines new CarouselItemCallbacks type and adds itemCallbacks to CarouselOpts |
| src/components/carousel.tsx | Extracts callbacks from props and passes them to ProductCard components |
| spec/components/Carousel/Carousel.test.tsx | Adds test coverage for all callback scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Review Results✅ StrengthsWell-designed type-safe callback system with comprehensive test coverage for all three callback scenarios. 🚨 Critical IssuesNone
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Code Review Results✅ StrengthsWell-structured implementation with comprehensive test coverage for all three callbacks and proper optional handling. 🚨 Critical IssuesNone found.
|
Code Review Results✅ StrengthsWell-tested implementation with comprehensive test coverage for all three callback scenarios and proper edge case handling. 🚨 Critical IssuesNone
|
Code Review Results✅ StrengthsWell-tested implementation with comprehensive test coverage for all three callback scenarios and proper handling of optional callbacks. 🚨 Critical IssuesNone
|
| export type CarouselItemCallbacks<T = Product> = { | ||
| onProductClick?: (item: T, index: number) => void; | ||
| onAddToCart?: (e: React.MouseEvent, item: T, index: number) => void; | ||
| onAddToWishlist?: (e: React.MouseEvent, item: T, index: number) => void; | ||
| }; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we move this into the types for ProductCard instead? This will be then be generically interpreted if the consumer uses the carousel for others types
Mudaafi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I left a comment at https://github.com/Constructor-io/constructorio-ui-components/pull/28/changes#r2708353012 for considerations
|
Closing without merging in favor of handling this in consuming libraries |
No description provided.