Frontend School

Dynamic Resizable Dashboard Panels

Machine Coding
hard

Dynamic Resizable Dashboard Panels

Hard
React
UI
Machine Coding
Resizable Panels
Flexbox

Overview

At Zepto, our internal operations and analytics dashboards are critical for real-time decision-making. These tools often present complex data, and empowering users to customize their workspace layout significantly boosts productivity. This problem challenges you to build a core component for such a dashboard, focusing on dynamic and nested resizable panels.

What you need to do / Task

Your goal is to implement a flexible panel layout system that allows users to resize different sections of a dashboard.

  1. Initial Layout Rendering: Render a predefined initial layout consisting of three distinct panels:
    • A left column containing two panels stacked vertically: Panel A (top) and Panel B (bottom).
    • A right column containing a single panel: Panel C.
    • Initially, the left column (containing A and B) and the right column (C) should each occupy approximately 50% of the total dashboard width.
    • Within the left column, Panel A and Panel B should each occupy approximately 50% of the left column's height.
  2. Vertical Resizing: Implement a draggable vertical divider located between the left column (A+B) and the right column (C). Dragging this divider should dynamically adjust the widths of the two main columns while maintaining their total combined width.
  3. Horizontal Resizing: Implement a draggable horizontal divider located between Panel A and Panel B within the left column. Dragging this divider should dynamically adjust the heights of Panel A and Panel B while maintaining the total height of the left column.
  4. Smooth Interaction: Ensure that resizing operations are smooth, visually responsive, and do not cause layout jumps or flickering.
  5. Panel Content: Each panel should display simple text content (e.g., "Analytics Chart", "Order List", "Recent Activity").

UI/UX expectations

  • Visual Dividers: Clear, distinct visual dividers/handles should be present for both vertical and horizontal resizing. These should be visually distinct (e.g., using a background color or border).
  • Cursor Feedback: The mouse cursor should change appropriately (e.g., ew-resize for vertical dividers, ns-resize for horizontal dividers) when hovering over a resizer.
  • Responsive Resizing: Panel dimensions should update immediately as the user drags a divider, providing direct manipulation feedback.
  • No Overflow: The overall dashboard container should not produce scrollbars due to resizing, and individual panel content should only scroll if its intrinsic content exceeds the panel's dimensions.
  • Basic Styling: Panels should have visible borders and distinct background colors for easy differentiation.

Acceptance criteria

  • The initial dashboard layout renders correctly with three distinct panels (A, B, C) in the specified configuration.
  • The vertical divider is present and can be dragged to resize the left and right columns proportionally.
  • The horizontal divider is present and can be dragged to resize Panel A and Panel B proportionally.
  • All resizing operations are smooth, without lag or visual artifacts.
  • Panel content remains visible and contained within its respective panel during and after resizing.
  • No console errors or warnings are observed during component rendering or user interaction.
  • The solution effectively uses React state to manage panel dimensions.

Constraints

Constraints & assumptions

  • You must use React for building the UI.
  • No external UI libraries or specialized resizing components are allowed (e.g., react-resizable-panels, react-split-pane). You must implement the resizing logic from scratch.
  • The problem focuses on the resizing mechanism; complex data fetching or rendering within the panels is not required.
  • Assume a modern browser environment (Chrome, Firefox, Edge).
  • Panel dimensions should be managed using flexible units (e.g., CSS flex-grow properties or percentages) rather than fixed pixel widths/heights, to ensure responsiveness.

Out of scope

  • Saving or loading layout configurations (e.g., to local storage).
  • Dynamically adding or removing panels.
  • Keyboard accessibility for resizing.
  • More complex nested resizing beyond the described two-level structure.
  • Cross-browser compatibility for older or niche browsers.

What interviewers evaluate

  • Correct and robust implementation of the core resizing logic for both vertical and horizontal dividers.
  • Effective and idiomatic use of React hooks (useState, useRef, useCallback) for state management and event handling.
  • Clean, modular, and readable code structure, demonstrating good software engineering practices.
  • Efficient handling of DOM events (mousemove, mouseup) to ensure smooth and performant user interactions.

Loading editor...