Skip to content

Commit

Permalink
add new tab button (#33)
Browse files Browse the repository at this point in the history
* Add new tab button
Fixes #32

* Fix search input styling
  • Loading branch information
fcollonval authored May 18, 2022
1 parent 087621f commit 4c95ca6
Show file tree
Hide file tree
Showing 5 changed files with 3,662 additions and 1,323 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jlab-enhanced/launcher",
"version": "3.1.0",
"version": "3.2.0",
"description": "A enhanced launcher for JupyterLab",
"keywords": [
"jupyter",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
from jupyter_packaging import wrap_installers, npm_builder, get_data_files

post_develop = npm_builder(
build_cmd="install:extension", source_dir="src", build_dir=lab_path
npm=["jlpm"], build_cmd="install:extension", source_dir="src", build_dir=lab_path
)
setup_args["cmdclass"] = wrap_installers(
post_develop=post_develop, ensured_targets=ensured_targets
Expand Down
22 changes: 20 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { toArray } from '@lumino/algorithm';

import { ReadonlyPartialJSONObject } from '@lumino/coreutils';

import { Widget } from '@lumino/widgets';
import { DockPanel, TabBar, Widget } from '@lumino/widgets';

import { EXTENSION_ID, Launcher, LauncherModel } from './launcher';

Expand Down Expand Up @@ -112,7 +112,10 @@ async function activate(
main.title.closable = !!toArray(shell.widgets('main')).length;
main.id = id;

shell.add(main, 'main', { activate: args['activate'] as boolean });
shell.add(main, 'main', {
activate: args['activate'] as boolean,
ref: args['ref'] as string
});

if (labShell) {
labShell.layoutModified.connect(() => {
Expand All @@ -132,6 +135,21 @@ async function activate(
});
}

if (labShell && app.version >= '3.4.0') {
labShell.addButtonEnabled = true;
labShell.addRequested.connect((sender: DockPanel, arg: TabBar<Widget>) => {
// Get the ref for the current tab of the tabbar which the add button was clicked
const ref =
arg.currentTitle?.owner.id ||
arg.titles[arg.titles.length - 1].owner.id;
if (commands.hasCommand('filebrowser:create-main-launcher')) {
// If a file browser is defined connect the launcher to it
return commands.execute('filebrowser:create-main-launcher', { ref });
}
return commands.execute(CommandIDs.create, { ref });
});
}

return model;
}

Expand Down
6 changes: 2 additions & 4 deletions style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,19 @@

.jp-NewLauncher-search-wrapper::after {
content: ' ';
color: white;
background-color: var(--jp-brand-color1);
position: absolute;
height: 32px;
width: 12px;
padding: 0px 12px;
background-image: var(--jp-icon-search-white);
background-image: var(--jp-icon-search);
background-size: 20px;
background-repeat: no-repeat;
background-position: center;
left: 164px;
}

.jp-NewLauncher-search-input {
padding: 0px 9px;
padding: 0px 25px 0 9px;
background-color: var(--jp-input-active-background);
box-shadow: inset 0 0 0 var(--jp-border-width) var(--jp-input-border-color);
width: 150px;
Expand Down
Loading

0 comments on commit 4c95ca6

Please sign in to comment.