Skip to content

Commit a71c382

Browse files
Merge pull request #84 from hbcarlos/command-toolbar-buttons
Theme issue with toolbar buttons
2 parents e9260dd + f75d5f0 commit a71c382

25 files changed

+432
-36
lines changed

src/editor.ts

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import { MainMenu, JupyterLabMenu } from '@jupyterlab/mainmenu';
1818

1919
import { IChangedArgs, PathExt } from '@jupyterlab/coreutils';
2020

21+
import { undoIcon, redoIcon } from '@jupyterlab/ui-components';
22+
2123
import { CommandRegistry } from '@lumino/commands';
2224

2325
import { Signal } from '@lumino/signaling';
@@ -26,6 +28,19 @@ import { DrawIOWidget } from './widget';
2628

2729
import { DrawIOToolbarButton } from './toolbar';
2830

31+
import {
32+
formatPanelIcon,
33+
plusIcon,
34+
zoominIcon,
35+
zoomoutIcon,
36+
deleteIcon,
37+
toFrontIcon,
38+
toBackIcon,
39+
fillColorIcon,
40+
strokeColorIcon,
41+
shadowIcon
42+
} from './icons';
43+
2944
const DIRTY_CLASS = 'jp-mod-dirty';
3045

3146
export class DrawIODocumentWidget extends DocumentWidget<DrawIOWidget> {
@@ -41,12 +56,13 @@ export class DrawIODocumentWidget extends DocumentWidget<DrawIOWidget> {
4156
this._menubar = new MainMenu(this._commands);
4257

4358
this._menubar.clearMenus();
59+
this.toolbar.addClass('dio-toolbar');
4460

4561
//TODO:
4662
// Add toolbar actions to change the default style of arrows and conections.
4763
this._menuView = new JupyterLabMenu({ commands: this._commands });
4864
this._menuView.menu.title.caption = 'View (Space+Drag to Scroll)';
49-
this._menuView.menu.title.iconClass = 'geSprite geSprite-formatpanel';
65+
this._menuView.menu.title.icon = formatPanelIcon;
5066
this._menubar.addMenu(this._menuView.menu, { rank: 1 });
5167

5268
this._menuZoom = new JupyterLabMenu({ commands: this._commands });
@@ -57,7 +73,7 @@ export class DrawIODocumentWidget extends DocumentWidget<DrawIOWidget> {
5773

5874
this._menuInsert = new JupyterLabMenu({ commands: this._commands });
5975
this._menuInsert.menu.title.caption = 'Insert';
60-
this._menuInsert.menu.title.iconClass = 'geSprite geSprite-plus';
76+
this._menuInsert.menu.title.icon = plusIcon;
6177
this._menubar.addMenu(this._menuInsert.menu, { rank: 2 });
6278

6379
this.context.ready.then(async value => {
@@ -201,41 +217,56 @@ export class DrawIODocumentWidget extends DocumentWidget<DrawIOWidget> {
201217

202218
this.toolbar.addItem('ViewDropdown', this._menubar);
203219

204-
actions['zoomIn'].iconCls = 'geSprite geSprite-zoomin';
220+
actions['zoomIn'].icon = zoominIcon;
221+
actions['zoomIn'].tooltip = 'Zoom In (Ctrl+(Numpad)/Alt+Mousewheel)';
205222
this.toolbar.addItem('zoomIn', new DrawIOToolbarButton(actions['zoomIn']));
206-
actions['zoomOut'].iconCls = 'geSprite geSprite-zoomout';
223+
224+
actions['zoomOut'].icon = zoomoutIcon;
225+
actions['zoomOut'].tooltip = 'Zoom Out (Ctrl-(Numpad)/Alt+Mousewheel)';
207226
this.toolbar.addItem(
208227
'zoomOut',
209228
new DrawIOToolbarButton(actions['zoomOut'])
210229
);
211230

212-
actions['undo'].iconCls = 'geSprite geSprite-undo';
231+
actions['undo'].icon = undoIcon;
232+
actions['fillColor'].tooltip = 'Undo (Ctrl+Z)';
213233
this.toolbar.addItem('undo', new DrawIOToolbarButton(actions['undo']));
214-
actions['redo'].iconCls = 'geSprite geSprite-redo';
234+
235+
actions['redo'].icon = redoIcon;
236+
actions['redo'].tooltip = 'Redo (Ctrl+Shift+Z)';
215237
this.toolbar.addItem('redo', new DrawIOToolbarButton(actions['redo']));
216238

217-
actions['delete'].iconCls = 'geSprite geSprite-delete';
239+
actions['delete'].icon = deleteIcon;
240+
actions['delete'].tooltip = 'Delete';
218241
this.toolbar.addItem('delete', new DrawIOToolbarButton(actions['delete']));
219242

220-
actions['toFront'].iconCls = 'geSprite geSprite-tofront';
243+
actions['toFront'].icon = toFrontIcon;
244+
actions['toFront'].tooltip = 'To Front (Ctrl+Shift+F)';
221245
this.toolbar.addItem(
222246
'toFront',
223247
new DrawIOToolbarButton(actions['toFront'])
224248
);
225-
actions['toBack'].iconCls = 'geSprite geSprite-toback';
249+
250+
actions['toBack'].icon = toBackIcon;
251+
actions['toBack'].tooltip = 'To Back (Ctrl+Shift+B)';
226252
this.toolbar.addItem('toBack', new DrawIOToolbarButton(actions['toBack']));
227253

228-
actions['fillColor'].iconCls = 'geSprite geSprite-fillcolor';
254+
actions['fillColor'].icon = fillColorIcon;
255+
actions['fillColor'].tooltip = 'Fill Color';
229256
this.toolbar.addItem(
230257
'fillColor',
231258
new DrawIOToolbarButton(actions['fillColor'])
232259
);
233-
actions['strokeColor'].iconCls = 'geSprite geSprite-strokecolor';
260+
261+
actions['strokeColor'].icon = strokeColorIcon;
262+
actions['strokeColor'].tooltip = 'Fill Stroke Color';
234263
this.toolbar.addItem(
235264
'strokeColor',
236265
new DrawIOToolbarButton(actions['strokeColor'])
237266
);
238-
actions['shadow'].iconCls = 'geSprite geSprite-shadow';
267+
268+
actions['shadow'].icon = shadowIcon;
269+
actions['shadow'].tooltip = 'Shadow';
239270
this.toolbar.addItem('shadow', new DrawIOToolbarButton(actions['shadow']));
240271
}
241272

src/icons.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { LabIcon } from '@jupyterlab/ui-components';
2+
3+
// icon svg import statements
4+
import formatPanel from '../style/icons/formatPanel.svg';
5+
import plus from '../style/icons/plus.svg';
6+
import zoomin from '../style/icons/zoomin.svg';
7+
import zoomout from '../style/icons/zoomout.svg';
8+
import del from '../style/icons/del.svg';
9+
import tofront from '../style/icons/tofront.svg';
10+
import toback from '../style/icons/toback.svg';
11+
import fillColor from '../style/icons/fillColor.svg';
12+
import strokeColor from '../style/icons/strokeColor.svg';
13+
import shadow from '../style/icons/shadow.svg';
14+
15+
export const formatPanelIcon = new LabIcon({
16+
name: 'drawio:icon/formatPanel',
17+
svgstr: formatPanel
18+
});
19+
20+
export const plusIcon = new LabIcon({
21+
name: 'drawio:icon/plus',
22+
svgstr: plus
23+
});
24+
25+
export const zoominIcon = new LabIcon({
26+
name: 'drawio:icon/zoomin',
27+
svgstr: zoomin
28+
});
29+
30+
export const zoomoutIcon = new LabIcon({
31+
name: 'drawio:icon/zoomout',
32+
svgstr: zoomout
33+
});
34+
35+
export const deleteIcon = new LabIcon({
36+
name: 'drawio:icon/delete',
37+
svgstr: del
38+
});
39+
40+
export const toFrontIcon = new LabIcon({
41+
name: 'drawio:icon/toFront',
42+
svgstr: tofront
43+
});
44+
45+
export const toBackIcon = new LabIcon({
46+
name: 'drawio:icon/toBack',
47+
svgstr: toback
48+
});
49+
50+
export const fillColorIcon = new LabIcon({
51+
name: 'drawio:icon/fillColor',
52+
svgstr: fillColor
53+
});
54+
55+
export const strokeColorIcon = new LabIcon({
56+
name: 'drawio:icon/strokeColor',
57+
svgstr: strokeColor
58+
});
59+
60+
export const shadowIcon = new LabIcon({
61+
name: 'drawio:icon/shadow',
62+
svgstr: shadow
63+
});

0 commit comments

Comments
 (0)