Big refactoring with properties + Implement Property
This commit is contained in:
parent
43fb019e05
commit
d2492520b4
5 changed files with 133 additions and 28 deletions
|
@ -1,16 +1,12 @@
|
|||
import * as React from 'react';
|
||||
import Properties from '../../../Interfaces/Properties';
|
||||
|
||||
interface IContainerProps {
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
parent: Container | null,
|
||||
id: string,
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
children: Container[],
|
||||
x: number,
|
||||
y: number,
|
||||
width: number,
|
||||
height: number,
|
||||
style?: React.CSSProperties,
|
||||
properties: Properties,
|
||||
userData?: Record<string, string | number>
|
||||
}
|
||||
|
||||
|
@ -18,17 +14,25 @@ export class Container extends React.Component<IContainerProps> {
|
|||
componentWillUnMount() {
|
||||
}
|
||||
|
||||
public GetProperties(): Properties {
|
||||
const properties : Properties = {
|
||||
...this.props.properties
|
||||
};
|
||||
return properties;
|
||||
}
|
||||
|
||||
public render(): React.ReactNode {
|
||||
const containersElements = this.props.children.map(child => child.render());
|
||||
const style = Object.assign({}, this.props.properties);
|
||||
style.x = 0;
|
||||
style.y = 0;
|
||||
return (
|
||||
<g
|
||||
transform={`translate(${this.props.x}, ${this.props.y})`}
|
||||
key={`container-${this.props.id}`}
|
||||
transform={`translate(${this.props.properties.x}, ${this.props.properties.y})`}
|
||||
key={`container-${this.props.properties.id}`}
|
||||
>
|
||||
<rect
|
||||
width={this.props.width}
|
||||
height={this.props.height}
|
||||
style={this.props.style}
|
||||
style={style}
|
||||
>
|
||||
</rect>
|
||||
{ containersElements }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue