Implement container adding
This commit is contained in:
parent
70963ce41f
commit
6c029ac13c
2 changed files with 32 additions and 10 deletions
32
src/App.tsx
32
src/App.tsx
|
@ -4,6 +4,7 @@ import Sidebar from './Components/Sidebar/Sidebar';
|
||||||
import { SVGSidebar } from './Components/SVGSidebar/SVGSidebar';
|
import { SVGSidebar } from './Components/SVGSidebar/SVGSidebar';
|
||||||
import { AvailableContainer } from './Interfaces/AvailableContainer';
|
import { AvailableContainer } from './Interfaces/AvailableContainer';
|
||||||
import { Configuration } from './Interfaces/Configuration';
|
import { Configuration } from './Interfaces/Configuration';
|
||||||
|
import { Container } from './SVG/Elements/Container';
|
||||||
import { MainContainer } from './SVG/Elements/MainContainer';
|
import { MainContainer } from './SVG/Elements/MainContainer';
|
||||||
import { SVG } from './SVG/SVG';
|
import { SVG } from './SVG/SVG';
|
||||||
|
|
||||||
|
@ -62,14 +63,29 @@ class App extends React.Component<IAppProps> {
|
||||||
} as IAppState);
|
} as IAppState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddContainer(type: string) {
|
public AddContainer(type: string): void {
|
||||||
// const container = new Container({
|
if (this.state.MainContainer === null ||
|
||||||
// x: 0,
|
this.state.MainContainer === undefined) {
|
||||||
// y: 0,
|
return;
|
||||||
// width: 300,
|
}
|
||||||
// height: this.state.configuration.MainContainer.Height,
|
|
||||||
// children: []
|
const container = new Container({
|
||||||
// });
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
width: 300,
|
||||||
|
height: this.state.configuration.MainContainer.Height,
|
||||||
|
children: []
|
||||||
|
});
|
||||||
|
|
||||||
|
const newMainContainer = new MainContainer({
|
||||||
|
width: this.state.MainContainer.props.width,
|
||||||
|
height: this.state.MainContainer.props.height,
|
||||||
|
children: this.state.MainContainer.props.children.concat([container])
|
||||||
|
});
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
MainContainer: newMainContainer
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -11,12 +11,18 @@ interface IContainerProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Container extends React.Component<IContainerProps> {
|
export class Container extends React.Component<IContainerProps> {
|
||||||
public render(): React.ReactNode {
|
public static ContainerCount = 0;
|
||||||
const containersElements = this.props.children.map(child => child.render());
|
|
||||||
|
|
||||||
|
componentWillUnMount() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public render(): React.ReactNode {
|
||||||
|
Container.ContainerCount++;
|
||||||
|
const containersElements = this.props.children.map(child => child.render());
|
||||||
return (
|
return (
|
||||||
<g
|
<g
|
||||||
transform={`translate(${this.props.x}, ${this.props.y})`}
|
transform={`translate(${this.props.x}, ${this.props.y})`}
|
||||||
|
key={`container-${Container.ContainerCount}`}
|
||||||
>
|
>
|
||||||
<rect
|
<rect
|
||||||
width={this.props.width}
|
width={this.props.width}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue