// // Copyright 2026 DXOS.org // import { type Meta, type StoryObj } from '@storybook/react-vite'; import React, { type ComponentPropsWithoutRef, forwardRef, useState } from 'react'; import { withLayout, withTheme } from '../../testing'; import { Panel } from '../Panel'; import { ScrollArea } from '../ScrollArea'; import { Toolbar } from '../Toolbar'; import { Splitter, type SplitterMode, type SplitterRootProps } from './Splitter'; const PanelContent = forwardRef & { label: string }>( ({ label, ...props }, forwardedRef) => ( {label} {Array.from({ length: 100 }).map((_, i) => (
{label}-{i}
))}
), ); const Panes = () => ( <> ); // Renders the splitter with no surrounding chrome (Panel.Root keeps the height chain without a toolbar). const BasicStory = (args: SplitterRootProps) => ( ); // Toolbar drives the animated collapse via `mode`. const ToolbarStory = (args: SplitterRootProps) => { const [mode, setMode] = useState(args.mode ?? 'split'); return ( setMode('start')}>A setMode('split')}>A+B setMode('end')}>B ); }; const meta: Meta = { title: 'ui/react-ui-core/components/Splitter', component: Splitter.Root, render: BasicStory, decorators: [withTheme(), withLayout({ layout: 'fullscreen' })], parameters: { layout: 'fullscreen', }, }; export default meta; type Story = StoryObj; export const VerticalStart: Story = { args: { orientation: 'vertical', anchor: 'start', resizable: true, defaultSize: 20, minSize: 6, }, }; export const VerticalEnd: Story = { args: { orientation: 'vertical', anchor: 'end', resizable: true, defaultSize: 20, minSize: 6, }, }; export const VerticalAnimated: Story = { render: ToolbarStory, args: { orientation: 'vertical', transition: 250, }, }; export const HorizontalStart: Story = { args: { orientation: 'horizontal', anchor: 'start', resizable: true, defaultSize: 30, minSize: 6, }, }; export const HorizontalEnd: Story = { args: { orientation: 'horizontal', anchor: 'end', resizable: true, defaultSize: 30, minSize: 6, }, }; export const HorizontalAnimated: Story = { render: ToolbarStory, args: { orientation: 'horizontal', transition: 250, }, };