diff --git a/packages/splitview-demo/src/stories/paneview.stories.tsx b/packages/splitview-demo/src/stories/paneview.stories.tsx index f9694204f..e6e216a2e 100644 --- a/packages/splitview-demo/src/stories/paneview.stories.tsx +++ b/packages/splitview-demo/src/stories/paneview.stories.tsx @@ -5,6 +5,12 @@ import { PaneviewReadyEvent, IPaneviewPanelProps, SerializedPaneview, + PanelConstraintChangeEvent, + CompositeDisposable, + PanelDimensionChangeEvent, + ExpansionEvent, + FocusEvent, + ActiveEvent, } from 'dockview'; import * as React from 'react'; import { Story, Meta } from '@storybook/react'; @@ -12,6 +18,32 @@ import 'dockview/dist/styles.css'; const components: PanelCollection = { default: (props) => { + const [constraints, setConstraints] = React.useState< + PanelConstraintChangeEvent + >(); + const [dimensions, setDimensions] = React.useState< + PanelDimensionChangeEvent + >(); + const [expansionState, setExpansionState] = React.useState< + ExpansionEvent + >(); + const [active, setActive] = React.useState(); + const [focus, setFocus] = React.useState(); + + React.useEffect(() => { + const disposables = new CompositeDisposable( + props.api.onDidConstraintsChange(setConstraints), + props.api.onDidDimensionsChange(setDimensions), + props.api.onDidExpansionChange(setExpansionState), + props.api.onDidActiveChange(setActive), + props.api.onDidFocusChange(setFocus) + ); + + return () => { + disposables.dispose(); + }; + }, []); + const resize = () => { props.api.setSize({ size: 300 }); }; @@ -21,10 +53,24 @@ const components: PanelCollection = { style={{ padding: '10px', backgroundColor: props.color, + boxSizing: 'border-box', height: '100%', }} > -
hello world
+
+
Contraints:
+
{`maximumSize: ${constraints?.maximumSize} minimumSize: ${constraints?.minimumSize}`}
+
Dimesions:
+
{`width: ${dimensions?.width} height: ${dimensions?.height}`}
+
Expansion:
+
{`expanded: ${expansionState?.isExpanded}`}
+
Active:
+
{`active: ${active?.isActive}`}
+
Focus:
+
{`focused: ${focus?.isFocused}`}
+
); diff --git a/packages/splitview-demo/src/stories/splitview.stories.tsx b/packages/splitview-demo/src/stories/splitview.stories.tsx index 3873b27d8..7ffc2c036 100644 --- a/packages/splitview-demo/src/stories/splitview.stories.tsx +++ b/packages/splitview-demo/src/stories/splitview.stories.tsx @@ -23,6 +23,7 @@ const components: PanelCollection = { padding: '10px', backgroundColor: props.color, height: '100%', + boxSizing: 'border-box', }} >
hello world