Overview
At Blinkit, product presentation is crucial for customer engagement and sales. Our product detail pages heavily rely on rich media to showcase items like groceries, electronics, and household essentials. A well-designed image carousel allows customers to effortlessly browse through multiple product angles, variations, or related items, significantly enhancing their shopping experience and aiding in purchase decisions.
This problem challenges you to build a robust and user-friendly image carousel component, similar to what you'd find on our product pages. This component will be reusable across various parts of our application, requiring attention to detail, performance, and accessibility.
What you need to do / Task
Your primary task is to create a functional and visually appealing ImageCarousel React component that displays a series of images.
- Component Structure: Create a reusable
ImageCarousel component that accepts an array of image data as a prop.
- Image Display: Display one image at a time prominently within the carousel.
- Navigation Controls: Implement 'Previous' and 'Next' buttons (e.g., left and right arrows) that allow users to cycle through the images.
- Pagination Indicators: Add a set of 'dot' indicators (or similar) below the carousel. Each dot should correspond to an image, visually indicating the current image, and allowing users to directly jump to any image by clicking its corresponding dot.
- Edge Case Handling: Ensure navigation wraps around (e.g., clicking 'Next' on the last image goes to the first, and 'Previous' on the first goes to the last).
UI/UX expectations
- Layout: The carousel should have a clear main display area for the current image, with navigation buttons positioned intuitively (e.g., on the sides of the image). Pagination dots should be centered below the image.
- Interactions:
- Clicking 'Previous'/'Next' buttons should smoothly transition to the adjacent image.
- Clicking a pagination dot should smoothly transition to the corresponding image.
- The active pagination dot should be visually distinct.
- Accessibility: Ensure navigation buttons have appropriate
aria-label attributes and images have alt text (you can use a placeholder for alt if not provided in mock data).
- Visuals: Implement a subtle transition effect (e.g., fade-in/out or slide) when changing images to enhance user experience.
Acceptance criteria
- The
ImageCarousel component is rendered correctly in App.tsx.
- It displays the first image from the provided data upon initial render.
- 'Previous' and 'Next' buttons correctly navigate through images, including wrapping around at the ends.
- Pagination dots are rendered for each image, with the current image's dot highlighted.
- Clicking a pagination dot correctly navigates to the corresponding image.
- Images include basic
alt text.
- Navigation buttons are accessible via
aria-label.
- A smooth visual transition occurs when changing images.