chore: docs

This commit is contained in:
mathuo 2024-09-05 20:26:17 +01:00
parent d1d8c8083e
commit 693a3cd6ef
No known key found for this signature in database
GPG Key ID: C6EEDEFD6CA07281
2 changed files with 59 additions and 32 deletions

View File

@ -13,10 +13,26 @@ import { GridActions } from './gridActions';
import { PanelActions } from './panelActions'; import { PanelActions } from './panelActions';
import { GroupActions } from './groupActions'; import { GroupActions } from './groupActions';
import { LeftControls, PrefixHeaderControls, RightControls } from './controls'; import { LeftControls, PrefixHeaderControls, RightControls } from './controls';
import { usePanelApiMetadata } from './debugPanel'; import { Table, usePanelApiMetadata } from './debugPanel';
const DebugContext = React.createContext<boolean>(false);
const Option = (props: {
title: string;
onClick: () => void;
value: string;
}) => {
return (
<div>
<span>{`${props.title}: `}</span>
<button onClick={props.onClick}>{props.value}</button>
</div>
);
};
const components = { const components = {
default: (props: IDockviewPanelProps) => { default: (props: IDockviewPanelProps) => {
const isDebug = React.useContext(DebugContext);
const metadata = usePanelApiMetadata(props.api); const metadata = usePanelApiMetadata(props.api);
return ( return (
@ -24,13 +40,11 @@ const components = {
style={{ style={{
height: '100%', height: '100%',
overflow: 'auto', overflow: 'auto',
color: 'white',
position: 'relative', position: 'relative',
padding: 5, padding: 5,
// border: '5px dashed purple', border: isDebug ? '2px dashed orange' : '',
}} }}
> >
{/* <Table data={metadata} /> */}
<span <span
style={{ style={{
position: 'absolute', position: 'absolute',
@ -45,21 +59,23 @@ const components = {
{props.api.title} {props.api.title}
</span> </span>
<div> {isDebug && (
<span>{'Panel Rendering Mode: '}</span> <div style={{ fontSize: '0.8em' }}>
<span>{metadata.renderer.value}</span> <Option
<button title="Panel Rendering Mode"
onClick={() => { value={metadata.renderer.value}
onClick={() =>
props.api.setRenderer( props.api.setRenderer(
props.api.renderer === 'always' props.api.renderer === 'always'
? 'onlyWhenVisible' ? 'onlyWhenVisible'
: 'always' : 'always'
); )
}} }
> />
Toggle
</button> <Table data={metadata} />
</div> </div>
)}
</div> </div>
); );
}, },
@ -238,6 +254,7 @@ const DockviewDemo = (props: { theme?: string }) => {
}, [gapCheck]); }, [gapCheck]);
const [showLogs, setShowLogs] = React.useState<boolean>(false); const [showLogs, setShowLogs] = React.useState<boolean>(false);
const [debug, setDebug] = React.useState<boolean>(false);
return ( return (
<div <div
@ -292,6 +309,15 @@ const DockviewDemo = (props: { theme?: string }) => {
padding: '4px', padding: '4px',
}} }}
> >
<button
onClick={() => {
setDebug(!debug);
}}
>
<span className="material-symbols-outlined">
engineering
</span>
</button>
<button <button
onClick={() => { onClick={() => {
setShowLogs(!showLogs); setShowLogs(!showLogs);
@ -318,6 +344,7 @@ const DockviewDemo = (props: { theme?: string }) => {
display: 'flex', display: 'flex',
}} }}
> >
<DebugContext.Provider value={debug}>
<DockviewReact <DockviewReact
components={components} components={components}
defaultTabComponent={headerComponents.default} defaultTabComponent={headerComponents.default}
@ -330,6 +357,7 @@ const DockviewDemo = (props: { theme?: string }) => {
onReady={onReady} onReady={onReady}
className={props.theme || 'dockview-theme-abyss'} className={props.theme || 'dockview-theme-abyss'}
/> />
</DebugContext.Provider>
</div> </div>
{showLogs && ( {showLogs && (

View File

@ -91,7 +91,6 @@ function usePopover() {
export const GridActions = (props: { export const GridActions = (props: {
api?: DockviewApi; api?: DockviewApi;
containerRef: HTMLElement;
hasCustomWatermark: boolean; hasCustomWatermark: boolean;
toggleCustomWatermark: () => void; toggleCustomWatermark: () => void;
}) => { }) => {