Frontend School

Resizable Content Editor with Live Preview

Machine Coding
easy

Resizable Content Editor with Live Preview

Easy
React
DOM Manipulation
UI/UX
Split Pane

Overview

Clevertap's campaign creation often involves editing content (e.g., email templates, push notifications) and seeing a live preview. A flexible UI that allows users to adjust the working area to their preference is crucial for productivity. This problem asks you to build a foundational component for such an experience: a horizontally split pane where the user can drag a divider to resize the editor and preview areas.

What you need to do / Task

Your goal is to implement a resizable split pane component for a simple content editor and live preview.

  1. Render Panes: Display two distinct content areas: a "Content Editor" on the left and a "Live Preview" on the right.
  2. Implement Draggable Divider: Create a vertical divider element positioned between the two panes.
  3. Resize Panes: When the divider is dragged horizontally by the user, the widths of the "Content Editor" and "Live Preview" panes should adjust dynamically.
  4. Fill Container: Ensure the combined width of the two panes and the divider always occupies 100% of the available width of their parent container.

UI/UX expectations

  • Initial State: The "Content Editor" and "Live Preview" panes should initially render with equal widths (e.g., 50% each, accounting for the divider's width).
  • Divider Visuals: The divider should be visually distinct (e.g., a thin vertical bar with a background color).
  • Cursor Feedback: When the user hovers over the divider, the cursor should change to ew-resize to indicate it is draggable.
  • Smooth Resizing: Dragging the divider should result in smooth, real-time resizing of the adjacent panes.
  • Minimum Width: Panes should not be allowed to collapse to zero width. Implement a reasonable minimum width (e.g., 100px) for each pane.

Acceptance criteria

  • The application renders two distinct content panes and a vertical divider between them.
  • The divider is visually distinct and has the ew-resize cursor on hover.
  • Dragging the divider horizontally successfully resizes both the left and right panes.
  • Panes maintain a minimum width and do not collapse completely.
  • The combined width of the two panes and the divider always fills the parent container's width.
  • The component behaves responsively to mouse drag events (i.e., resizing is smooth and real-time).

Constraints

Constraints & assumptions

  • The component should be built using React.
  • You can assume the parent container (.split-pane-container) provides sufficient horizontal space and has display: flex to accommodate the panes and divider.
  • No external libraries for split pane functionality are allowed; implement the dragging and resizing logic from scratch.
  • Focus solely on horizontal splitting. Vertical splitting is out of scope.
  • No need for persistence of pane sizes across page reloads or component unmounts.
  • Mock content (e.g., a textarea for the editor, a div for the preview) is sufficient.

Out of scope

  • Saving or loading content from the editor.
  • Implementing a full rich text editor or complex live preview rendering.
  • Responsiveness for very small screen sizes or mobile devices.
  • Multiple dividers or nested split panes.

What interviewers evaluate

  • Correctness of Logic: Accurate implementation of the draggable split pane mechanism and pane resizing calculations.
  • React Best Practices: Effective use of React state, refs, and component lifecycle for managing UI interactions.
  • DOM Interaction: Proficient handling of mouse events (mousedown, mousemove, mouseup) for dragging.
  • UI/UX Adherence: Attention to detail regarding cursor changes, minimum pane sizes, and overall visual feedback.
  • Code Quality: Clean, readable, and maintainable component structure with appropriate separation of concerns.

Loading editor...