Overview
In the fast-paced world of trading, efficient management of watchlists is paramount for investors. Traders often need to quickly reorder their watchlist items based on real-time market movements, personal preference, or strategic priorities. This problem challenges you to build a component that allows users to intuitively reorder their stock watchlist using a drag-and-drop interface.
What you need to do / Task
Your primary task is to implement a React component that displays a list of stock symbols and enables users to reorder these symbols using drag-and-drop interactions.
- Render the Watchlist: Display an initial list of mock stock symbols.
- Enable Dragging: Make each stock symbol item draggable.
- Handle Dropping: Implement the logic to correctly reorder the list when an item is dragged and dropped into a new position.
- Update UI: Ensure the UI reflects the new order immediately after a successful drop.
UI/UX expectations
- List Presentation: Display stock symbols as a clear, vertical list. Each symbol should be distinct.
- Draggable Items: Each list item should visually indicate that it is draggable (e.g., cursor changes to
grab or grabbing on hover/drag).
- Drag Feedback: When an item is actively being dragged, it should provide visual feedback (e.g., a semi-transparent appearance of the dragged item, or a visual "lift" effect).
- Insertion Indicator: While dragging an item over the list, provide a clear visual cue (e.g., a horizontal line or a background highlight) to indicate where the dragged item will be inserted if dropped at that position.
- Smooth Reordering: The list should visually reorder smoothly and instantly once an item is dropped.
Acceptance criteria
- The initial list of predefined stock symbols is rendered in the correct order.
- Users can click and drag any stock symbol from its current position.
- While dragging, a visual indicator (e.g., a "ghost" element or styled original) for the dragged item is present.
- Dragging an item over other items provides a visual cue for the potential drop position.
- Dropping an item successfully reorders the list, and the updated order is reflected in the UI.
- Dragging an item to the very beginning or end of the list correctly places it there.
- No external drag-and-drop libraries (e.g.,
react-beautiful-dnd, dnd-kit) are used; the solution should leverage native browser APIs or basic mouse/touch events.