Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bottom Panel Implementation #4752

Merged
merged 11 commits into from Jun 27, 2018
40 changes: 39 additions & 1 deletion packages/application/src/shell.ts
Expand Up @@ -73,6 +73,7 @@ class ApplicationShell extends Widget {
this.addClass(APPLICATION_SHELL_CLASS);
this.id = 'main';

let bottomPanel = this._bottomPanel = new BoxPanel();
let topPanel = this._topPanel = new Panel();
let hboxPanel = this._hboxPanel = new BoxPanel();
let dockPanel = this._dockPanel = new DockPanel();
Expand All @@ -83,6 +84,8 @@ class ApplicationShell extends Widget {
let rightHandler = this._rightHandler = new Private.SideBarHandler('right');
let rootLayout = new BoxLayout();


bottomPanel.id = 'jp-bottom-panel';
topPanel.id = 'jp-top-panel';
hboxPanel.id = 'jp-main-content-panel';
dockPanel.id = 'jp-main-dock-panel';
Expand All @@ -96,6 +99,7 @@ class ApplicationShell extends Widget {
rightHandler.sideBar.addClass('jp-mod-right');
rightHandler.stackedPanel.id = 'jp-right-stack';

bottomPanel.direction = 'bottom-to-top';
hboxPanel.spacing = 0;
dockPanel.spacing = 5;
hsplitPanel.spacing = 1;
Expand Down Expand Up @@ -124,9 +128,14 @@ class ApplicationShell extends Widget {

BoxLayout.setStretch(topPanel, 0);
BoxLayout.setStretch(hboxPanel, 1);
BoxLayout.setStretch(bottomPanel, 0);

rootLayout.addWidget(topPanel);
rootLayout.addWidget(hboxPanel);
rootLayout.addWidget(bottomPanel);

// initially hiding bottom panel when no elements inside
this._bottomPanel.hide();

this.layout = rootLayout;

Expand Down Expand Up @@ -191,6 +200,7 @@ class ApplicationShell extends Widget {
return !this._rightHandler.sideBar.currentTitle;
}


/**
* Whether JupyterLab is in presentation mode with the `jp-mod-presentationMode` CSS class.
*/
Expand Down Expand Up @@ -441,6 +451,29 @@ class ApplicationShell extends Widget {
this._onLayoutModified();
}


/**
* Add a widget to the bottom content area.
*
* #### Notes
* Widgets must have a unique `id` property, which will be used as the DOM id.
*/

addToBottomArea(widget: Widget, options: ApplicationShell.ISideAreaOptions = {}): void {
if (!widget.id) {
console.error('Widgets added to app shell must have unique id property.');
return;
}
// Temporary: widgets are added to the panel in order of insertion.
this._bottomPanel.addWidget(widget);
this._onLayoutModified();

if (this._bottomPanel.isHidden) {
this._bottomPanel.show();
}
}


/**
* Collapse the left area.
*/
Expand Down Expand Up @@ -502,6 +535,8 @@ class ApplicationShell extends Widget {
return this._dockPanel.isEmpty;
case 'top':
return this._topPanel.widgets.length === 0;
case 'bottom':
return this._bottomPanel.widgets.length === 0;
case 'right':
return this._rightHandler.stackedPanel.widgets.length === 0;
default:
Expand Down Expand Up @@ -581,6 +616,8 @@ class ApplicationShell extends Widget {
return iter(this._rightHandler.sideBar.titles.map(t => t.owner));
case 'top':
return this._topPanel.children();
case 'bottom':
return this._bottomPanel.children();
default:
throw new Error('Invalid area');
}
Expand Down Expand Up @@ -702,6 +739,7 @@ class ApplicationShell extends Widget {
private _rightHandler: Private.SideBarHandler;
private _tracker = new FocusTracker<Widget>();
private _topPanel: Panel;
private _bottomPanel: Panel;
}


Expand All @@ -714,7 +752,7 @@ namespace ApplicationShell {
* The areas of the application shell where widgets can reside.
*/
export
type Area = 'main' | 'top' | 'left' | 'right';
type Area = 'main' | 'top' | 'left' | 'right' | 'bottom';

/**
* The restorable description of an area within the main dock panel.
Expand Down
5 changes: 5 additions & 0 deletions packages/application/style/index.css
Expand Up @@ -46,6 +46,11 @@ body {
min-height: var(--jp-private-menubar-height);
}

#jp-bottom-panel {
border-bottom: var(--jp-border-width) solid var(--jp-border-color0);
background: var(--jp-layout-color1);
display: flex;
}

/* Sibling imports */
@import './datagrid.css';
Expand Down