Skip to content

Commit 50b6e14

Browse files
committed
chore: docs
1 parent 9387e4a commit 50b6e14

File tree

19 files changed

+245
-217
lines changed

19 files changed

+245
-217
lines changed

packages/docs/docs/core/groups/floatingGroups.mdx

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import { DocRef } from '@site/src/components/ui/reference/docRef';
88

99
This section describes floating groups.
1010

11+
:::info
12+
Floating groups cannot be maximized. Calling maximize function on groups in these states will have no effect.
13+
:::
14+
1115
Dockview has built-in support for floating groups. Each floating container can contain a single group with many panels
1216
and you can have as many floating containers as needed. You cannot dock multiple groups together in the same floating container.
1317

@@ -23,12 +27,13 @@ The following properties can be set to configure the behaviours of floating grou
2327
<DocRef declaration="DockviewComponentOptions" methods={['floatingGroupBounds', 'disableFloatingGroups']} />
2428
</FrameworkSpecific>
2529

30+
Floating groups can be interacted with whilst holding the `shift` key activating the `event.shiftKey` boolean property on `KeyboardEvent` events.
31+
2632
## Live Example
2733

2834
<LiveExample framework="react" id="dockview/floating-groups"/>
2935

3036

31-
Floating groups can be interacted with whilst holding the `shift` key activating the `event.shiftKey` boolean property on `KeyboardEvent` events.
3237

3338
> Float an existing tab by holding `shift` whilst interacting with the tab
3439
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: Hidden Header
3+
---
4+
5+
import useBaseUrl from '@docusaurus/useBaseUrl';
6+
import LiveExample from '@site/src/components/ui/exampleFrame';
7+
import { DocRef } from '@site/src/components/ui/reference/docRef';
8+
9+
You may wish to hide the header section of a group. This can achieved through the `hidden` variable on `panel.group.header`.
10+
11+
```tsx
12+
panel.group.header.hidden = true;
13+
```

packages/docs/docs/core/groups/maxmizedGroups.mdx

-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ import LiveExample from '@site/src/components/ui/exampleFrame';
77

88
This section described how to maxmimize groups.
99

10-
11-
:::info
12-
Floating groups cannot be maximized. Calling maximize function on groups in these states will have no effect.
13-
:::
14-
1510
## API methods
1611

1712
The following methods on the [API](/docs/api/dockview/overview) are related to maximizing groups.

packages/docs/docs/core/locked.mdx

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: Locked
3+
---
4+
5+
import useBaseUrl from '@docusaurus/useBaseUrl';
6+
7+
import { DocRef } from '@site/src/components/ui/reference/docRef';
8+
import LiveExample from '@site/src/components/ui/exampleFrame';
9+
10+
This section describes how to lock the dock to prevent movement.

packages/docs/docs/core/panels/add.mdx

+29-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
---
2-
title: Add Panel
2+
title: Adding Panels
33
sidebar_position: 1
44
---
55

66
import { DocRef } from '@site/src/components/ui/reference/docRef';
77

8-
This section describes how to add a new panel.
8+
This section describes how to add a new panel and the options you can provide.
99

10-
## API
10+
11+
Panels can be added through the dock api.
1112

1213
<DocRef declaration="DockviewApi" methods={['addPanel']} />
1314

14-
## Opening a Simple Panel
15+
## Opening a Basic Panel
1516

16-
The minimum options required to open a panel are a unique `id` for the panel and the name of the `component` to render.
17+
To open a panel requires a unique `id` and the name of the `component` to render.
1718

1819
```ts
1920
const panel: IDockviewPanel = api.addPanel({
@@ -22,7 +23,29 @@ const panel: IDockviewPanel = api.addPanel({
2223
});
2324
```
2425

25-
> See [Overview](/docs/core/overview) to learn how to register components.
26+
> See [Overview](/docs/core/overview) to register components.
27+
28+
## Providing a Panel Title
29+
30+
:::warning
31+
Registering and updating the title using these built-in variables only works for the default tab renderer.
32+
If you use a custom tab render you can optionally access these variables to render the title, or you can take
33+
your own approach to rendering a tab title.
34+
:::
35+
36+
Use `title` to provide a custom title for the panel. If no `title` is provided then the dock will render `id` in the tab.
37+
38+
```tsx
39+
api.addPanel({
40+
id: 'panel_1',
41+
component: 'my_component',
42+
title: 'my_custom_title',
43+
});
44+
```
45+
46+
```tsx
47+
api.setTitle('my_new_custom_title');
48+
```
2649

2750
## Provide a custom Tab renderer
2851

packages/docs/docs/core/panels/register.mdx

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Register A Panel
2+
title: Registering Panels
33
sidebar_position: 0
44
---
55

@@ -8,8 +8,7 @@ import { DocRef } from '@site/src/components/ui/reference/docRef';
88

99
This section describes how to register a panel.
1010

11-
You can register panels through the `components` [option](/docs/api/dockview/options).
12-
11+
You can register panels through the dock [option](/docs/api/dockview/options) `components`.
1312

