Frontend School

Simple Image Gallery with Modal Viewer

Machine Coding
easy

Simple Image Gallery with Modal Viewer

Easy
React
UI
Gallery
Modal

Overview

In the fast-paced world of digital content, visual presentation is key. We need to develop a foundational component for an internal content management system: a simple image gallery. This gallery will allow users to browse thumbnails and view a larger version of an image along with its details in a modal overlay, enhancing the user experience for content review.

What you need to do / Task

Your goal is to build a functional image gallery component using React.

  1. Display Thumbnails: Render a grid or list of image thumbnails using the provided mock data. Each thumbnail should be visually distinct and represent an individual image.
  2. Open Modal on Click: Implement functionality such that clicking on any image thumbnail opens a modal dialog.
  3. Modal Content: The modal dialog should display the full-size version of the clicked image, along with its title and description.
  4. Close Modal: Provide a clear way to close the modal, such as a close button or by clicking on the modal overlay.

UI/UX expectations

  • Gallery Layout: The thumbnails should be presented in a grid-like structure, allowing for easy scanning.
  • Clickable Thumbnails: Each thumbnail should be clearly identifiable as clickable.
  • Modal Presentation: The modal should appear centered on the screen, overlaying the main content, and dimming the background slightly to focus user attention.
  • Close Mechanism: A visible "X" button or similar icon should be present within the modal, and clicking outside the modal content (on the overlay) should also close it.

Acceptance criteria

  • The application successfully renders a collection of image thumbnails based on the provided data.
  • Clicking any thumbnail displays a modal window.
  • The modal window correctly shows the full-size image corresponding to the clicked thumbnail.
  • The modal window displays the title and description of the selected image.
  • The modal can be closed by clicking a dedicated close button.
  • The modal can be closed by clicking on the dimmed background overlay.

Constraints

Constraints & assumptions

  • You must use React (functional components and hooks).
  • Basic HTML and CSS for structure and minimal styling are expected. Focus on functionality over elaborate design.
  • The application should run in a modern web browser environment.
  • All image data will be provided via a mock data structure within App.tsx.
  • No external libraries are strictly required beyond React itself, but you may use basic CSS-in-JS if preferred (e.g., styled-components if already set up, but not necessary to set up for this problem).

Out of scope

  • Implementing image lazy loading or performance optimizations for a large number of images.
  • Adding keyboard navigation for the gallery or modal.
  • Implementing a carousel/slideshow within the modal to browse images.
  • Backend integration or fetching data from an API.

What interviewers evaluate

  • React State Management: Effective use of useState for managing UI state, particularly modal visibility and selected image data.
  • Event Handling: Correct implementation of click handlers for opening and closing the modal.
  • Conditional Rendering: Ability to conditionally render the modal component based on application state.
  • Component Structure: Logical organization of the UI into reusable and maintainable React components.

Loading editor...