Skip to content

Commit

Permalink
feat(ContextMenu): The menu container can toggle display status based…
Browse files Browse the repository at this point in the history
… on the page status
  • Loading branch information
gaoli committed Aug 31, 2018
1 parent 046a7a7 commit 8c294c9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/components/ContextMenu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { pick } from '@utils';
import Editor from '@antv/g6-editor';
import { CONTEXT_MENU_CONTAINER } from '@common/constants';
import BaseComponent from '@components/Base';
import Menu from './menu';

class ContextMenu extends BaseComponent {
contextMenu = null;
Expand Down Expand Up @@ -34,4 +35,10 @@ class ContextMenu extends BaseComponent {
}
}

export const NodeMenu = Menu.create('node');
export const EdgeMenu = Menu.create('edge');
export const GroupMenu = Menu.create('group');
export const MultiMenu = Menu.create('multi');
export const CanvasMenu = Menu.create('canvas');

export default ContextMenu;
31 changes: 31 additions & 0 deletions src/components/ContextMenu/menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import BaseComponent from '@components/Base';

class Menu extends BaseComponent {
static create = function (type) {
return class TypedMenu extends Menu {
constructor(props) {
super(props, type);
}
};
}

constructor(props, type) {
super(props);

this.type = type;
}

render() {
const { children } = this.props;
const { type } = this;

return (
<div className="menu" data-status={`${type}-selected`}>
{children}
</div>
);
}
}

export default Menu;
13 changes: 12 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ import Register, {
} from '@components/Register';
import Command from '@components/Command';
import Minimap from '@components/Minimap';
import ContextMenu from '@components/ContextMenu';
import ContextMenu, {
NodeMenu,
EdgeMenu,
GroupMenu,
MultiMenu,
CanvasMenu,
} from '@components/ContextMenu';
import Toolbar from '@components/Toolbar';
import ItemPanel, { Item } from '@components/ItemPanel';
import DetailPanel, {
Expand All @@ -35,6 +41,11 @@ export {
Command,
Minimap,
ContextMenu,
NodeMenu,
EdgeMenu,
GroupMenu,
MultiMenu,
CanvasMenu,
Toolbar,
Item,
ItemPanel,
Expand Down

0 comments on commit 8c294c9

Please sign in to comment.