Skip to content

Commit c69e6f9

Browse files
committed
chore: docs
1 parent 33f08a8 commit c69e6f9

File tree

23 files changed

+424
-13
lines changed

23 files changed

+424
-13
lines changed

packages/docs/docs/core/overview.mdx

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ sidebar_position: 0
55

66
This section provided a core overview.
77

8-
9-
After creating an instance of the component you will want to obtain a reference to the [API](/docs/api/dockview/overview)
10-
object which will facilitate further interactions with the component.
8+
Once you have created an dock you will want to store a reference to the [API](/docs/api/dockview/overview).
119

1210
<FrameworkSpecific framework='React'>
1311
```tsx

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

+10
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,18 @@ title: Add Panel
33
sidebar_position: 1
44
---
55

6+
import { DocRef } from '@site/src/components/ui/reference/docRef';
7+
68
This section describes how to add a new panel.
79

10+
## API
11+
12+
The API associated with opening a panel
13+
14+
<DocRef declaration="DockviewApi" methods={['addPanel']} />
15+
16+
## Open a panel
17+
818
Using the dockview API you can access the `addPanel` method which returns an instance of the created panel.
919
The minimum method signature is:
1020

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

+20-9
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,30 @@ title: Register A Panel
33
sidebar_position: 0
44
---
55

6-
This section describes how to register a panel for later use.
6+
This section describes how to register a panel.
77

8-
The render implementation of the panel is linked to a key that can be referenced later on.
9-
A collection of panels can be provided through the `components` option.
8+
You can register panes through the `components` option.
109

1110
<FrameworkSpecific framework='React'>
12-
```tsx
13-
const components = {
14-
my_component: (props: IDockviewPanelProps) => {
11+
```jsx
12+
<DockviewReact components={{
13+
component_1: (props: IDockviewPanelProps) => {
14+
const api: DockviewPanelApi = props.api;
15+
const containerApi: DockviewApi = props.containerApi;
16+
17+
return <div>{/** logic */}</div>
18+
},
19+
component_2: (props: IDockviewPanelProps) => {
1520
return <div>{/** logic */}</div>
1621
}
17-
}
18-
19-
<DockviewReact components={components}/>
22+
}}/>
2023
```
2124
</FrameworkSpecific>
25+
26+
27+
Each panel has an [API](/docs/api/dockview/panelApi) which can be used to control the panel and you can
28+
also has access the dock [API](/docs/api/dockview/overview) directly from the panel.
29+
30+
It is expected you should be able to achieve everything you need through these two APIs. If you find yourself
31+
building work-arounds to accommodate requires please raise an [Issue](https://github.com/mathuo/dockview/issues)
32+
to see if it's something that could be added.

packages/docs/docs/core/panels/update.mdx

+14
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ title: Update Panel
33
sidebar_position: 2
44
---
55

6+
import { DocRef } from '@site/src/components/ui/reference/docRef';
7+
8+
This section describes how to update the parameters of a panel.
9+
10+
:::warning
11+
**Use this feature sparingly**: Anything you assign to the `params` options of a panel will be persisted.
12+
Only use this to store small amounts of static view data.
13+
**Do not** use this to pass application state.
14+
:::
15+
16+
## Panel API
17+
18+
<DocRef declaration="DockviewPanelApi" methods={['updateParameters']} />
19+
620
## Update Panel
721

822
You can programatically update the `params` passed through to the panel through the panal api using `api.updateParameters`.

packages/docs/src/components/ui/reference/docRef.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import './docRef.scss';
44

55
export interface DocRefProps {
66
declaration: string;
7+
methods?: string[];
78
}
89

910
import docsJson from '../../../generated/api.output.json';
@@ -87,6 +88,10 @@ export const DocRef = (props: DocRefProps) => {
8788
<table className="doc-ref-table">
8889
<tbody>
8990
{docs.map((doc) => {
91+
if (props.methods && !props.methods.includes(doc.name)) {
92+
return null;
93+
}
94+
9095
return (
9196
<tr>
9297
<th

packages/docs/src/css/custom.scss

+35
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
:root {
1414
--ifm-font-weight-bold: 600;
1515

16+
--ifm-alert-padding-vertical: 8px;
17+
--ifm-alert-padding-horizontal: 8px;
18+
1619
--ifm-color-primary: #21222c;
1720
--ifm-color-primary-dark: #1e1f28;
1821
--ifm-color-primary-darker: #1c1d25;
@@ -112,6 +115,22 @@
112115

113116
tr {
114117
background-color: inherit !important;
118+
119+
&:last-child {
120+
border-bottom: var(--ifm-table-border-width) solid
121+
var(--ifm-table-border-color);
122+
}
123+
}
124+
}
125+
126+
code {
127+
.token {
128+
&.maybe-class-name {
129+
color: #cf8cff;
130+
}
131+
&.keyword {
132+
color: rgb(130, 170, 255);
133+
}
115134
}
116135
}
117136
}
@@ -211,3 +230,19 @@
211230
var(--ifm-transition-timing-default);
212231
}
213232
}
233+
234+
.toc-display {
235+
display: none;
236+
}
237+
238+
@media (min-width: 1500px) {
239+
.toc-display {
240+
display: block;
241+
}
242+
}
243+
244+
.theme-admonition {
245+
border: none;
246+
display: flex;
247+
padding: 8px 16px;
248+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
export default function AdmonitionIconDanger(props) {
3+
return (
4+
<svg viewBox="0 0 12 16" {...props}>
5+
<path
6+
fillRule="evenodd"
7+
d="M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"
8+
/>
9+
</svg>
10+
);
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
export default function AdmonitionIconInfo(props) {
3+
return (
4+
<svg viewBox="0 0 14 16" {...props}>
5+
<path
6+
fillRule="evenodd"
7+
d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"
8+
/>
9+
</svg>
10+
);
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
export default function AdmonitionIconNote(props) {
3+
return (
4+
<svg viewBox="0 0 14 16" {...props}>
5+
<path
6+
fillRule="evenodd"
7+
d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"
8+
/>
9+
</svg>
10+
);
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
export default function AdmonitionIconTip(props) {
3+
return (
4+
<svg viewBox="0 0 12 16" {...props}>
5+
<path
6+
fillRule="evenodd"
7+
d="M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"
8+
/>
9+
</svg>
10+
);
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
export default function AdmonitionIconCaution(props) {
3+
return (
4+
<svg viewBox="0 0 16 16" {...props}>
5+
<path
6+
fillRule="evenodd"
7+
d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"
8+
/>
9+
</svg>
10+
);
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from 'react';
2+
import clsx from 'clsx';
3+
import { ThemeClassNames } from '@docusaurus/theme-common';
4+
import styles from './styles.module.css';
5+
function AdmonitionContainer({ type, className, children }) {
6+
return (
7+
<div
8+
className={clsx(
9+
ThemeClassNames.common.admonition,
10+
ThemeClassNames.common.admonitionType(type),
11+
styles.admonition,
12+
className
13+
)}
14+
>
15+
{children}
16+
</div>
17+
);
18+
}
19+
function AdmonitionHeading({ icon, title }) {
20+
return (
21+
<div className={styles.admonitionHeading}>
22+
<span className={styles.admonitionIcon}>{icon}</span>
23+
{/* {title} */}
24+
</div>
25+
);
26+
}
27+
function AdmonitionContent({ children }) {
28+
return children ? (
29+
<div className={styles.admonitionContent}>{children}</div>
30+
) : null;
31+
}
32+
export default function AdmonitionLayout(props) {
33+
const { type, icon, title, children, className } = props;
34+
return (
35+
<AdmonitionContainer type={type} className={className}>
36+
<AdmonitionHeading title={title} icon={icon} />
37+
<AdmonitionContent>{children}</AdmonitionContent>
38+
</AdmonitionContainer>
39+
);
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.admonition {
2+
margin-bottom: 1em;
3+
}
4+
5+
.admonitionHeading {
6+
font: var(--ifm-heading-font-weight) var(--ifm-h5-font-size) /
7+
var(--ifm-heading-line-height) var(--ifm-heading-font-family);
8+
text-transform: uppercase;
9+
}
10+
11+
/* Heading alone without content (does not handle fragment content) */
12+
.admonitionHeading:not(:last-child) {
13+
margin-bottom: 0.3rem;
14+
}
15+
16+
.admonitionHeading code {
17+
text-transform: none;
18+
}
19+
20+
.admonitionIcon {
21+
display: inline-block;
22+
vertical-align: middle;
23+
margin-right: 0.4em;
24+
}
25+
26+
.admonitionIcon svg {
27+
display: inline-block;
28+
height: 1.6em;
29+
width: 1.6em;
30+
fill: var(--ifm-alert-foreground-color);
31+
}
32+
33+
.admonitionContent > :last-child {
34+
margin-bottom: 0;
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import clsx from 'clsx';
3+
import Translate from '@docusaurus/Translate';
4+
import AdmonitionLayout from '@theme/Admonition/Layout';
5+
import IconWarning from '@theme/Admonition/Icon/Warning';
6+
const infimaClassName = 'alert alert--warning';
7+
const defaultProps = {
8+
icon: <IconWarning />,
9+
title: (
10+
<Translate
11+
id="theme.admonition.caution"
12+
description="The default label used for the Caution admonition (:::caution)">
13+
caution
14+
</Translate>
15+
),
16+
};
17+
// TODO remove before v4: Caution replaced by Warning
18+
// see https://github.com/facebook/docusaurus/issues/7558
19+
export default function AdmonitionTypeCaution(props) {
20+
return (
21+
<AdmonitionLayout
22+
{...defaultProps}
23+
{...props}
24+
className={clsx(infimaClassName, props.className)}>
25+
{props.children}
26+
</AdmonitionLayout>
27+
);
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
import clsx from 'clsx';
3+
import Translate from '@docusaurus/Translate';
4+
import AdmonitionLayout from '@theme/Admonition/Layout';
5+
import IconDanger from '@theme/Admonition/Icon/Danger';
6+
const infimaClassName = 'alert alert--danger';
7+
const defaultProps = {
8+
icon: <IconDanger />,
9+
title: (
10+
<Translate
11+
id="theme.admonition.danger"
12+
description="The default label used for the Danger admonition (:::danger)">
13+
danger
14+
</Translate>
15+
),
16+
};
17+
export default function AdmonitionTypeDanger(props) {
18+
return (
19+
<AdmonitionLayout
20+
{...defaultProps}
21+
{...props}
22+
className={clsx(infimaClassName, props.className)}>
23+
{props.children}
24+
</AdmonitionLayout>
25+
);
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
import clsx from 'clsx';
3+
import Translate from '@docusaurus/Translate';
4+
import AdmonitionLayout from '@theme/Admonition/Layout';
5+
import IconInfo from '@theme/Admonition/Icon/Info';
6+
const infimaClassName = 'alert alert--info';
7+
const defaultProps = {
8+
icon: <IconInfo />,
9+
title: (
10+
<Translate
11+
id="theme.admonition.info"
12+
description="The default label used for the Info admonition (:::info)">
13+
info
14+
</Translate>
15+
),
16+
};
17+
export default function AdmonitionTypeInfo(props) {
18+
return (
19+
<AdmonitionLayout
20+
{...defaultProps}
21+
{...props}
22+
className={clsx(infimaClassName, props.className)}>
23+
{props.children}
24+
</AdmonitionLayout>
25+
);
26+
}

0 commit comments

Comments
 (0)