mirror of
https://github.com/mathuo/dockview
synced 2025-08-29 13:36:31 +00:00
refactor: single tab mode
This commit is contained in:
parent
01816a1d8b
commit
026e6b9b91
@ -57,10 +57,7 @@ export interface PanelApi {
|
|||||||
/**
|
/**
|
||||||
* A core api implementation that should be used across all panel-like objects
|
* A core api implementation that should be used across all panel-like objects
|
||||||
*/
|
*/
|
||||||
export abstract class PanelApiImpl
|
export class PanelApiImpl extends CompositeDisposable implements PanelApi {
|
||||||
extends CompositeDisposable
|
|
||||||
implements PanelApi
|
|
||||||
{
|
|
||||||
private _isFocused = false;
|
private _isFocused = false;
|
||||||
private _isActive = false;
|
private _isActive = false;
|
||||||
private _isVisible = true;
|
private _isVisible = true;
|
||||||
|
@ -68,6 +68,7 @@ export interface DockviewComponentOptions extends DockviewRenderFunctions {
|
|||||||
defaultTabComponent?: string;
|
defaultTabComponent?: string;
|
||||||
showDndOverlay?: (event: DockviewDndOverlayEvent) => boolean;
|
showDndOverlay?: (event: DockviewDndOverlayEvent) => boolean;
|
||||||
createGroupControlElement?: (group: GroupPanel) => IGroupControlRenderer;
|
createGroupControlElement?: (group: GroupPanel) => IGroupControlRenderer;
|
||||||
|
singleTabMode?: 'fullwidth' | 'default';
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PanelOptions {
|
export interface PanelOptions {
|
||||||
|
@ -234,9 +234,7 @@ export class Groupview extends CompositeDisposable implements IGroupview {
|
|||||||
|
|
||||||
this.container.classList.add('groupview');
|
this.container.classList.add('groupview');
|
||||||
|
|
||||||
this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel, {
|
this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
|
||||||
tabHeight: options.tabHeight,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.contentContainer = new ContentContainer();
|
this.contentContainer = new ContentContainer();
|
||||||
|
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.single-panel {
|
&.dv-single-tab.dv-full-width-single-tab {
|
||||||
background-color: red !important;
|
|
||||||
|
|
||||||
.tabs-container {
|
.tabs-container {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
|
||||||
|
@ -135,8 +135,7 @@ export class TabsContainer
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly accessor: DockviewComponent,
|
private readonly accessor: DockviewComponent,
|
||||||
private readonly group: GroupPanel,
|
private readonly group: GroupPanel
|
||||||
readonly options: { tabHeight?: number }
|
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@ -145,17 +144,31 @@ export class TabsContainer
|
|||||||
this._element = document.createElement('div');
|
this._element = document.createElement('div');
|
||||||
this._element.className = 'tabs-and-actions-container';
|
this._element.className = 'tabs-and-actions-container';
|
||||||
|
|
||||||
this.height = options.tabHeight;
|
this.height = accessor.options.tabHeight;
|
||||||
|
|
||||||
|
toggleClass(
|
||||||
|
this._element,
|
||||||
|
'dv-full-width-single-tab',
|
||||||
|
this.accessor.options.singleTabMode === 'fullwidth'
|
||||||
|
);
|
||||||
|
|
||||||
this.addDisposables(
|
this.addDisposables(
|
||||||
this.accessor.onDidAddPanel((e) => {
|
this.accessor.onDidAddPanel((e) => {
|
||||||
if (e.api.group === this.group) {
|
if (e.api.group === this.group) {
|
||||||
toggleClass(this._element, 'single-panel', this.size === 1);
|
toggleClass(
|
||||||
|
this._element,
|
||||||
|
'dv-single-tab',
|
||||||
|
this.size === 1
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
this.accessor.onDidRemovePanel((e) => {
|
this.accessor.onDidRemovePanel((e) => {
|
||||||
if (e.api.group === this.group) {
|
if (e.api.group === this.group) {
|
||||||
toggleClass(this._element, 'single-panel', this.size === 1);
|
toggleClass(
|
||||||
|
this._element,
|
||||||
|
'dv-single-tab',
|
||||||
|
this.size === 1
|
||||||
|
);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -69,6 +69,7 @@ export interface IDockviewReactProps {
|
|||||||
disableAutoResizing?: boolean;
|
disableAutoResizing?: boolean;
|
||||||
defaultTabComponent?: React.FunctionComponent<IDockviewPanelHeaderProps>;
|
defaultTabComponent?: React.FunctionComponent<IDockviewPanelHeaderProps>;
|
||||||
groupControlComponent?: React.FunctionComponent<IDockviewGroupControlProps>;
|
groupControlComponent?: React.FunctionComponent<IDockviewGroupControlProps>;
|
||||||
|
singleTabMode?: 'fullwidth' | 'default';
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DockviewReact = React.forwardRef(
|
export const DockviewReact = React.forwardRef(
|
||||||
@ -161,6 +162,7 @@ export const DockviewReact = React.forwardRef(
|
|||||||
props.groupControlComponent,
|
props.groupControlComponent,
|
||||||
{ addPortal }
|
{ addPortal }
|
||||||
),
|
),
|
||||||
|
singleTabMode: props.singleTabMode,
|
||||||
});
|
});
|
||||||
|
|
||||||
domRef.current?.appendChild(dockview.element);
|
domRef.current?.appendChild(dockview.element);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user