Frontend School

Interactive Property Image Gallery

Machine Coding
medium

Interactive Property Image Gallery

Medium
React
Frontend
UI
State Management
Event Handling

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:

  1. Display Thumbnails: Render a list of image thumbnails from the provided mock data.
  2. Main Image Viewer: Display a main image viewer area that shows the currently selected full-size image.
  3. Thumbnail Selection: When a thumbnail is clicked, the corresponding full-size image should be updated and displayed in the main viewer.
  4. 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).
  5. 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).

Constraints

Constraints & assumptions

  • You are provided with a mock array of image data (URL, alt text). Do not fetch images from an external API.
  • Focus on building functional React components. Avoid class components.
  • No external UI libraries or heavy frameworks are allowed (e.g., Material UI, Ant Design). Use basic HTML and CSS.
  • Image loading states (e.g., spinners, broken image placeholders) are out of scope. Assume all images load successfully.
  • The gallery will contain a small, fixed number of images (e.g., 5-10 images).

Out of scope

  • Complex routing or deep linking for specific images.
  • Accessibility beyond basic keyboard navigation and alt text for images.
  • Performance optimizations for very large galleries (e.g., virtualized lists).
  • Image lazy loading or advanced caching strategies.

What interviewers evaluate

  • Correctness and Robustness: Does the core logic for image selection and navigation work as expected, including edge cases like wrapping around?
  • State Management: Effective use of React hooks (useState, useEffect) to manage component state and side effects.
  • Code Structure and Readability: Clear, well-organized component structure, meaningful variable names, and adherence to React best practices.
  • Event Handling: Proper implementation of click handlers and keyboard event listeners.

Loading editor...