-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #8226: support sidebar bottom menu and add settings menu to the left
Signed-off-by: 二凢 <dingyu.wdy@alibaba-inc.com>
- Loading branch information
Showing
9 changed files
with
184 additions
and
7 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
77 changes: 77 additions & 0 deletions
77
packages/core/src/browser/shell/sidebar-bottom-menu-widget.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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2020 Alibaba Inc. and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
import { injectable, inject } from 'inversify'; | ||
import * as React from 'react'; | ||
import { ReactWidget } from '../widgets'; | ||
import { ContextMenuRenderer } from '../context-menu-renderer'; | ||
import { MenuPath } from '../../common/menu'; | ||
|
||
export const SidebarBottomMenuWidgetFactory = Symbol('SidebarBottomMenuWidgetFactory'); | ||
|
||
export interface SidebarBottomMenu { | ||
id: string; | ||
iconClass: string; | ||
title: string; | ||
menuPath: MenuPath; | ||
order: number; // smaller one place lower | ||
} | ||
|
||
/** | ||
* The menu widget placed on the bottom of the sidebar. | ||
*/ | ||
@injectable() | ||
export class SidebarBottomMenuWidget extends ReactWidget { | ||
protected readonly menus: SidebarBottomMenu[]; | ||
|
||
@inject(ContextMenuRenderer) | ||
protected readonly contextMenuRenderer: ContextMenuRenderer; | ||
|
||
constructor() { | ||
super(); | ||
this.menus = []; | ||
} | ||
|
||
addMenu(menu: SidebarBottomMenu): void { | ||
const exists = this.menus.find(m => m.id === menu.id); | ||
if (exists) { | ||
return; | ||
} | ||
this.menus.push(menu); | ||
this.update(); | ||
} | ||
|
||
protected onClick(e: React.MouseEvent<HTMLElement, MouseEvent>, menuPath: MenuPath): void { | ||
this.contextMenuRenderer.render({ | ||
menuPath, | ||
anchor: { | ||
x: e.clientX, | ||
y: e.clientY, | ||
} | ||
}); | ||
} | ||
|
||
protected render(): React.ReactNode { | ||
return <React.Fragment> | ||
{this.menus.sort((a, b) => a.order - b.order).map(menu => <i | ||
key={menu.id} | ||
className={menu.iconClass} | ||
title={menu.title} | ||
onClick={e => this.onClick(e, menu.menuPath)} | ||
/>)} | ||
</React.Fragment>; | ||
} | ||
} |
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