import * as React from 'react'; import { IContainerModel } from '../../../Interfaces/ContainerModel'; import { getDepth } from '../../../utils/itertools'; import { Dimension } from './Dimension'; export interface IContainerProps { model: IContainerModel } const GAP = 50; export class Container extends React.PureComponent { /** * Render the container * @returns Render the container */ public render(): React.ReactNode { const containersElements = this.props.model.children.map(child => ); const xText = Number(this.props.model.properties.width) / 2; const yText = Number(this.props.model.properties.height) / 2; const transform = `translate(${Number(this.props.model.properties.x)}, ${Number(this.props.model.properties.y)})`; // g style const defaultStyle: React.CSSProperties = { transitionProperty: 'all', transitionTimingFunction: 'cubic-bezier(0.4, 0, 0.2, 1)', transitionDuration: '150ms' }; // Rect style const style = Object.assign( JSON.parse(JSON.stringify(defaultStyle)), this.props.model.properties ); style.x = 0; style.y = 0; delete style.height; delete style.width; // Dimension props const id = `dim-${this.props.model.properties.id}`; const xStart: number = 0; const xEnd = Number(this.props.model.properties.width); const y = -(GAP * (getDepth(this.props.model) + 1)); const strokeWidth = 1; const text = (this.props.model.properties.width ?? 0).toString(); return ( {this.props.model.properties.id} { containersElements } ); } }