mirror of
https://github.com/mathuo/dockview
synced 2025-05-02 09:38:26 +00:00
docs: demo + storybook
This commit is contained in:
parent
fc7ef9226b
commit
f6c4791f0c
@ -32,7 +32,7 @@ export const Application = () => {
|
||||
React.useEffect(() => {
|
||||
const onresize = (ev: UIEvent) => {
|
||||
const { innerWidth: width, innerHeight: height } = window;
|
||||
api.current?.layout(width, height); // // fill the entire screen
|
||||
// api.current?.layout(width, height); // // fill the entire screen
|
||||
};
|
||||
window.addEventListener('resize', onresize);
|
||||
|
||||
|
@ -3,11 +3,6 @@ import { DockviewApi, GridviewApi, SplitviewApi } from 'dockview';
|
||||
import { useLayoutRegistry } from './registry';
|
||||
import './controlCenter.scss';
|
||||
|
||||
const nextGuid = (() => {
|
||||
let counter = 0;
|
||||
return () => counter++;
|
||||
})();
|
||||
|
||||
export const ControlCenter = () => {
|
||||
const registry = useLayoutRegistry();
|
||||
|
||||
@ -34,7 +29,7 @@ export const ControlCenter = () => {
|
||||
|
||||
const onAdd = () => {
|
||||
const api = registry.get<DockviewApi>('dockview');
|
||||
const _id = nextGuid();
|
||||
const _id = Date.now();
|
||||
const id = `${_id}`;
|
||||
|
||||
api.addPanel({
|
||||
|
@ -70,7 +70,7 @@ const components: PanelCollection<IDockviewPanelProps> = {
|
||||
React.useEffect(() => {
|
||||
const compDis = new CompositeDisposable(
|
||||
props.api.onDidDimensionsChange((event) => {
|
||||
_api.current?.layout(event.width, event.height);
|
||||
// _api.current?.layout(event.width, event.height);
|
||||
}),
|
||||
_api.current.onGridEvent((event) => {
|
||||
if (event.kind === GroupChangeKind.LAYOUT_CONFIG_UPDATED) {
|
||||
@ -346,7 +346,7 @@ export const TestGrid = (props: IGridviewPanelProps) => {
|
||||
}),
|
||||
props.api.onDidDimensionsChange((event) => {
|
||||
const { width, height } = event;
|
||||
_api.current.layout(width, height);
|
||||
// _api.current.layout(width, height);
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -33,6 +33,7 @@ export const IFrame = (props: {
|
||||
onEvent: (name: string) => void;
|
||||
theme: string;
|
||||
hideBorders: boolean;
|
||||
disableAutoResizing: boolean;
|
||||
}) => {
|
||||
const api = React.useRef<DockviewApi>();
|
||||
|
||||
@ -64,6 +65,7 @@ export const IFrame = (props: {
|
||||
onReady={onReady}
|
||||
components={components}
|
||||
hideBorders={props.hideBorders}
|
||||
disableAutoResizing={props.disableAutoResizing}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@ -72,6 +74,7 @@ export const Simple = (props: {
|
||||
onEvent: (name: string) => void;
|
||||
theme: string;
|
||||
hideBorders: boolean;
|
||||
disableAutoResizing: boolean;
|
||||
}) => {
|
||||
const api = React.useRef<DockviewApi>();
|
||||
|
||||
@ -115,6 +118,7 @@ export const Simple = (props: {
|
||||
onReady={onReady}
|
||||
components={components}
|
||||
hideBorders={props.hideBorders}
|
||||
disableAutoResizing={props.disableAutoResizing}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@ -190,6 +194,7 @@ export const CustomWatermark = (props: {
|
||||
onEvent: (name: string) => void;
|
||||
theme: string;
|
||||
hideBorders: boolean;
|
||||
disableAutoResizing: boolean;
|
||||
}) => {
|
||||
const api = React.useRef<DockviewApi>();
|
||||
|
||||
@ -215,6 +220,7 @@ export const CustomWatermark = (props: {
|
||||
components={components}
|
||||
hideBorders={props.hideBorders}
|
||||
watermarkComponent={Watermark}
|
||||
disableAutoResizing={props.disableAutoResizing}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
@ -30,6 +30,7 @@ export const Simple = (props: {
|
||||
orientation: Orientation;
|
||||
hideBorders: boolean;
|
||||
proportionalLayout: boolean;
|
||||
disableAutoResizing: boolean;
|
||||
}) => {
|
||||
const api = React.useRef<GridviewApi>();
|
||||
|
||||
@ -92,6 +93,7 @@ export const Simple = (props: {
|
||||
components={components}
|
||||
hideBorders={props.hideBorders}
|
||||
proportionalLayout={props.proportionalLayout}
|
||||
disableAutoResizing={props.disableAutoResizing}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@ -109,7 +111,11 @@ export default {
|
||||
);
|
||||
},
|
||||
],
|
||||
args: { orientation: Orientation.VERTICAL, proportionalLayout: true },
|
||||
args: {
|
||||
orientation: Orientation.VERTICAL,
|
||||
proportionalLayout: true,
|
||||
disableAutoResizing: false,
|
||||
},
|
||||
argTypes: {
|
||||
orientation: {
|
||||
control: {
|
||||
|
@ -25,7 +25,10 @@ const components: PanelCollection<IPaneviewPanelProps> = {
|
||||
},
|
||||
};
|
||||
|
||||
export const Simple = (props: { theme: string }) => {
|
||||
export const Simple = (props: {
|
||||
theme: string;
|
||||
disableAutoResizing: boolean;
|
||||
}) => {
|
||||
const api = React.useRef<PaneviewApi>();
|
||||
|
||||
const onReady = (event: PaneviewReadyEvent) => {
|
||||
@ -66,11 +69,15 @@ export const Simple = (props: { theme: string }) => {
|
||||
className={props.theme}
|
||||
onReady={onReady}
|
||||
components={components}
|
||||
disableAutoResizing={props.disableAutoResizing}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export const Deserialization = (props: { theme: string }) => {
|
||||
export const Deserialization = (props: {
|
||||
theme: string;
|
||||
disableAutoResizing: boolean;
|
||||
}) => {
|
||||
const api = React.useRef<PaneviewApi>();
|
||||
|
||||
const onReady = (event: PaneviewReadyEvent) => {
|
||||
@ -128,6 +135,7 @@ export const Deserialization = (props: { theme: string }) => {
|
||||
className={props.theme}
|
||||
onReady={onReady}
|
||||
components={components}
|
||||
disableAutoResizing={props.disableAutoResizing}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@ -145,7 +153,7 @@ export default {
|
||||
);
|
||||
},
|
||||
],
|
||||
args: { theme: 'dockview-theme-light' },
|
||||
args: { theme: 'dockview-theme-light', disableAutoResizing: false },
|
||||
argTypes: {
|
||||
theme: {
|
||||
control: {
|
||||
|
@ -30,6 +30,7 @@ export const Simple = (props: {
|
||||
orientation: Orientation;
|
||||
hideBorders: boolean;
|
||||
proportionalLayout: boolean;
|
||||
disableAutoResizing: boolean;
|
||||
}) => {
|
||||
const api = React.useRef<SplitviewApi>();
|
||||
|
||||
@ -58,7 +59,7 @@ export const Simple = (props: {
|
||||
|
||||
React.useEffect(() => {
|
||||
window.addEventListener('resize', () => {
|
||||
api.current?.layout(window.innerWidth, window.innerHeight);
|
||||
// api.current?.layout(window.innerWidth, window.innerHeight);
|
||||
});
|
||||
}, []);
|
||||
|
||||
@ -69,6 +70,7 @@ export const Simple = (props: {
|
||||
components={components}
|
||||
hideBorders={props.hideBorders}
|
||||
proportionalLayout={props.proportionalLayout}
|
||||
disableAutoResizing={props.disableAutoResizing}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@ -77,6 +79,7 @@ export const SnappablePanel = (props: {
|
||||
orientation: Orientation;
|
||||
hideBorders: boolean;
|
||||
proportionalLayout: boolean;
|
||||
disableAutoResizing: boolean;
|
||||
}) => {
|
||||
const api = React.useRef<SplitviewApi>();
|
||||
|
||||
@ -118,11 +121,17 @@ export const SnappablePanel = (props: {
|
||||
components={components}
|
||||
hideBorders={props.hideBorders}
|
||||
proportionalLayout={props.proportionalLayout}
|
||||
disableAutoResizing={props.disableAutoResizing}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export const Deserialization = (props: { orientation: Orientation }) => {
|
||||
export const Deserialization = (props: {
|
||||
orientation: Orientation;
|
||||
hideBorders: boolean;
|
||||
proportionalLayout: boolean;
|
||||
disableAutoResizing: boolean;
|
||||
}) => {
|
||||
const api = React.useRef<SplitviewApi>();
|
||||
|
||||
const onReady = (event: SplitviewReadyEvent) => {
|
||||
@ -181,6 +190,9 @@ export const Deserialization = (props: { orientation: Orientation }) => {
|
||||
onReady={onReady}
|
||||
orientation={props.orientation}
|
||||
components={components}
|
||||
disableAutoResizing={props.disableAutoResizing}
|
||||
hideBorders={props.hideBorders}
|
||||
proportionalLayout={props.proportionalLayout}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@ -198,7 +210,11 @@ export default {
|
||||
);
|
||||
},
|
||||
],
|
||||
args: { orientation: Orientation.VERTICAL, proportionalLayout: true },
|
||||
args: {
|
||||
orientation: Orientation.VERTICAL,
|
||||
proportionalLayout: true,
|
||||
disableAutoResizing: false,
|
||||
},
|
||||
argTypes: {
|
||||
orientation: {
|
||||
control: {
|
||||
|
@ -139,8 +139,6 @@ export const DockviewReact: React.FunctionComponent<IDockviewReactProps> = (
|
||||
domRef.current?.appendChild(dockview.element);
|
||||
dockview.deserializer = new ReactPanelDeserialzier(dockview);
|
||||
|
||||
// dockview.resizeToFit();
|
||||
|
||||
if (props.onReady) {
|
||||
props.onReady({ api: new DockviewApi(dockview) });
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ export interface IGridviewReactProps {
|
||||
hideBorders?: boolean;
|
||||
className?: string;
|
||||
proportionalLayout?: boolean;
|
||||
disableAutoResizing?: number;
|
||||
disableAutoResizing?: boolean;
|
||||
}
|
||||
|
||||
export const GridviewReact: React.FunctionComponent<IGridviewReactProps> = (
|
||||
|
@ -89,8 +89,6 @@ export const PaneviewReact: React.FunctionComponent<IPaneviewReactProps> = (
|
||||
props.onReady({ api: new PaneviewApi(paneview) });
|
||||
}
|
||||
|
||||
paneview.resizeToFit();
|
||||
|
||||
paneviewRef.current = paneview;
|
||||
|
||||
return () => {
|
||||
|
@ -72,8 +72,6 @@ export const SplitviewReact: React.FunctionComponent<ISplitviewReactProps> = (
|
||||
: undefined,
|
||||
});
|
||||
|
||||
splitview.resizeToFit();
|
||||
|
||||
if (props.onReady) {
|
||||
props.onReady({ api: new SplitviewApi(splitview) });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user