Frontend School

Episode Sequence Editor

Machine Coding
medium

Episode Sequence Editor

Medium
React
Drag and Drop
UI/UX
State Management

Overview

At Netflix, content curation is paramount. Our content editors often need to fine-tune the sequence of episodes within a series to optimize viewer engagement or align with narrative arcs. This problem simulates a core part of their toolkit: an intuitive UI for reordering episodes within a given series. Efficiently managing episode order directly impacts viewer experience and content discoverability.

What you need to do / Task

Your task is to build a React component that allows content editors to visually reorder a list of episodes using drag-and-drop.

  1. Display Episodes: Render a list of episodes, each showing its title and duration.
  2. Enable Drag and Drop: Implement functionality that allows users to pick up an episode and drag it to a new position within the list.
  3. Reorder List: When an episode is dropped, update the list's internal state to reflect the new order.
  4. Visual Feedback: Provide clear visual cues during the drag-and-drop process.

UI/UX expectations

  • Episode Item: Each episode should be presented as a distinct, clickable/draggable item, displaying its episodeNumber, title, and duration.
  • Draggable Indicator: The cursor should change to grab when hovering over an episode item, indicating it's draggable.
  • Dragging State: When an episode is being dragged, it should have a distinct visual style (e.g., reduced opacity, a border).
  • Drop Target Feedback: As a dragged episode hovers over potential drop locations, provide visual feedback indicating where the item will be inserted (e.g., a line showing the insertion point, or a background highlight on the target item).
  • Smooth Interaction: The drag-and-drop experience should feel responsive and smooth.
  • Order Display: The current order of episode titles should be displayed below the list to confirm state updates.

Acceptance criteria

  • Users can click and drag any episode item from the list.
  • Dragging an episode item over another episode or between episodes visually indicates the new insertion point.
  • Releasing a dragged episode correctly inserts it at the target position in the list.
  • The visual order of episodes in the UI updates immediately after a drop.
  • The internal component state (the episodes array) accurately reflects the new order.
  • No episodes are lost or duplicated during the reordering process.
  • The provided current-order display accurately reflects the reordered state.

Constraints

Constraints & assumptions

  • You should use React functional components with hooks.
  • You are free to use a third-party drag-and-drop library (e.g., react-dnd, dnd-kit) if you are proficient with it and can integrate it quickly. Alternatively, you can implement the drag-and-drop logic using native browser APIs (e.g., draggable attribute, dragstart, dragover, drop events).
  • The provided mock data for episodes (mockEpisodes) should be used as the initial dataset.
  • The list will contain a small number of items (typically 5-10 episodes).
  • The reordered list only needs to be maintained in the component's local state; no backend API calls are required.

Out of scope

  • Backend integration for persisting changes to a server.
  • Complex nested drag-and-drop functionality (e.g., dragging items into sub-groups or different lists).
  • Full keyboard accessibility for drag-and-drop actions (focus on mouse/pointer interactions for this time budget).
  • Extensive styling beyond what is necessary for clear UI/UX feedback and adherence to the basic Netflix theme provided.

What interviewers evaluate

  • Core Drag-and-Drop Logic: Correct implementation of the drag-and-drop mechanism to reorder items.
  • State Management: Effective use of React state to manage and update the order of episodes.
  • UI/UX Feedback: Thoughtful design and implementation of visual cues during the drag-and-drop process.
  • Code Quality: Clarity, modularity, and maintainability of the React component(s) and associated logic.

Loading editor...