Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
add icon (#4177)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzhe-lz authored Sep 15, 2021
1 parent 0ad73ef commit 9a9cb3d
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions ts/jupyter_extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'
import { ICommandPalette, IFrame } from '@jupyterlab/apputils';
import { PageConfig } from '@jupyterlab/coreutils';
import { ILauncher } from '@jupyterlab/launcher';
import { LabIcon } from '@jupyterlab/ui-components';

const nniIconSvg = `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 162 84">
<polygon fill="#0b6bac" points="0,84 12,84 34,18 56,84 68,84 87,27 75,27 62,66 40,0 28,0 0,84"/>
<polygon fill="#0b6bac" points="94,84 106,84 125,27 113,27 100,66 90,36 84,54 94,84"/>
<polygon fill="#0b6bac" points="122,0 128,18 140,18 134,0 122,0"/>
<polygon fill="#0b6bac" points="131,27 150,84 162,84 143,27 131,27"/>
</svg>
`;
const nniIcon = new LabIcon({ name: 'nni', svgstr: nniIconSvg });

class NniWidget extends IFrame {
constructor() {
Expand All @@ -14,6 +25,7 @@ class NniWidget extends IFrame {
this.url = PageConfig.getBaseUrl() + 'nni/index';
this.id = 'nni';
this.title.label = 'NNI';
this.title.icon = nniIcon;
this.title.closable = true;
}
}
Expand All @@ -27,7 +39,7 @@ async function activate(app: JupyterFrontEnd, palette: ICommandPalette, launcher
commands.addCommand(command, {
label: 'NNI',
caption: 'NNI',
iconClass: (args) => (args.isPalette ? null : 'jp-Launcher-kernelIcon'),
icon: (args) => (args.isPalette ? null : nniIcon),
execute: () => {
shell.add(new NniWidget(), 'main');
}
Expand All @@ -36,11 +48,7 @@ async function activate(app: JupyterFrontEnd, palette: ICommandPalette, launcher
palette.addItem({ command, category });

if (launcher) {
launcher.add({
command,
category,
kernelIconUrl: '/nni/icon.png' // FIXME: this field only works for "Notebook" category
});
launcher.add({ command, category });
}
}

Expand Down

0 comments on commit 9a9cb3d

Please sign in to comment.