Dynamic Resizable Layout with Nested Split Panes
Modern productivity applications, especially those in the Zoho suite, heavily rely on flexible and customizable user interfaces. A common requirement is the ability for users to dynamically adjust the layout of different content areas. This problem challenges you to build a robust and reusable SplitPane component that allows users to resize adjacent content areas by dragging a divider. The component should support both horizontal and vertical splitting and, critically, allow for nesting to create complex, multi-dimensional layouts.
Your primary task is to implement a SplitPane React component that offers dynamic resizing capabilities.
SplitPane Component: Create a SplitPane component that accepts children (representing the content of each pane), a direction prop ('horizontal' or 'vertical'), and an optional initialSizes prop (an array of numbers representing initial percentage values for each pane). Each SplitPane instance must also take a unique id prop for persistence.SplitPane component can be nested. For example, a main vertical split where one of the panes itself contains a horizontal split. This requires careful consideration of how sizing and drag events propagate.minSize prop, defaulting to 50px). Panes should not be able to shrink below this threshold.localStorage) and restored upon component mount, providing a consistent user experience across sessions. The unique id prop should be used to store and retrieve sizes for each specific SplitPane instance.ew-resize for horizontal splits and ns-resize for vertical splits when hovering over the divider.tab). Users should be able to resize panes using arrow keys (e.g., left/right for horizontal, up/down for vertical splits) when the divider is focused. Appropriate ARIA attributes (e.g., role="separator", aria-orientation, aria-valuenow, aria-valuemin, aria-valuemax) should be used.App.tsx will demonstrate a nested layout. Your component should render this structure correctly.SplitPane component correctly renders its children arranged according to the specified direction (horizontal or vertical).minSize constraint.SplitPane components function independently and correctly within their parent panes.localStorage based on a unique id for each SplitPane instance.Constraints
react-split-pane, re-resizable). Basic utility libraries like lodash are acceptable if needed, but the core logic should be custom.SplitPane has a defined size.initialSizes will be an array of percentages summing to 100, or will be absent, in which case panes should distribute evenly.initialSizes array length (assume it matches children count if provided).SplitPane component is designed for reusability, extensibility, and clarity.initialSizes and minSize).Loading editor...