Container: Support for children
This commit is contained in:
parent
5f91128c85
commit
c60a8651db
3 changed files with 26 additions and 10 deletions
|
@ -1,6 +1,8 @@
|
|||
import * as React from 'react';
|
||||
|
||||
interface IContainerProps {
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
children: Container[],
|
||||
x: number,
|
||||
y: number,
|
||||
width: number,
|
||||
|
@ -9,15 +11,21 @@ interface IContainerProps {
|
|||
}
|
||||
|
||||
export class Container extends React.Component<IContainerProps> {
|
||||
public render() {
|
||||
public render(): React.ReactNode {
|
||||
const containersElements = this.props.children.map(child => child.render());
|
||||
|
||||
return (
|
||||
<rect
|
||||
x={this.props.x}
|
||||
y={this.props.y}
|
||||
width={this.props.width}
|
||||
height={this.props.height}
|
||||
style={this.props.style}
|
||||
/>
|
||||
<g>
|
||||
<rect
|
||||
x={this.props.x}
|
||||
y={this.props.y}
|
||||
width={this.props.width}
|
||||
height={this.props.height}
|
||||
style={this.props.style}
|
||||
>
|
||||
</rect>
|
||||
{ containersElements }
|
||||
</g>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue