Skip to content

Commit

Permalink
feat: add menuBarProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
wewoor committed Oct 22, 2020
1 parent d5708b5 commit 77f5fcd
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/provider/menuBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as React from 'react';
import { IMenuBar, MenuBarEvent } from 'mo/core/workbench/menuBar';
import { BaseProvider } from './base';
import { moleculeService } from 'mo/main';
import { cloneInstance } from 'mo/common/utils';

const initialState = cloneInstance(moleculeService.menuBar);

export const MenuBarCtx = React.createContext<IMenuBar>(initialState);

export class MenuBarProvider extends BaseProvider<any, IMenuBar> {
state: IMenuBar;
constructor(props) {
super(props);
this.register([MenuBarEvent.DataChanged]);
this.state = initialState;
}

public render() {
return (
<MenuBarCtx.Provider
value={this.state}>
{ this.props.children }
</MenuBarCtx.Provider>
);
}
}
26 changes: 26 additions & 0 deletions src/workbench/menuBar/menuBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'mo/workbench/menuBar/style.scss';
import * as React from 'react';
import { prefixClaName } from 'mo/common/className';
import { IMenuBar } from 'mo/core/workbench/menuBar';

export interface IMenuBarProps {
// menuBar: IMenuBar;
}

function MenuBar(props: IMenuBar) {
// const { menuBar } = props;
const menuBar = props;
console.log('menubar:', props);
const click = function(e) {
menuBar.onClick(e, {
name: 'test',
});
};
return (
<div className={prefixClaName('menuBar')}>
<a className="menu-action codicon codicon-menu" onClick={click}></a>
</div>
);
};

export default MenuBar;

0 comments on commit 77f5fcd

Please sign in to comment.