Skip to content

Commit 7169e9f

Browse files
author
Frederic Collonval
committed
Start using IIconRegistry
1 parent 14027ee commit 7169e9f

File tree

7 files changed

+463
-418
lines changed

7 files changed

+463
-418
lines changed

package.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
"style/*.css",
3232
"style/images/*.svg"
3333
],
34+
"sideEffects": [
35+
"style/*.css"
36+
],
3437
"jupyterlab": {
3538
"extension": true,
3639
"discovery": {
@@ -46,14 +49,15 @@
4649
}
4750
},
4851
"dependencies": {
49-
"@jupyterlab/application": "^1.0.0",
50-
"@jupyterlab/apputils": "^1.0.0",
51-
"@jupyterlab/console": "^1.0.0",
52+
"@jupyterlab/application": "^1.1.0",
53+
"@jupyterlab/apputils": "^1.1.0",
54+
"@jupyterlab/console": "^1.1.0",
5255
"@jupyterlab/coreutils": "^3.0.0",
53-
"@jupyterlab/filebrowser": "^1.0.0",
54-
"@jupyterlab/mainmenu": "^1.0.0",
55-
"@jupyterlab/services": "^4.0.0",
56-
"@jupyterlab/terminal": "^1.0.0",
56+
"@jupyterlab/filebrowser": "^1.1.0",
57+
"@jupyterlab/mainmenu": "^1.1.0",
58+
"@jupyterlab/services": "^4.1.0",
59+
"@jupyterlab/terminal": "^1.1.0",
60+
"@jupyterlab/ui-components": "^1.1.0",
5761
"@phosphor/widgets": "^1.8.0",
5862
"nbdime": "~5.0.1",
5963
"react": "~16.8.4",

src/componentsStyle/GitWidgetStyle.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,3 @@ export const gitWidgetStyle = style({
88
background: 'var(--jp-layout-color1)',
99
fontSize: 'var(--jp-ui-font-size0)'
1010
});
11-
12-
export const gitTabStyle = style({
13-
backgroundImage: 'var(--jp-icon-git)'
14-
});

src/icons.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { IIconRegistry } from '@jupyterlab/ui-components';
2+
3+
// icon svg import statements
4+
import gitSvg from '../style/images/git-icon.svg';
5+
6+
export function registerGitIcons(iconRegistry: IIconRegistry) {
7+
iconRegistry.addIcon({
8+
name: 'git',
9+
svg: gitSvg
10+
});
11+
}

src/index.ts

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,22 @@
1-
import { addCommands, CommandIDs } from './gitMenuCommands';
2-
3-
import { PathExt } from '@jupyterlab/coreutils';
4-
5-
import { GitWidget } from './components/GitWidget';
6-
71
import {
82
ILayoutRestorer,
93
JupyterFrontEnd,
104
JupyterFrontEndPlugin
115
} from '@jupyterlab/application';
12-
6+
import { PathExt } from '@jupyterlab/coreutils';
137
import { IFileBrowserFactory } from '@jupyterlab/filebrowser';
14-
158
import { IMainMenu } from '@jupyterlab/mainmenu';
16-
17-
import { Menu } from '@phosphor/widgets';
18-
9+
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
10+
import { defaultIconRegistry } from '@jupyterlab/ui-components';
1911
import { Token } from '@phosphor/coreutils';
20-
21-
import { gitTabStyle } from './componentsStyle/GitWidgetStyle';
22-
12+
import { Menu } from '@phosphor/widgets';
13+
import { GitWidget } from './components/GitWidget';
2314
import { IDiffCallback } from './git';
24-
export { IDiffCallback } from './git';
25-
26-
import '../style/variables.css';
27-
import '../style/diff.css';
28-
import '../style/diff.css';
15+
import { addCommands, CommandIDs } from './gitMenuCommands';
16+
import { registerGitIcons } from './icons';
2917
import { GitClone } from './widgets/gitClone';
30-
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
18+
19+
export { IDiffCallback } from './git';
3120

3221
export const EXTENSION_ID = 'jupyter.extensions.git_plugin';
3322

@@ -78,7 +67,7 @@ export class GitExtension implements IGitExtension {
7867
renderMime
7968
);
8069
this.gitPlugin.id = 'jp-git-sessions';
81-
this.gitPlugin.title.iconClass = `jp-SideBar-tabIcon ${gitTabStyle}`;
70+
this.gitPlugin.title.iconClass = `jp-SideBar-tabIcon jp-GitIcon`;
8271
this.gitPlugin.title.caption = 'Git';
8372

8473
// Let the application restorer track the running panel for restoration of
@@ -123,6 +112,9 @@ function activate(
123112
renderMime: IRenderMimeRegistry
124113
): IGitExtension {
125114
const { commands } = app;
115+
116+
registerGitIcons(defaultIconRegistry);
117+
126118
let gitExtension = new GitExtension(app, restorer, factory, renderMime);
127119

128120
const category = 'Git';

src/svg.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) Jupyter Development Team.
2+
// Distributed under the terms of the Modified BSD License.
3+
4+
// including this file in a package allows for the use of import statements
5+
// with svg files. Example: `import xSvg from 'path/xSvg.svg'`
6+
7+
// for use with raw-loader in Webpack.
8+
// The svg will be imported as a raw string
9+
10+
declare module '*.svg' {
11+
const value: string;
12+
export default value;
13+
}

style/images/git-icon.svg

Lines changed: 47 additions & 37 deletions
Loading

0 commit comments

Comments
 (0)