chore(project): 添加项目配置文件和忽略规则
- 添加 Babel 配置文件支持 ES6+ 语法转换 - 添加 ESLint 忽略规则和配置文件 - 添加 Git 忽略规则文件 - 添加 Travis CI 配置文件 - 添加 1.4.2 版本变更日志文件 - 添加 Helm 图表辅助模板文件 - 添加 Helm 忽略规则文件
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import React from 'react';
|
||||
import { pick } from '@utils';
|
||||
|
||||
class Panel extends React.Component {
|
||||
static create = function (type) {
|
||||
return class TypedPanel extends Panel {
|
||||
constructor(props) {
|
||||
super(props, type);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
constructor(props, type) {
|
||||
super(props);
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
render() {
|
||||
const { status, children } = this.props;
|
||||
const { type } = this;
|
||||
|
||||
if (`${type}-selected` !== status) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div {...pick(this.props, ['style', 'className'])}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Panel;
|
||||
@@ -0,0 +1,58 @@
|
||||
import React from 'react';
|
||||
import { pick } from '@utils';
|
||||
import { STATUS_CANVAS_SELECTED } from '@common/constants';
|
||||
import withGGEditorContext from '@common/context/GGEditorContext/withGGEditorContext';
|
||||
import Panel from './Panel';
|
||||
|
||||
class DetailPanel extends React.Component {
|
||||
state = {
|
||||
status: '',
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.bindEvent();
|
||||
}
|
||||
|
||||
bindEvent() {
|
||||
const { onAfterAddPage } = this.props;
|
||||
|
||||
onAfterAddPage(({ page }) => {
|
||||
this.setState({
|
||||
status: STATUS_CANVAS_SELECTED,
|
||||
});
|
||||
|
||||
page.on('statuschange', ({ status }) => {
|
||||
this.setState({ status });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { children } = this.props;
|
||||
const { status } = this.state;
|
||||
|
||||
if (!status) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div {...pick(this.props, ['style', 'className'])}>
|
||||
{
|
||||
React.Children.toArray(children).map(child => React.cloneElement(child, {
|
||||
status,
|
||||
}))
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const NodePanel = Panel.create('node');
|
||||
export const EdgePanel = Panel.create('edge');
|
||||
export const GroupPanel = Panel.create('group');
|
||||
export const MultiPanel = Panel.create('multi');
|
||||
export const CanvasPanel = Panel.create('canvas');
|
||||
|
||||
export default withGGEditorContext(DetailPanel);
|
||||
Reference in New Issue
Block a user