mirror of
https://github.com/mathuo/dockview
synced 2025-02-02 22:45:48 +00:00
chore: update readme
This commit is contained in:
parent
6642bcb430
commit
e21ca56092
33
README.md
33
README.md
@ -69,12 +69,29 @@ You should also attach a dockview theme to an element containing your components
|
||||
Demonstrated below is a high level example of a `DockviewReact` component. You can follow a similar pattern for `GridviewReact`, `SplitviewReact` and `PaneviewReact` components too, see examples for more.
|
||||
|
||||
```tsx
|
||||
import { DockviewReact, DockviewReadyEvent, PanelCollection.IDockviewPanelProps } from 'dockview';
|
||||
import {
|
||||
DockviewReact,
|
||||
DockviewReadyEvent,
|
||||
PanelCollection,
|
||||
IDockviewPanelProps,
|
||||
IDockviewPanelHeaderProps,
|
||||
} from 'dockview';
|
||||
|
||||
const components: PanelCollection<IDockviewPanelProps> = {
|
||||
default: (props: IDockviewPanelProps<{someProps: string}>) => {
|
||||
return <div>{props.params.someProps}</div>
|
||||
}
|
||||
default: (props: IDockviewPanelProps<{ someProps: string }>) => {
|
||||
return <div>{props.params.someProps}</div>;
|
||||
},
|
||||
};
|
||||
|
||||
const headers: PanelCollection<IDockviewPanelHeaderProps> = {
|
||||
customTab: (props: IDockviewPanelHeaderProps) => {
|
||||
return (
|
||||
<div>
|
||||
<span>{props.api.title}</span>
|
||||
<span onClick={() => props.api.close()}>{'[x]'}</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
const Component = () => {
|
||||
@ -96,7 +113,13 @@ const Component = () => {
|
||||
});
|
||||
};
|
||||
|
||||
return <DockviewReact components={components} onReady={onReady} />;
|
||||
return (
|
||||
<DockviewReact
|
||||
components={components}
|
||||
tabComponents={headers}
|
||||
onReady={onReady}
|
||||
/>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -77,6 +77,17 @@ const components: PanelCollection<IDockviewPanelProps> = {
|
||||
}
|
||||
};
|
||||
|
||||
const headers: PanelCollection<IDockviewPanelHeaderProps> = {
|
||||
customHeader: (props) => {
|
||||
return (
|
||||
<div>
|
||||
<span>{props.api.title}</span>
|
||||
<span onClick={() => props.api.close()}>{'[x]'}</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
const Component = () => {
|
||||
const onReady = (event: DockviewReadyEvent) => {
|
||||
event.api.addPanel({
|
||||
@ -89,6 +100,7 @@ const Component = () => {
|
||||
event.api.addPanel({
|
||||
id: 'panel2',
|
||||
component: 'default',
|
||||
tabComponent: 'customHeader', // optional custom header
|
||||
params: {
|
||||
someProps: 'World',
|
||||
},
|
||||
@ -96,7 +108,7 @@ const Component = () => {
|
||||
});
|
||||
};
|
||||
|
||||
return <DockviewReact components={components} onReady={onReady} />;
|
||||
return <DockviewReact components={components} tabComponents={headers} onReady={onReady} />;
|
||||
};
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user