Overview
OYO's platform heavily relies on high-quality visuals for properties. A seamless image gallery experience is crucial for users to explore property details, amenities, and rooms. This problem simulates building a core component of such a gallery, focusing on interaction, state management, and user experience for an L3 candidate.
What you need to do / Task
Your task is to build a functional and interactive image gallery component using React. Specifically, you need to:
- Display Thumbnails: Render a list of image thumbnails from the provided mock data.
- Main Image Viewer: Display a main image viewer area that shows the currently selected full-size image.
- Thumbnail Selection: When a thumbnail is clicked, the corresponding full-size image should be updated and displayed in the main viewer.
- Navigation Buttons: Implement "Previous" and "Next" buttons. Clicking these buttons should navigate through the images in the main viewer. The navigation should loop (e.g., clicking "Next" on the last image should show the first image).
- Keyboard Navigation: Add keyboard support for navigation. The Left arrow key should trigger "Previous" functionality, and the Right arrow key should trigger "Next" functionality.
UI/UX expectations
- The main image viewer should be prominently displayed at the top or left of the gallery container.
- Thumbnails should be arranged horizontally below or to the right of the main viewer, allowing for easy browsing.
- "Previous" and "Next" buttons should be clearly visible and accessible near the main image viewer.
- The currently selected thumbnail should have a distinct visual indicator (e.g., a border or different background) to highlight its active state.
- Basic layout and responsiveness are encouraged but not the primary focus; functionality is key.
Acceptance criteria
- All provided image thumbnails are rendered correctly.
- Clicking any thumbnail updates the main image display to the selected image.
- The "Previous" button correctly navigates to the prior image, wrapping from the first image to the last.
- The "Next" button correctly navigates to the subsequent image, wrapping from the last image to the first.
- Pressing the Left arrow key triggers the "Previous" image navigation.
- Pressing the Right arrow key triggers the "Next" image navigation.
- The active thumbnail is visually highlighted, and this highlight updates correctly upon navigation (via clicks or buttons/keys).