Frontend School

Dynamic Content Layout with Resizable Panels

Machine Coding
easy

Dynamic Content Layout with Resizable Panels

Easy
React
UI
Frontend
Event Handling
CSS

Overview

At Netflix, providing a flexible and customizable user experience is paramount, even for our internal tools. Imagine an analytics dashboard or a content configuration editor where engineers need to view and manipulate data across multiple panes. This problem focuses on building a core UI primitive: a container with two vertical panels separated by a draggable divider, allowing users to dynamically adjust the layout. This component is fundamental for creating adaptable and user-friendly interfaces.

What you need to do / Task

Your task is to implement a ResizablePanelGroup React component that satisfies the following requirements:

  1. Render Panels: The component should render two distinct content areas, visually represented as 'Left Panel' and 'Right Panel', positioned side-by-side.
  2. Draggable Divider: A vertical divider must be placed between the two panels. This divider should be draggable horizontally.
  3. Real-time Resizing: As the user drags the divider, the widths of both the left and right panels must adjust in real-time, maintaining the total width of the ResizablePanelGroup container.
  4. Minimum Widths: Each panel must respect a minimum width, preventing it from collapsing entirely or becoming too small to be useful.

UI/UX expectations

  • Initial Layout: Upon loading, the left panel should occupy 60% of the ResizablePanelGroup's total width, and the right panel should occupy 40%.
  • Divider Appearance: The divider should be visually distinct (e.g., a colored vertical bar) and clearly indicate its draggable nature. When hovering over the divider, the cursor should change to ew-resize.
  • Resizing Interaction: The resizing should feel smooth and responsive. Panel content should adapt or scroll if it overflows its new dimensions.
  • Container: The ResizablePanelGroup itself will have a fixed total width and height, provided by the surrounding application.

Acceptance criteria

  • The ResizablePanelGroup component renders two distinct panels and a visible, interactive divider.
  • Dragging the vertical divider horizontally successfully changes the widths of both adjacent panels.
  • Panel widths update continuously and smoothly during the drag operation.
  • Both the left and right panels enforce a minimum width of 100px each; they cannot be shrunk below this size.
  • The mouse cursor correctly changes to ew-resize when hovering over the divider.
  • The overall layout remains stable and visually coherent throughout the resizing process.

Constraints

Constraints & assumptions

  • You must use React for this implementation.
  • Focus solely on vertical resizing (two panels side-by-side). Horizontal resizing (top/bottom panels) is out of scope.
  • Do not use any external UI component libraries (e.g., react-resizable-panels, react-split-pane). The core resizing logic must be implemented from scratch.
  • The parent ResizablePanelGroup container will have a fixed width (e.g., 800px) and height (e.g., 400px).
  • Initial panel widths: Left Panel 60%, Right Panel 40%.
  • Minimum panel width: 100 pixels.

Out of scope

  • Persistence of panel sizes (e.g., saving to local storage).
  • Nesting of ResizablePanelGroup components.
  • Advanced accessibility features beyond cursor changes.
  • Responsiveness to window size changes (the parent container is fixed).

What interviewers evaluate

  • Correct implementation of the drag-and-drop resizing mechanism using browser mouse events.
  • Effective management of React component state and props for dynamic UI updates.
  • Clean, modular component structure and separation of concerns.
  • Appropriate application of CSS for layout, visual feedback, and user interaction.

Loading editor...