From d959945da7218d4623ed531be8900686f3fe2145 Mon Sep 17 00:00:00 2001 From: Siklos Date: Thu, 4 Aug 2022 00:12:06 +0200 Subject: [PATCH] Dev docs Container --- src/Components/SVG/Elements/Container.tsx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Components/SVG/Elements/Container.tsx b/src/Components/SVG/Elements/Container.tsx index f36553f..1094588 100644 --- a/src/Components/SVG/Elements/Container.tsx +++ b/src/Components/SVG/Elements/Container.tsx @@ -14,6 +14,10 @@ interface IContainerProps { const GAP = 50; export class Container extends React.Component { + /** + * Returns A copy of the properties of the Container + * @returns A copy of the properties of the Container + */ public GetProperties(): Properties { const properties : Properties = { ...this.props.properties @@ -21,7 +25,10 @@ export class Container extends React.Component { return properties; } - public * MakeIterator() { + /** + * Returns a Generator iterating of over the children depth-first + */ + public * MakeIterator(): Generator { const queue: Container[] = [this]; const visited = new Set(queue); while (queue.length > 0) { @@ -40,6 +47,10 @@ export class Container extends React.Component { } } + /** + * Returns the depth of the container + * @returns The depth of the container + */ public getDepth() { let depth = 0; @@ -52,6 +63,10 @@ export class Container extends React.Component { return depth; } + /** + * Returns the absolute position by iterating to the parent + * @returns The absolute position of the container + */ public getAbsolutePosition(): [number, number] { let x = Number(this.props.properties.x); let y = Number(this.props.properties.y); @@ -64,6 +79,10 @@ export class Container extends React.Component { return [x, y]; } + /** + * Render the container + * @returns Render the container + */ public render(): React.ReactNode { const containersElements = this.props.children.map(child => child.render()); const xText = Number(this.props.properties.width) / 2;