Overview
Delhivery's internal asset management system needs a highly performant and user-friendly way to browse a vast collection of product and delivery proof images. The existing gallery is slow, especially with thousands of images, and lacks essential features for efficient navigation. Your task is to develop a modern ImageGallery component that addresses these performance bottlenecks and enhances user experience through infinite scrolling, lazy loading, and category-based filtering.
What you need to do / Task
- Develop an
ImageGallery React Component: Create a functional React component that displays a grid of images.
- Implement Infinite Scrolling: As the user scrolls towards the bottom of the gallery, new images should automatically load and append to the existing list. This should be a smooth and continuous experience.
- Implement Lazy Loading for Images: Images should only be fetched and rendered when they are about to enter or are within the user's viewport, optimizing initial load times and resource usage.
- Add Category Filtering: Provide a mechanism (e.g., a dropdown or buttons) to filter images by their assigned categories. When a filter is applied, the gallery should display only images from the selected category, resetting the pagination and scroll position.
- Display Image Details on Hover: When a user hovers over an image card, an overlay should appear, displaying the full title and category of the image.
UI/UX expectations
- Layout: Images should be displayed in a responsive grid layout, adapting to different screen sizes.
- Filtering: A clear filter control (e.g., a
<select> dropdown) should be positioned at the top of the gallery, allowing users to easily choose a category or view all images.
- Image Cards: Each image should be presented in a card-like structure, showing a thumbnail and a truncated title below it.
- Hover Interaction: On hover, a semi-transparent overlay should smoothly appear over the image, revealing its full title and category in a readable format.
- Loading Feedback: A clear loading indicator (e.g., a spinner or text) must be visible at the bottom of the gallery when more images are being fetched via infinite scroll or after a filter change.
- Error Handling: If an image fails to load, a fallback placeholder (e.g., a grey box with 'Error loading image') should be displayed instead of a broken image icon.
Acceptance criteria
- The gallery initially loads and displays the first batch of images.
- Scrolling down triggers the loading of subsequent batches of images, which are appended to the current display.
- Images outside the current viewport are not loaded/rendered until they are scrolled into view (lazy loading).
- Selecting a category from the filter updates the displayed images to show only those matching the selected category, and the scroll position is reset to the top.
- Hovering over any image card reveals its complete title and category in an overlay.
- A loading indicator is visibly present while new images are being fetched (both for infinite scroll and filter changes).
- Images that fail to load display a graceful fallback placeholder.
- The gallery handles scenarios where no images are found for a selected filter or in the entire dataset.