Frontend School

Dynamic Dashboard Layout with Resizable & Collapsible Panels

Machine Coding
hard

Dynamic Dashboard Layout with Resizable & Collapsible Panels

Hard
React
TypeScript
UI
Resizable Panels
Layout
Frontend

Overview

Blinkit's internal operational dashboards require highly flexible and customizable layouts to empower power users and optimize workflows. This problem challenges you to build a dynamic dashboard layout comprising a main content area, a left sidebar, and a bottom panel. The core task is to implement robust resizing and collapsing functionality for the sidebar and bottom panel, ensuring a highly responsive and intuitive user experience. This is crucial for power users who need to customize their workspace efficiently to monitor real-time data and manage tasks.

What you need to do / Task

  1. Layout Implementation: Create a React component that establishes a three-pane layout: a LeftSidebar, a MainContent area, and a BottomPanel.
  2. Horizontal Resizing: Implement horizontal resizing for the LeftSidebar. A drag handle on its right edge should allow users to adjust its width. The MainContent area should dynamically expand or shrink to fill the remaining horizontal space.
  3. Vertical Resizing: Implement vertical resizing for the BottomPanel. A drag handle on its top edge should allow users to adjust its height. The combined LeftSidebar and MainContent section should dynamically expand or shrink to fill the remaining vertical space.
  4. Collapsible Panels: Both the LeftSidebar and BottomPanel must be collapsible and expandable. Provide clear UI controls (e.g., buttons with arrow icons) to toggle their collapsed state.
  5. Minimum Dimensions: Enforce minimum dimensions for expanded panels:
    • LeftSidebar: Minimum width of 150px.
    • BottomPanel: Minimum height of 100px.
  6. Smooth Interaction: Ensure the resizing and collapsing interactions are smooth, performant, and free of visual jank or flickering.
  7. State Persistence (Ephemeral): When a panel is collapsed and then expanded, it should restore to its previously set size (before collapsing) or a default size if it's the first expansion.

UI/UX expectations

  • Layout Structure: The LeftSidebar should be on the left, MainContent to its right. The BottomPanel should span the full width below both the LeftSidebar and MainContent.
  • Resize Handles: Visually distinct drag handles (e.g., a thin, contrasting bar) should separate the panels. The cursor should change to ew-resize for horizontal handles and ns-resize for vertical handles upon hover.
  • Dragging Feedback: During an active drag operation, the panels should resize in real-time as the mouse moves.
  • Collapse/Expand Controls: Clearly visible buttons (e.g., an arrow icon pointing in the direction of collapse/expand) should be present on the header of the LeftSidebar and BottomPanel. When a panel is collapsed, it should occupy a minimal space (e.g., a slim bar) and display an icon to expand it.
  • Responsiveness: The overall layout should adapt correctly to the browser window's dimensions, filling the viewport.

Acceptance criteria

  • User can drag the handle between LeftSidebar and MainContent to resize LeftSidebar's width.
  • User can drag the handle between BottomPanel and the top section to resize BottomPanel's height.
  • LeftSidebar respects a minimum width of 150px during resizing.
  • BottomPanel respects a minimum height of 100px during resizing.
  • LeftSidebar can be collapsed and expanded via a UI control, reclaiming/restoring space correctly.
  • BottomPanel can be collapsed and expanded via a UI control, reclaiming/restoring space correctly.
  • When a panel is collapsed, its space is correctly reclaimed by adjacent panels.
  • When a panel is expanded, it restores to its previous expanded size or a default if first expansion.
  • The MainContent area always dynamically fills the remaining available space, both horizontally and vertically.
  • Resizing and collapsing interactions are visibly smooth and performant.

Constraints

Constraints & assumptions

  • The solution must be implemented using React (TypeScript is strongly preferred, but JavaScript is acceptable).
  • The application should fill the entire viewport (100vw, 100vh).
  • Crucially, no external drag-and-drop or resizing libraries are allowed. Implement the drag logic natively using browser mousemove and mouseup events.
  • Assume a modern browser environment (Chrome, Firefox, Safari).
  • Panel content can be simple placeholder text or div elements.
  • Initial default sizes for expanded panels: LeftSidebar (250px width), BottomPanel (200px height).
  • Collapsed sizes: LeftSidebar (40px width), BottomPanel (30px height).

Out of scope

  • Persisting layout state (panel sizes, collapsed state) across browser sessions (e.g., using localStorage).
  • Full accessibility for keyboard-only resizing (basic focus indication on controls is sufficient).
  • Complex nested panel structures or dynamic addition/removal of panels.
  • Responsive adjustments for very small mobile screen sizes beyond basic viewport filling.

What interviewers evaluate

  • Architectural Design: How well the components are structured, separation of concerns, and effective state management for complex UI interactions.
  • Core Logic Implementation: Correctness, robustness, and efficiency of the resizing and collapsing mechanisms, including handling edge cases like minimum dimensions.
  • UI/UX & Interaction: Smoothness of user interactions, visual feedback, and adherence to specified behaviors for a high-quality user experience.
  • Code Quality: Readability, maintainability, appropriate use of React patterns (hooks, memoization where relevant), and error handling.

Loading editor...