refactor(carousel): implement composable carousel with embla #226
+1,403
−715
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎡 Refactor: Carousel Component - Embla Composable API Migration
Summary
Complete refactor of the Carousel component from a monolithic preset-based implementation to a flexible composable API built on Embla Carousel. This change provides better developer experience, more flexibility, and improved code maintainability.
🎯 Key Changes
New Composable Carousel Architecture
CustomCarouselwith modular composable componentsCarousel,CarouselContent,CarouselItemas base building blocksCarouselPrevious,CarouselNext,CarouselDots,CarouselProgress,CarouselThumbnailsuseCarousel()hook for custom indicator developmentCarouselApi,CarouselOptions,CarouselPlugin,ThumbnailData)Enhanced Features
embla-carousel-wheel-gesturesplugin for mouse wheel navigationembla-carousel-autoplayplugin for automatic slide transitionsComponent API
Removed Components
Indicatoratom component (replaced byCarouselProgressandCarouselDots)PresetCarouselreferences from examples📦 Dependencies
embla-carousel-autoplay@^8.6.0embla-carousel-wheel-gestures@^8.1.0🔄 Migration Impact
Updated Components (13 files)
ProductCarousel: Migrated to composable APIProductCarouselIndicator: Refactored to useuseCarousel()hookEmptyCart: Updated carousel implementationAlgoliaProductsCarousel: Optimized with proper memo and cleanupHomeProductsCarousel: Performance improvements with Map-based lookupsHomeCategories: Migrated with responsive basis classesHomePopularBrandsSection: Updated to composable APIImproved Code Quality
📚 Documentation
🎨 Storybook Setup
@storybook/nextjsframework🐛 Bug Fixes
ProductCarousel(removed duplicateobject-center)staticDirsconfiguration🚀 Performance
✅ Breaking Changes
CustomCarouselcomponent no longer available (useCarousel+ composable children)PresetCarouselremoved (examples updated to composable pattern)Indicatorcomponent removed (useCarouselProgressorCarouselDots)📝 Testing Notes
All carousel implementations across the app have been updated and tested. Storybook provides interactive examples for all supported patterns.