feat: docs

This commit is contained in:
mathuo 2022-05-05 22:11:36 +01:00
parent d94460955d
commit 3241cec703
No known key found for this signature in database
GPG Key ID: C6EEDEFD6CA07281
13 changed files with 228 additions and 115 deletions

View File

@ -1,8 +1,10 @@
name: Deploy Docs
on:
schedule:
- cron: '0 3 * * *' # every day at 3 am UTC
# on:
# schedule:
# - cron: '0 4 * * *'
on: [push]
jobs:
deploy-nightly-demo-app:

View File

@ -25,11 +25,18 @@ const withMDX = mdx({
},
});
console.log(`CI=${process.env.CI}`);
const extraParams = process.env.CI
? {
basePath: '/dockview/docs',
assetPrefix: '/dockview/docs/',
}
: {};
export default withTM(
withMDX({
basePath: '/dockview/docs',
assetPrefix: '/dockview/docs/',
//
...extraParams,
reactStrictMode: true,
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
experimental: {

View File

@ -31,16 +31,21 @@ export const Header = (props: {}) => {
return (
<div
style={{
height: '0px',
backgroundColor: '#0070f3',
padding: '5vw',
backgroundColor: 'var(--header-color)',
padding: '0px 8px',
display: 'flex',
alignItems: 'center',
borderBottom: '1px solid var(--border-color)',
}}
>
<DockviewReact
onReady={onReady}
components={components}
className="dockview-theme-dark"
/>
<div>
<div>
<span style={{ fontSize: '2em' }}>dockview</span>
<span style={{ fontSize: '1.25em' }}>
{' documentation'}
</span>
</div>
</div>
</div>
);
};

View File

@ -12,21 +12,7 @@ const components = {
export const SimpleDockview = () => {
const onReady = (event: DockviewReadyEvent) => {
event.api.onDidLayoutChange(() => {
localStorage.setItem(
'dockview_test',
JSON.stringify(event.api.toJSON())
);
});
const layout = localStorage.getItem('dockview_test');
if (layout) {
event.api.fromJSON(JSON.parse(layout));
return;
}
event.api.addPanel({
const panel = event.api.addPanel({
id: 'panel_1',
component: 'default',
params: {
@ -34,6 +20,9 @@ export const SimpleDockview = () => {
},
});
panel.group.locked = true;
panel.group.header.hidden = true;
event.api.addPanel({
id: 'panel_2',
component: 'default',

View File

@ -62,6 +62,7 @@ export const SimpleGridview = () => {
title: 'Panel 6',
},
position: { referencePanel: 'panel_5', direction: 'below' },
minimumWidth: 10,
});
event.api.addPanel({
@ -71,6 +72,17 @@ export const SimpleGridview = () => {
title: 'Panel 7',
},
position: { referencePanel: 'panel_6', direction: 'right' },
minimumWidth: 10,
});
event.api.addPanel({
id: 'panel_8',
component: 'default',
params: {
title: 'Panel 8',
},
position: { referencePanel: 'panel_6', direction: 'right' },
minimumWidth: 10,
});
};
@ -78,6 +90,7 @@ export const SimpleGridview = () => {
<GridviewReact
components={components}
onReady={onReady}
proportionalLayout={false}
orientation={Orientation.VERTICAL}
className="dockview-theme-dark"
/>

View File

@ -0,0 +1,60 @@
import { SimpleSplitview } from './simpleSplitview';
import * as React from 'react';
export const SimpleSplitview2 = (props: { proportional?: boolean }) => {
const [value, setValue] = React.useState<number>(50);
const onChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setValue(Number(event.target.value));
};
return (
<div
style={{
display: 'flex',
flexDirection: 'column',
height: '100px',
margin: '10px 0px',
}}
>
<div
style={{
height: '25px',
display: 'flex',
alignItems: 'center',
}}
>
<input
type={'range'}
min={20}
max={100}
defaultValue={50}
value={value}
onChange={onChange}
/>
<span style={{ padding: '0px 8px' }}>
Slide to resize the splitview container
</span>
</div>
<div
style={{
flexGrow: 1,
display: 'grid',
gridTemplateColumns: `${value}fr ${100 - value}fr`,
}}
>
<div
style={{
backgroundColor: 'rgb(30,30,30)',
color: 'white',
flexGrow: 1,
border: '1px solid grey',
}}
>
<SimpleSplitview proportional={props.proportional} />
</div>
<div></div>
</div>
</div>
);
};

View File

@ -1,39 +1,9 @@
import { SimpleSplitview } from '../components/simpleSplitview';
import { SimpleSplitview2 } from '../components/simpleSplitview2';
## Auto resizing
# Basics
`SplitviewReact`, `GridviewReact`, `PaneviewReact` and `DockviewReact` will all automatically resize to fill the size of their parent element.
Internally this is achieved using a [ResizeObserver](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver).
You can disable this by settings the `disableAutoResizing` prop to be `true`.
You can manually resize a component using the API method `layout(width: number, height: number): void`.
You can force a component to resize without providing any measurements using the API method `resizeToFit(): void`.
This method will evaluate the width and height of the parent `HTMLElement` container and use these values to relayout.
## Proportional layout
<div
style={{
height: '100px',
backgroundColor: 'rgb(30,30,30)',
color: 'white',
margin: '20px 0px',
}}
>
<SimpleSplitview proportional={false} />
</div>
<div
style={{
height: '100px',
backgroundColor: 'rgb(30,30,30)',
color: 'white',
margin: '20px 0px',
}}
>
<SimpleSplitview proportional={true} />
</div>
This section will take you through a number of concepts that can be applied to all dockview components.
## Panels
@ -63,9 +33,12 @@ const MyComponent = (props: ISplitviewPanelProps<{ title: string }>) => {
};
```
### Accessing the panel API
## API
You can access an extensive set of functions in the panel via both the panel `api` and `containerApi`. The `api` is specific to that particular panel and the `containerApi` corresponds to that api which you access during the `onReady` event.
There are two types of API you will interact with using `dockview`.
- The `panel API` is accessible via `props.api` in user defined panels and via the `.api` variable found on panel instances. This API contains actions and variable related to the the individual panel.
- The `component API` is accessible via `event.api` in the `onReady` events and `props.containerApi` in user defined panels. This API contains actions and variable related to the component as a whole.
```tsx
const MyComponent = (props: ISplitviewPanelProps<{ title: string }>) => {
@ -98,3 +71,20 @@ const MyComponent = (props: ISplitviewPanelProps<{ title: string }>) => {
### Serialization
All components support `toJSON(): T` which returns a Typed object representation of the components state. This same Typed object can be used to deserialize a view using `fromJSON(object: T): void`.
## Auto resizing
`SplitviewReact`, `GridviewReact`, `PaneviewReact` and `DockviewReact` will all automatically resize to fill the size of their parent element.
Internally this is achieved using a [ResizeObserver](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver).
You can disable this by settings the `disableAutoResizing` prop to be `true`.
You can manually resize a component using the API method `layout(width: number, height: number): void`.
## Proportional layout
The `proportionalLayout` property indicates the expected behaviour of the component as it's container resizes, should all views resize equally or should just one view expand to fill the new space. `proportionalLayout` can be set as a property on `SplitviewReact` and `GridviewReact` components.
Although not configurable on `DockviewReact` and `PaneviewReact` these both behave as if `proportionalLayout=true` was set for them.
<SimpleSplitview2 proportional={false} />
<SimpleSplitview2 proportional={true} />

View File

@ -1,3 +1,43 @@
import { SimpleDockview } from '../components/simpleDockview';
Dockview is an abstraction built on top of [Gridviews](/gridview) where each view is a tabbed container.
<div
style={{
height: '300px',
backgroundColor: 'rgb(30,30,30)',
color: 'white',
margin: '20px 0px',
}}
>
<SimpleDockview />
</div>
```tsx
const panel = event.api.addPanel(...);
const anotherPanel = event.api.getPanel('somePanelid');
```
You can access the panels associated group through the `panel.group` variable.
The group will always be defined and will change if a panel is moved into another group.
### Locked group
Locking a group will disable all drop events for this group ensuring a user can not add additional panels to the group.
You can still add groups to a locked panel programatically using the api.
```tsx
panel.group.locked = true;
```
## Group header
You may wish to hide the header section of a group. This can achieved through setting the `hidden` variable on `panel.group.header`.
```tsx
panel.group.header.hidden = true;
```
## Component Props
```tsx
@ -33,46 +73,45 @@ const onReady = (event: DockviewReadyEvent) => {
};
```
| Property | Type | Description |
| ---------------------- | ------------------------------------------------- | ------------------------------------------- |
| height | `number` | Component pixel height |
| width | `number` | Component pixel width |
| minimumHeight | `number` | |
| maximumHeight | `number` | |
| maximumWidth | `number` | |
| maximumWidth | `number` | |
| length | `number` | Number of panels |
| size | `number` | Number of Groups |
| panels | `IGroupPanel[]` | |
| groups | `IGroupviewPanel[]` | |
| activePanel | `IGroupPanel \| undefined` | |
| activeGroup | `IGroupviewPanel \| undefined` | |
| | | |
| onDidLayoutChange | `Event<void>` | |
| onDidLayoutFromJSON | `Event<void>` | |
| onDidAddGroup | `Event<IGroupviewPanel>` | |
| onDidRemoveGroup | `Event<IGroupviewPanel>` | |
| onDidActiveGroupChange | `Event<IGroupviewPanel \| undefined>` | |
| onDidAddPanel | `Event<IGroupPanel>` | |
| onDidRemovePanel | `Event<IGroupPanel>` | |
| onDidActivePanelChange | `Event<IGroupPanel \| undefined>` | |
| onDidDrop | `Event<DockviewDropEvent` | |
| | | |
| addPanel | `addPanel(options: AddPanelOptions): IGroupPanel` | |
| getPanel | `(id: string) \| IGroupPanel \| undefined` | |
| addEmptyGroup | `(options? AddGroupOptions): void` | |
| closeAllGroups | `(): void` | |
| removeGroup | `(group: IGroupviewPanel): void` | |
| getGroup | `(id: string): IGroupviewPanel \| undefined` | |
| | | |
| getTabHeight | `(): number \| undefined` | |
| setTabHeight | `(hegiht: number \| undefined): void` | |
| updateOptions | `(options:SplitviewComponentUpdateOptions): void` | |
| focus | `(): void` | |
| layout | `(width: number, height:number): void` | See [Auto resizing](/basics/#auto-resizing) |
| resizeToFit | `(): void` | See [Auto resizing](/basics/#auto-resizing) |
| fromJSON | `(data: SerializedDockview): void` | See [Serialization](/basics/#serialization) |
| toJSON | `(): SerializedDockview` | See [Serialization](/basics/#serialization) |
| Property | Type | Description |
| ---------------------- | ---------------------------------------------------- | ------------------------------------------- |
| height | `number` | Component pixel height |
| width | `number` | Component pixel width |
| minimumHeight | `number` | |
| maximumHeight | `number` | |
| maximumWidth | `number` | |
| maximumWidth | `number` | |
| length | `number` | Number of panels |
| size | `number` | Number of Groups |
| panels | `IDockviewPanel[]` | |
| groups | `IDockviewPanel[]` | |
| activePanel | `IDockviewPanel \| undefined` | |
| activeGroup | `IDockviewPanel \| undefined` | |
| | | |
| onDidLayoutChange | `Event<void>` | |
| onDidLayoutFromJSON | `Event<void>` | |
| onDidAddGroup | `Event<IDockviewPanel>` | |
| onDidRemoveGroup | `Event<IDockviewPanel>` | |
| onDidActiveGroupChange | `Event<IDockviewPanel \| undefined>` | |
| onDidAddPanel | `Event<IDockviewPanel>` | |
| onDidRemovePanel | `Event<IDockviewPanel>` | |
| onDidActivePanelChange | `Event<IDockviewPanel \| undefined>` | |
| onDidDrop | `Event<DockviewDropEvent` | |
| | | |
| addPanel | `addPanel(options: AddPanelOptions): IDockviewPanel` | |
| getPanel | `(id: string) \| IDockviewPanel \| undefined` | |
| addEmptyGroup | `(options? AddGroupOptions): void` | |
| closeAllGroups | `(): void` | |
| removeGroup | `(group: IDockviewPanel): void` | |
| getGroup | `(id: string): IDockviewPanel \| undefined` | |
| | | |
| getTabHeight | `(): number \| undefined` | |
| setTabHeight | `(hegiht: number \| undefined): void` | |
| updateOptions | `(options:SplitviewComponentUpdateOptions): void` | |
| focus | `(): void` | |
| layout | `(width: number, height:number): void` | See [Auto resizing](/basics/#auto-resizing) |
| fromJSON | `(data: SerializedDockview): void` | See [Serialization](/basics/#serialization) |
| toJSON | `(): SerializedDockview` | See [Serialization](/basics/#serialization) |
## Dockview Panel API
@ -102,7 +141,7 @@ const MyComponent = (props: IDockviewPanelProps<{ title: string }>) => {
| setConstraints | `(value: PanelConstraintChangeEvent2): void;` | |
| setSize | `(event: SizeEvent): void` | |
| | | |
| group | `GroupviewPanel | undefined` |
| group | `GroupPanel | undefined` |
| isGroupActive | `boolean` | |
| title | `string` | |
| suppressClosable | `boolean` | |

View File

@ -59,7 +59,6 @@ const onReady = (event: GridviewReadyEvent) => {
| setActive | `(panel: IGridviewPanel): void` | |
| toggleVisiblity | `(panel: IGridviewPanel): void` | |
| layout | `(width: number, height:number): void` | See [Auto resizing](/basics/#auto-resizing) |
| resizeToFit | `(): void` | See [Auto resizing](/basics/#auto-resizing) |
| fromJSON | `(data: SerializedGridview): void` | See [Serialization](/basics/#serialization) |
| toJSON | `(): SerializedGridview` | See [Serialization](/basics/#serialization) |

View File

@ -52,7 +52,6 @@ const onReady = (event: GridviewReadyEvent) => {
| | | |
| focus | `(): void` | |
| layout | `(width: number, height:number): void` | See [Auto resizing](/basics/#auto-resizing) |
| resizeToFit | `(): void` | See [Auto resizing](/basics/#auto-resizing) |
| fromJSON | `(data: SerializedPaneview): void` | See [Serialization](/basics/#serialization) |
| toJSON | `(): SerializedPaneview` | See [Serialization](/basics/#serialization) |

View File

@ -123,7 +123,6 @@ const onReady = (event: SplitviewReadyEvent) => {
| updateOptions | `(options:SplitviewComponentUpdateOptions): void` | |
| focus | `(): void` | |
| layout | `(width: number, height:number): void` | See [Auto resizing](/basics/#auto-resizing) |
| resizeToFit | `(): void` | See [Auto resizing](/basics/#auto-resizing) |
| fromJSON | `(data: SerializedSplitview): void` | See [Serialization](/basics/#serialization) |
| toJSON | `(): SerializedSplitview` | See [Serialization](/basics/#serialization) |

View File

@ -1,25 +1,31 @@
@import "./navigation.css";
@import "~dockview/dist/styles/dockview.css";
:root {
--primary-text-color:rgb(30,30,30);
--header-color:rgb(235, 235, 235);
--navigation-color:rgb(245, 245, 245);
--border-color:rgb(30,30,30)
}
html,
body {
padding: 0;
margin: 0;
/* font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; */
font-family: 'Roboto', sans-serif;
font-family: system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
font: 100% /1.65 system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
}
a {
.markdown-body a {
text-decoration: none;
color:dodgerblue;
}
a, a:hover, a:visited, a:active {
.markdown-body a, .markdown-body a:hover, .markdown-body a:visited, .markdown-body a:active {
color:dodgerblue;
}
a:hover {
.markdown-body a:hover {
text-decoration: underline;
}

View File

@ -1,6 +1,6 @@
.navigation {
padding: 30px;
background-color: lightgray;
background-color: var(--navigation-color);
font-size: 16px;
width: 200px;
border-radius: 15px;
@ -11,6 +11,11 @@
cursor: pointer;
}
.node a {
text-decoration: none;
color: inherit;
}
.expandable-node::after {
}