1413
<FrameworkSpecific framework='React'>
1514
<DocRef declaration="IDockviewReactProps" methods={['components']} />
@@ -25,6 +24,7 @@ You can register panels through the `components` [option](/docs/api/dockview/opt
2524
const components = {
2625
component_1: (props: IDockviewPanelProps) => {
2726
const api: DockviewPanelApi = props.api;
27+
const groupApi: DockviewGroupPanelApi = props.group.api;
2828
const containerApi: DockviewApi = props.containerApi;
2929

3030
return <div>{/** logic */}</div>
@@ -39,5 +39,8 @@ return <DockviewReact components={components}/>
3939
</FrameworkSpecific>
4040

4141

42-
Each panel has it's own [API](/docs/api/dockview/panelApi) which can be used to control the panel and you can
43-
also has access the dock [API](/docs/api/dockview/overview) from the panel directly.
42+
Each panel has an [api](/docs/api/dockview/panelApi) which is used to control specific
43+
features on that individual panel.
44+
The panel also has access the [group api](/docs/api/dockview/groupApi) and the container
45+
[api](/docs/api/dockview/overview), which is the docks primary api.
46+

packages/docs/docs/core/tabs/rendering.mdx packages/docs/docs/core/panels/tabs.mdx

+46-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
---
2-
title: Custom Tab Rendering
2+
title: Tabs
33
sidebar_position: 2
44
---
55

66
import { MultiFrameworkContainer } from '@site/src/components/ui/container';
77
import CustomHeadersDockview from '@site/sandboxes/customheader-dockview/src/app';
8+
import DockviewNative from '@site/sandboxes/fullwidthtab-dockview/src/app';
9+
import { attach as attachNativeDockview } from '@site/sandboxes/javascript/fullwidthtab-dockview/src/app';
10+
import { DocRef } from '@site/src/components/ui/reference/docRef';
811

912
This section describes how to implement custom tab renderers
1013

1114
## Register a Tab Component
1215

1316
<FrameworkSpecific framework='React'>
14-
```jsx
15-
<DockviewReact tabComponents={{
17+
```tsx
18+
const components = {
1619
tab_1: (props: IDockviewPanelHeaderProps) => {
1720
const api: DockviewPanelApi = props.api;
1821
const containerApi: DockviewApi = props.containerApi;
@@ -22,7 +25,9 @@ This section describes how to implement custom tab renderers
2225
tab_2: (props: IDockviewPanelHeaderProps) => {
2326
return <div>{/** logic */}</div>
2427
}
25-
}}/>
28+
};
29+
30+
return <DockviewReact tabComponents={tabComponents}/>
2631
```
2732
</FrameworkSpecific>
2833

@@ -35,14 +40,14 @@ not implemented
3540

3641
<FrameworkSpecific framework='React'>
3742
```jsx
38-
const MyTab = (props: IDockviewPanelHeaderProps) => {
43+
const CustomTabRenderer = (props: IDockviewPanelHeaderProps) => {
3944
const api: DockviewPanelApi = props.api;
4045
const containerApi: DockviewApi = props.containerApi;
4146

4247
return <div>{/** logic */}</div>
4348
}
4449

45-
return <DockviewReact defaultTabRenderer={MyTab}/>
50+
return <DockviewReact defaultTabRenderer={CustomTabRenderer}/>
4651
```
4752
</FrameworkSpecific>
4853

@@ -98,3 +103,38 @@ This still makes use of the `DockviewDefaultTab` since it's only a minor change.
98103
sandboxId="customheader-dockview"
99104
react={CustomHeadersDockview}
100105
/>
106+
107+
## Full Width Tab
108+
109+
When a group has only one single tab you may want that tab to take the full width.
110+
111+
<FrameworkSpecific framework='React'>
112+
<DocRef declaration="IDockviewReactProps" methods={['singleTabMode']} />
113+
</FrameworkSpecific>
114+
115+
<FrameworkSpecific framework='JavaScript'>
116+
<DocRef declaration="DockviewComponentOptions" methods={['singleTabMode']} />
117+
</FrameworkSpecific>
118+
119+
```tsx
120+
return <DockviewReactComponent singleTabMode="fullwidth" />
121+
```
122+
123+
<MultiFrameworkContainer
124+
sandboxId="fullwidthtab-dockview"
125+
react={DockviewNative}
126+
typescript={attachNativeDockview}
127+
/>
128+
129+
import DockviewTabheight from '@site/sandboxes/tabheight-dockview/src/app';
130+
import { attach as attachTabHeightDockview } from '@site/sandboxes/javascript/tabheight-dockview/src/app';
131+
132+
## Tab Height
133+
134+
Tab height can be controlled through CSS.
135+
136+
<MultiFrameworkContainer
137+
sandboxId="tabheight-dockview"
138+
react={DockviewTabheight}
139+
typescript={attachTabHeightDockview}
140+
/>

packages/docs/docs/core/state/load.mdx

+14-14
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,26 @@ import { MultiFrameworkContainer } from '@site/src/components/ui/container';
66
import LiveExample from '@site/src/components/ui/exampleFrame';
77
import { DocRef } from '@site/src/components/ui/reference/docRef';
88

9-
This section described loading a dock layout.9
9+
This section described loading a dock layout.
1010

1111
<DocRef declaration="DockviewApi" methods={['fromJSON', 'onDidLayoutFromJSON']} />
1212

13-
## Layout Persistence
13+
## Load A Layout
1414

15-
Layouts are loaded and saved via to `fromJSON` and `toJSON` methods on the Dockview api.
16-
The api also exposes an event `onDidLayoutChange` you can listen on to determine when the layout has changed.
17-
Below are some snippets showing how you might load from and save to localStorage.
15+
To load a layout you should a pass a valid object to `fromJSON`. If you try to load an invalid or corrupted layout the dock will throw an Error and the dock will reset gracefully ready
16+
for another attempt with a valid object.
1817

19-
If you try to load a invalid or corrupted layout the dock will recover g
18+
You could load a previously saved layout from local storage for example.
2019

21-
```tsx title="Loading a layout from localStorage"
20+
```tsx
2221
const onReady = (event: DockviewReadyEvent) => {
23-
const layoutString = localStorage.getItem('dockview_persistence_layout');
24-
2522
let success = false;
2623

27-
if (layoutString) {
24+
const mySerializedLayout = localStorage.getItem('my_layout');
25+
26+
if (mySerializedLayout) {
2827
try {
29-
const layout = JSON.parse(layoutString);
28+
const layout = JSON.parse(mySerializedLayout);
3029
event.api.fromJSON(layout);
3130
success = true;
3231
} catch (err) {
@@ -35,13 +34,14 @@ const onReady = (event: DockviewReadyEvent) => {
3534
}
3635

3736
if (!success) {
38-
// do something if there is no layout or there was a loading error
37+
// perhap load a default layout?
3938
}
4039
};
40+
41+
return <DockviewComponent onReady={onReady}/>;
4142
```
4243

43-
Here is an example using the above code loading from and saving to localStorage.
44-
If you refresh the page you should notice your layout is loaded as you left it.
44+
# Live Example
4545

4646
<LiveExample framework="react" id="dockview/layout"/>
4747

packages/docs/docs/core/state/save.mdx

+16-42
Original file line numberDiff line numberDiff line change
@@ -11,59 +11,33 @@ This section describes how to serialize a dockview instance.
1111

1212
<DocRef declaration="DockviewApi" methods={['toJSON', 'onDidLayoutChange']} />
1313

14+
To retrieve the current state of the dock call `toJSON()`.
15+
You can listen to the event `onDidlayoutChange` to determine when the layout has changed.
1416

17+
```tsx
18+
const [api, setApi] = React.useState<DockviewApi>();
1519

16-
## Layout Persistence
17-
18-
Layouts are loaded and saved via to `fromJSON` and `toJSON` methods on the Dockview api.
19-
The api also exposes an event `onDidLayoutChange` you can listen on to determine when the layout has changed.
20-
Below are some snippets showing how you might load from and save to localStorage.
21-
22-
```tsx title="Saving the layout state to localStorage"
2320
React.useEffect(() => {
24-
if (!api) {
25-
return;
26-
}
27-
28-
const disposable = api.onDidLayoutChange(() => {
29-
const layout = api.toJSON();
21+
if(!api) {
22+
return;
23+
}
3024

31-
localStorage.setItem(
32-
'dockview_persistence_layout',
33-
JSON.stringify(layout)
34-
);
35-
});
25+
const disposable = api.onDidLayoutChange(() => {
26+
const layout: SerializedDockview = api.toJSON();
27+
localStorage.setItem('my_layout', JSON.stringify(layout));
28+
});
3629

37-
return () => {
38-
disposable.dispose();
39-
};
30+
return () => disposable.dispose();
4031
}, [api]);
41-
```
4232

43-
```tsx title="Loading a layout from localStorage"
4433
const onReady = (event: DockviewReadyEvent) => {
45-
const layoutString = localStorage.getItem('dockview_persistence_layout');
46-
47-
let success = false;
48-
49-
if (layoutString) {
50-
try {
51-
const layout = JSON.parse(layoutString);
52-
event.api.fromJSON(layout);
53-
success = true;
54-
} catch (err) {
55-
//
56-
}
57-
}
34+
setApi(event.api);
35+
}
5836

59-
if (!success) {
60-
// do something if there is no layout or there was a loading error
61-
}
62-
};
37+
return <DockviewComponent onReady={onReady}/>
6338
```
6439

65-
Here is an example using the above code loading from and saving to localStorage.
66-
If you refresh the page you should notice your layout is loaded as you left it.
40+
# Live Example
6741

6842
<LiveExample framework="react" id="dockview/layout"/>
6943

packages/docs/docs/core/tabs/_category_.json

-6
This file was deleted.

0 commit comments

Comments
 (0)