Separated the model and the Container entity in order to remove any mutation operation
This commit is contained in:
parent
964d9a0e57
commit
e2a099457c
7 changed files with 206 additions and 178 deletions
|
@ -1,25 +1,25 @@
|
|||
import * as React from 'react';
|
||||
import { Container } from './Container';
|
||||
import { ContainerModel, getDepth, MakeIterator } from './ContainerModel';
|
||||
import { Dimension } from './Dimension';
|
||||
|
||||
interface IDimensionLayerProps {
|
||||
isHidden: boolean,
|
||||
roots: Container | Container[] | null,
|
||||
roots: ContainerModel | ContainerModel[] | null,
|
||||
}
|
||||
|
||||
const GAP: number = 50;
|
||||
|
||||
const getDimensionsNodes = (root: Container): React.ReactNode[] => {
|
||||
const it = root.MakeIterator();
|
||||
const getDimensionsNodes = (root: ContainerModel): React.ReactNode[] => {
|
||||
const it = MakeIterator(root);
|
||||
const dimensions: React.ReactNode[] = [];
|
||||
for (const container of it) {
|
||||
// WARN: this might be dangerous later when using other units/rules
|
||||
const width = Number(container.props.properties.width);
|
||||
const width = Number(container.properties.width);
|
||||
|
||||
const id = `dim-${container.props.properties.id}`;
|
||||
const xStart: number = container.props.properties.x;
|
||||
const id = `dim-${container.properties.id}`;
|
||||
const xStart: number = container.properties.x;
|
||||
const xEnd = xStart + width;
|
||||
const y = -(GAP * (container.getDepth() + 1));
|
||||
const y = -(GAP * (getDepth(container) + 1));
|
||||
const strokeWidth = 1;
|
||||
const text = width.toString();
|
||||
const dimension = new Dimension({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue