Add text to container
This commit is contained in:
parent
c5171caaaa
commit
5f312b9ff7
1 changed files with 12 additions and 0 deletions
|
@ -57,12 +57,17 @@ export class Container extends React.Component<IContainerProps> {
|
||||||
|
|
||||||
public render(): React.ReactNode {
|
public render(): React.ReactNode {
|
||||||
const containersElements = this.props.children.map(child => child.render());
|
const containersElements = this.props.children.map(child => child.render());
|
||||||
|
const xText = (this.props.properties.x * 2 + Number(this.props.properties.width)) / 2;
|
||||||
|
const yText = (this.props.properties.y * 2 + Number(this.props.properties.height)) / 2;
|
||||||
|
|
||||||
|
// g style
|
||||||
const defaultStyle = {
|
const defaultStyle = {
|
||||||
transitionProperty: 'all',
|
transitionProperty: 'all',
|
||||||
transitionTimingFunction: 'cubic-bezier(0.4, 0, 0.2, 1)',
|
transitionTimingFunction: 'cubic-bezier(0.4, 0, 0.2, 1)',
|
||||||
transitionDuration: '150ms'
|
transitionDuration: '150ms'
|
||||||
} as React.CSSProperties;
|
} as React.CSSProperties;
|
||||||
|
|
||||||
|
// Rect style
|
||||||
const style = Object.assign(
|
const style = Object.assign(
|
||||||
JSON.parse(JSON.stringify(defaultStyle)),
|
JSON.parse(JSON.stringify(defaultStyle)),
|
||||||
this.props.properties
|
this.props.properties
|
||||||
|
@ -72,6 +77,7 @@ export class Container extends React.Component<IContainerProps> {
|
||||||
delete style.height;
|
delete style.height;
|
||||||
delete style.width;
|
delete style.width;
|
||||||
|
|
||||||
|
// Dimension props
|
||||||
const id = `dim-${this.props.properties.id}`;
|
const id = `dim-${this.props.properties.id}`;
|
||||||
const xStart: number = 0;
|
const xStart: number = 0;
|
||||||
const xEnd = Number(this.props.properties.width);
|
const xEnd = Number(this.props.properties.width);
|
||||||
|
@ -99,6 +105,12 @@ export class Container extends React.Component<IContainerProps> {
|
||||||
style={style}
|
style={style}
|
||||||
>
|
>
|
||||||
</rect>
|
</rect>
|
||||||
|
<text
|
||||||
|
x={xText}
|
||||||
|
y={yText}
|
||||||
|
>
|
||||||
|
{this.props.properties.id}
|
||||||
|
</text>
|
||||||
{ containersElements }
|
{ containersElements }
|
||||||
</g>
|
</g>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue