-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add top menu * Add launcher * Filter unused extensions * Add items to menu * Update visuals * Update dependencies * Relax UI test * Update packages/jupytercad-app/src/app/plugins/launcher/index.ts Co-authored-by: martinRenou <[email protected]> * Update dark theme --------- Co-authored-by: martinRenou <[email protected]>
- Loading branch information
1 parent
eeee46e
commit 2fe750a
Showing
21 changed files
with
1,069 additions
and
875 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { | ||
ILabShell, | ||
JupyterFrontEnd, | ||
JupyterFrontEndPlugin | ||
} from '@jupyterlab/application'; | ||
|
||
const launcherPlugin: JupyterFrontEndPlugin<void> = { | ||
id: '@jupyterlab/-custom-launcher-extension', | ||
description: 'Customize the default launcher.', | ||
requires: [ILabShell], | ||
autoStart: true, | ||
activate: (app: JupyterFrontEnd, labShell: ILabShell): void => { | ||
labShell.layoutModified.connect(() => { | ||
const els = document.getElementsByClassName('jp-Launcher-sectionTitle'); | ||
const length = els.length; | ||
for (let idx = 0; idx < length; idx++) { | ||
const element = els.item(idx); | ||
if (element) { | ||
element.innerHTML = 'Create New Project'; | ||
} | ||
} | ||
}); | ||
} | ||
}; | ||
export default launcherPlugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
182 changes: 182 additions & 0 deletions
182
packages/jupytercad-app/src/app/plugins/mainmenu/menuWidget.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
import { RankedMenu, MenuSvg, homeIcon } from '@jupyterlab/ui-components'; | ||
import { CommandRegistry } from '@lumino/commands'; | ||
import { MenuBar } from '@lumino/widgets'; | ||
import { CommandIDs } from '@jupytercad/jupytercad-extension/lib/commands'; | ||
import { IThemeManager } from '@jupyterlab/apputils'; | ||
export class MainMenu extends MenuBar { | ||
constructor(options: { | ||
commands: CommandRegistry; | ||
themeManager: IThemeManager; | ||
}) { | ||
super({ forceItemsPosition: { forceX: false, forceY: true } }); | ||
this._commands = options.commands; | ||
this._themeManager = options.themeManager; | ||
this.addClass('jc-MainMenu'); | ||
this._createFileMenu(); | ||
this._createEditMenu(); | ||
this._createViewMenu(); | ||
this._createHelpMenu(); | ||
} | ||
|
||
private _createHelpMenu(): void { | ||
this._commands.addCommand('jupytercad:help-menu:documentation', { | ||
label: 'Documentation', | ||
execute: () => { | ||
window.open('https://github.com/QuantStack/jupytercad', '_blank'); | ||
}, | ||
icon: homeIcon | ||
}); | ||
const helpMenu = new MenuSvg({ | ||
commands: this._commands | ||
}); | ||
helpMenu.title.label = 'Help'; | ||
helpMenu.title.mnemonic = 0; | ||
helpMenu.addClass('jc-MenuBar-MenuItem'); | ||
this.addMenu(helpMenu); | ||
helpMenu.addItem({ | ||
type: 'command', | ||
command: 'jupytercad:help-menu:documentation' | ||
}); | ||
} | ||
private _createFileMenu(): void { | ||
const menu = new MenuSvg({ | ||
commands: this._commands | ||
}); | ||
menu.title.label = 'File'; | ||
menu.title.mnemonic = 0; | ||
menu.addClass('jc-MenuBar-FileMenu'); | ||
menu.addClass('jc-MenuBar-MenuItem'); | ||
this.addMenu(menu); | ||
menu.addItem({ | ||
type: 'command', | ||
command: 'jupytercad:create-new-jcad-file' | ||
}); | ||
menu.addItem({ | ||
type: 'command', | ||
command: 'jupytercad:open-file' | ||
}); | ||
} | ||
private _createEditMenu(): void { | ||
const menu = new MenuSvg({ | ||
commands: this._commands | ||
}); | ||
menu.title.label = 'Edit'; | ||
menu.title.mnemonic = 0; | ||
menu.addClass('jc-MenuBar-MenuItem'); | ||
this.addMenu(menu); | ||
|
||
const shapeMenu = new RankedMenu({ | ||
commands: this._commands, | ||
rank: 200 | ||
}); | ||
shapeMenu.title.label = 'Shape'; | ||
shapeMenu.addClass('jc-MenuBar-MenuItem'); | ||
shapeMenu.addItem({ | ||
type: 'command', | ||
command: CommandIDs.newBox | ||
}); | ||
shapeMenu.addItem({ | ||
type: 'command', | ||
command: CommandIDs.newCone | ||
}); | ||
shapeMenu.addItem({ | ||
type: 'command', | ||
command: CommandIDs.newCylinder | ||
}); | ||
shapeMenu.addItem({ | ||
type: 'command', | ||
command: CommandIDs.newSketch | ||
}); | ||
shapeMenu.addItem({ | ||
type: 'command', | ||
command: CommandIDs.newSphere | ||
}); | ||
shapeMenu.addItem({ | ||
type: 'command', | ||
command: CommandIDs.newTorus | ||
}); | ||
shapeMenu.addItem({ | ||
type: 'command', | ||
command: CommandIDs.newCone | ||
}); | ||
|
||
menu.addItem({ | ||
type: 'submenu', | ||
submenu: shapeMenu | ||
}); | ||
|
||
const operatorMenu = new RankedMenu({ | ||
commands: this._commands, | ||
rank: 200 | ||
}); | ||
operatorMenu.title.label = 'Operators'; | ||
operatorMenu.addClass('jc-MenuBar-MenuItem'); | ||
operatorMenu.addItem({ | ||
type: 'command', | ||
command: CommandIDs.cut | ||
}); | ||
operatorMenu.addItem({ | ||
type: 'command', | ||
command: CommandIDs.extrusion | ||
}); | ||
operatorMenu.addItem({ | ||
type: 'command', | ||
command: CommandIDs.intersection | ||
}); | ||
operatorMenu.addItem({ | ||
type: 'command', | ||
command: CommandIDs.union | ||
}); | ||
menu.addItem({ | ||
type: 'submenu', | ||
submenu: operatorMenu | ||
}); | ||
|
||
menu.addItem({ | ||
type: 'command', | ||
command: CommandIDs.undo | ||
}); | ||
menu.addItem({ | ||
type: 'command', | ||
command: CommandIDs.redo | ||
}); | ||
} | ||
|
||
private _createViewMenu(): void { | ||
const menu = new MenuSvg({ | ||
commands: this._commands | ||
}); | ||
menu.title.label = 'View'; | ||
menu.title.mnemonic = 0; | ||
menu.addClass('jc-MenuBar-ViewMenu'); | ||
menu.addClass('jc-MenuBar-MenuItem'); | ||
this.addMenu(menu); | ||
menu.addItem({ | ||
type: 'command', | ||
command: CommandIDs.updateExplodedView | ||
}); | ||
menu.addItem({ | ||
type: 'command', | ||
command: CommandIDs.updateAxes | ||
}); | ||
|
||
const themeMenu = new RankedMenu({ | ||
commands: this._commands, | ||
rank: 200 | ||
}); | ||
themeMenu.title.label = 'Theme'; | ||
themeMenu.addClass('jc-MenuBar-MenuItem'); | ||
this._themeManager.themes.forEach((theme, index) => { | ||
themeMenu.insertItem(index, { | ||
command: 'apputils:change-theme', | ||
args: { theme } | ||
}); | ||
}); | ||
menu.addItem({ | ||
type: 'submenu', | ||
submenu: themeMenu | ||
}); | ||
} | ||
private _commands: CommandRegistry; | ||
private _themeManager: IThemeManager; | ||
} |
4 changes: 2 additions & 2 deletions
4
...d-app/src/app/plugins/mainmenu/widget.tsx → .../src/app/plugins/mainmenu/titleWidget.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { Widget } from '@lumino/widgets'; | ||
|
||
export class MainMenu extends Widget { | ||
export class AppTitle extends Widget { | ||
constructor() { | ||
super(); | ||
this.addClass('jcad-MainMenu'); | ||
this.addClass('jc-MainMenu-AppTitle'); | ||
this.node.innerHTML = 'JupyterCAD'; | ||
} | ||
} |
Oops, something went wrong.