Frontend School

Myntra Outfit Builder: Drag to Reorder Items

Machine Coding
easy

Myntra Outfit Builder: Drag to Reorder Items

Easy
Drag and Drop
React
State Management
UI

Overview

Myntra's team of stylists constantly curates unique outfits and collections. Before an outfit is published, they need an an intuitive way to arrange the items within it, ensuring the visual flow and prominence of key pieces are just right. This problem focuses on building a core UI component for reordering items within a curated outfit.

What you need to do / Task

Your primary task is to implement a drag-and-drop interface for reordering a list of outfit items. Specifically, you need to:

  1. Display a pre-defined list of outfit items.
  2. Enable users to drag any item from the list and drop it into a new position within the same list.
  3. Ensure the internal state of the component accurately reflects the new order after a successful drag-and-drop operation.

UI/UX expectations

  • Item Representation: Each outfit item should be clearly distinguishable, displaying at least its name and a placeholder for an image.
  • Visual Feedback: Provide clear visual cues during the drag operation. The item being dragged should have a distinct appearance (e.g., a different background or border), and the potential drop target (where the item will land) should be visually indicated as the dragged item hovers over other items.
  • Smooth Interaction: The reordering process should feel smooth and responsive.
  • Basic Layout: The list of items should be vertically stacked with reasonable spacing.

Acceptance criteria

  • The initial list of OutfitItem components is rendered correctly based on the mock data.
  • A user can successfully initiate a drag operation on any item in the list.
  • As an item is dragged over other items, the list visually rearranges to indicate the prospective drop position.
  • Releasing the dragged item updates its position permanently within the displayed list.
  • The order of items, once changed by a drag-and-drop operation, persists within the component's state.

Constraints

Constraints & assumptions

  • Technology Stack: Use React and TypeScript for your solution.
  • Client-Side Only: Focus solely on client-side drag-and-drop functionality. No backend integration for saving the order is required.
  • Data: Use the provided mock data for outfit items.
  • List Size: Assume a small list of items (e.g., 5-7 items) for this problem.

Out of scope

  • Saving the reordered list to a persistent storage or a backend API.
  • Complex accessibility features beyond basic keyboard navigation for drag-and-drop (if time permits, but not a primary requirement).
  • Drag-and-drop between multiple distinct lists.
  • Advanced animations or transitions beyond basic visual feedback for reordering.

What interviewers evaluate

  • Correct implementation of HTML5 Drag and Drop API or a suitable library for reordering.
  • Effective state management to handle list reordering and updates.
  • Clean, modular, and maintainable React component structure.
  • Adherence to basic UI/UX expectations, including visual feedback during interactions.

Loading editor...