mediumMachine Coding

Build an Image Gallery with lightbox

760 views
01

Understand the problem

Build a responsive image grid that opens a full-screen lightbox.

ReactGalleryLightbox
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Stuck? AI Nudge Available

Get a conceptual hint to guide your logic without spoiling the final implementation.

03

Study the solution

Solve in

The solution is waiting

Give it an honest attempt first — then compare your thinking with the full walkthrough.

04

React solution

Complete solutionRun Playground
import React from 'react';
import ImageGallery from './src/ImageGallery';

// Use CSS gradients as stand-in "images" so the demo needs no network.
const images = [
  'linear-gradient(135deg,#2563eb,#7c3aed)',
  'linear-gradient(135deg,#16a34a,#22d3ee)',
  'linear-gradient(135deg,#d97706,#dc2626)',
  'linear-gradient(135deg,#7c3aed,#ec4899)',
  'linear-gradient(135deg,#0891b2,#14b8a6)',
  'linear-gradient(135deg,#f59e0b,#ef4444)',
];

export default function App() {
  return (
    <div style={{ fontFamily: 'sans-serif', padding: 20 }}>
      <h1>Image Gallery Demo</h1>
      <ImageGallery images={images} />
    </div>
  );
}
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.