From be0049658125afd0626ea42dd47c0d14cc82ec92 Mon Sep 17 00:00:00 2001 From: Siklos Date: Tue, 2 Aug 2022 23:36:31 +0200 Subject: [PATCH] Moved static GetDepth to getDepth class method --- .../ElementsSidebar/ElementsSidebar.tsx | 2 +- src/Components/SVG/Elements/Container.tsx | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Components/ElementsSidebar/ElementsSidebar.tsx b/src/Components/ElementsSidebar/ElementsSidebar.tsx index eefa336..afec90a 100644 --- a/src/Components/ElementsSidebar/ElementsSidebar.tsx +++ b/src/Components/ElementsSidebar/ElementsSidebar.tsx @@ -29,7 +29,7 @@ export class ElementsSidebar extends React.Component { const containerRows: React.ReactNode[] = []; this.iterateChilds((container: Container) => { - const depth: number = Container.getDepth(container); + const depth: number = container.getDepth(); const key = container.props.properties.id.toString(); const text = '|\t'.repeat(depth) + key; const selectedClass: string = this.props.SelectedContainer !== null && diff --git a/src/Components/SVG/Elements/Container.tsx b/src/Components/SVG/Elements/Container.tsx index 67d3d32..a3fd191 100644 --- a/src/Components/SVG/Elements/Container.tsx +++ b/src/Components/SVG/Elements/Container.tsx @@ -40,6 +40,18 @@ export class Container extends React.Component { } } + public getDepth() { + let depth = 0; + + let current: Container | null = this.props.parent; + while (current != null) { + depth++; + current = current.props.parent; + } + + return depth; + } + public render(): React.ReactNode { const containersElements = this.props.children.map(child => child.render()); const defaultStyle = { @@ -69,16 +81,4 @@ export class Container extends React.Component { ); } - - public static getDepth(container: Container): number { - let depth = 0; - - let current: Container | null = container.props.parent; - while (current != null) { - depth++; - current = current.props.parent; - } - - return depth; - } }