File tree 2 files changed +53
-0
lines changed
2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ import * as React from 'react' ;
2
+ import { IMenuBar , MenuBarEvent } from 'mo/core/workbench/menuBar' ;
3
+ import { BaseProvider } from './base' ;
4
+ import { moleculeService } from 'mo/main' ;
5
+ import { cloneInstance } from 'mo/common/utils' ;
6
+
7
+ const initialState = cloneInstance ( moleculeService . menuBar ) ;
8
+
9
+ export const MenuBarCtx = React . createContext < IMenuBar > ( initialState ) ;
10
+
11
+ export class MenuBarProvider extends BaseProvider < any , IMenuBar > {
12
+ state : IMenuBar ;
13
+ constructor ( props ) {
14
+ super ( props ) ;
15
+ this . register ( [ MenuBarEvent . DataChanged ] ) ;
16
+ this . state = initialState ;
17
+ }
18
+
19
+ public render ( ) {
20
+ return (
21
+ < MenuBarCtx . Provider
22
+ value = { this . state } >
23
+ { this . props . children }
24
+ </ MenuBarCtx . Provider >
25
+ ) ;
26
+ }
27
+ }
Original file line number Diff line number Diff line change
1
+ import 'mo/workbench/menuBar/style.scss' ;
2
+ import * as React from 'react' ;
3
+ import { prefixClaName } from 'mo/common/className' ;
4
+ import { IMenuBar } from 'mo/core/workbench/menuBar' ;
5
+
6
+ export interface IMenuBarProps {
7
+ // menuBar: IMenuBar;
8
+ }
9
+
10
+ function MenuBar ( props : IMenuBar ) {
11
+ // const { menuBar } = props;
12
+ const menuBar = props ;
13
+ console . log ( 'menubar:' , props ) ;
14
+ const click = function ( e ) {
15
+ menuBar . onClick ( e , {
16
+ name : 'test' ,
17
+ } ) ;
18
+ } ;
19
+ return (
20
+ < div className = { prefixClaName ( 'menuBar' ) } >
21
+ < a className = "menu-action codicon codicon-menu" onClick = { click } > </ a >
22
+ </ div >
23
+ ) ;
24
+ } ;
25
+
26
+ export default MenuBar ;
You can’t perform that action at this time.
0 commit comments