topArea 增加 prop itemClassName

This commit is contained in:
mario.gk 2020-05-05 18:06:25 +08:00
parent 7868ff210a
commit 0eaac97eed
3 changed files with 17 additions and 11 deletions

View File

@ -4,23 +4,23 @@ import { observer } from '@ali/lowcode-editor-core';
import Area from '../area'; import Area from '../area';
@observer @observer
export default class TopArea extends Component<{ area: Area }> { export default class TopArea extends Component<{ area: Area, itemClassName?: string }> {
render() { render() {
const { area } = this.props; const { area, itemClassName } = this.props;
return ( return (
<div className={classNames("lc-top-area", { <div className={classNames("lc-top-area", {
'lc-area-visible': area.visible 'lc-area-visible': area.visible
})}> })}>
<Contents area={area} /> <Contents area={area} itemClassName={itemClassName} />
</div> </div>
); );
} }
} }
@observer @observer
class Contents extends Component<{ area: Area }> { class Contents extends Component<{ area: Area, itemClassName?: string }> {
render() { render() {
const { area } = this.props; const { area, itemClassName } = this.props;
const left: any[] = []; const left: any[] = [];
const center: any[] = []; const center: any[] = [];
const right: any[] = []; const right: any[] = [];
@ -29,12 +29,17 @@ class Contents extends Component<{ area: Area }> {
const index2 = b.config?.index || 0; const index2 = b.config?.index || 0;
return index1 === index2 ? 0 : (index1 > index2 ? 1 : -1); return index1 === index2 ? 0 : (index1 > index2 ? 1 : -1);
}).forEach(item => { }).forEach(item => {
const content = (
<div className={itemClassName || ''}>
{item.content}
</div>
);
if (item.align === 'center') { if (item.align === 'center') {
center.push(item.content); center.push(content);
} else if (item.align === 'left') { } else if (item.align === 'left') {
left.push(item.content); left.push(content);
} else { } else {
right.push(item.content); right.push(content);
} }
}); });
return ( return (

View File

@ -13,16 +13,16 @@ import RightArea from './right-area';
import './workbench.less'; import './workbench.less';
@observer @observer
export class Workbench extends Component<{ skeleton: Skeleton, className?: string }> { export class Workbench extends Component<{ skeleton: Skeleton, className?: string, topAreaItemClassName?: string }> {
shouldComponentUpdate() { shouldComponentUpdate() {
return false; return false;
} }
render() { render() {
const { skeleton, className } = this.props; const { skeleton, className, topAreaItemClassName } = this.props;
return ( return (
<div className={classNames('lc-workbench', className)}> <div className={classNames('lc-workbench', className)}>
<TopArea area={skeleton.topArea} /> <TopArea area={skeleton.topArea} itemClassName={topAreaItemClassName} />
<div className="lc-workbench-body"> <div className="lc-workbench-body">
<LeftArea area={skeleton.leftArea} /> <LeftArea area={skeleton.leftArea} />
<LeftFloatPane area={skeleton.leftFloatArea} /> <LeftFloatPane area={skeleton.leftFloatArea} />

View File

@ -44,6 +44,7 @@ function init(container?: Element) {
createElement(Workbench, { createElement(Workbench, {
skeleton, skeleton,
className: 'engine-main', className: 'engine-main',
topAreaItemClassName: 'engine-actionitem',
}), }),
container, container,
); );