Question presented to candidate: "Build an IDE-style layout: a navigator on the left, and on the right an editor above a terminal. Both dividers can be dragged. The navigator must stay at least 160 px wide and the right side at least 240 px; the editor at least 120 px tall and the terminal at least 80 px. When the window is resized the layout should keep its proportions without breaking those minimums. Make one reusable split pane component that works in both directions and can be nested."
Requirements:
- A
SplitPanecomponent withdirection(horizontal or vertical), an initial split,minFirstandminSecondin px, and two content slots. - Nested use: a horizontal split whose second pane is a vertical split.
- Dragging the divider along the right axis, clamped so neither pane goes below its minimum; the pointer may leave the divider or the window.
- The split stored as a fraction of the free space, so window resizes keep proportions, then re-clamped against the new size.
- A defined behaviour when the container is smaller than both minimums together.
- Keyboard: arrows along the pane axis only, Shift for bigger steps, Home and End to the limits, Enter to collapse and restore the first pane; double-click resets.
- Separator semantics:
role="separator"with the correctaria-orientation,aria-valuenowas a percentage,aria-valuetextin pixels,aria-controls.
What a strong answer should cover:
- Why fractions for state and pixels for constraints, and when to convert (at pointerdown, on keys, on window resize).
- Measuring the container with
getBoundingClientRect, minus the gutter, and keeping the grab offset inside the divider so the bar does not jump. - Axis-aware code: one component reading
clientXorclientY, with matching keys and orientation (a side-by-side split has a vertical bar). - Clamping both sides at once and resolving impossible constraints deterministically.
- Content projection (children, named slots, multi-slot
ng-content) so panes can nest. - Listener clean-up for the drag and for the window resize handler.
Clarifying questions expected:
- "Should sizes persist, and should a collapsed pane stay collapsed after reload?"
- "When the window is too small for both minimums, which pane wins?"
- "Do we need more than two panes per split?"
Code / implementation expected: Yes. The reusable split pane and the nested IDE layout.