From bb269c81605e85aa978e941d60d65525cedc16aa Mon Sep 17 00:00:00 2001 From: amaliejvik Date: Wed, 3 Jul 2024 16:20:53 +0200 Subject: [PATCH] Formatting fix --- src/Components/LegendBox.ts | 22 ++++++++++------------ src/Components/Plot.ts | 2 +- src/Components/Point.ts | 2 +- src/Core.ts | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/Components/LegendBox.ts b/src/Components/LegendBox.ts index c6836b5..66ef27a 100644 --- a/src/Components/LegendBox.ts +++ b/src/Components/LegendBox.ts @@ -1,17 +1,15 @@ -import Core from "../Core"; import renderToString from "katex"; import Plot from "./Plot"; -import { Component, GuiComponent } from "./interfaces"; -import "style.css"; import Point from "./Point"; import State from "./State"; +import { Component, GuiComponent } from "./interfaces"; class LegendBox implements GuiComponent { - elements: (Component | String | State)[]; + elements: (Component | string | State)[]; states: { [key: string]: State }; htmlElement: HTMLElement; - constructor(elements?: (Component | String | State)[]) { + constructor(elements?: (Component | string | State)[]) { this.elements = elements || []; this.states = {}; this.htmlElement = this.createLegendBoxWrapper(); @@ -84,7 +82,7 @@ class LegendBox implements GuiComponent { this.elements.length === 0 ? "none" : "block"; } - private processElement(element: Component | String | State) { + private processElement(element: Component | string | State) { const functionContainer = document.createElement("div"); functionContainer.className = "function-container"; const icon = this.createIcon(element); @@ -105,7 +103,7 @@ class LegendBox implements GuiComponent { this.htmlElement.appendChild(functionContainer); } - private createIcon(element: Component | String | State) { + private createIcon(element: Component | string | State) { const icon = document.createElement("span"); icon.className = this.getIconClass(element); if (icon.className === "triangle-icon") { @@ -116,7 +114,7 @@ class LegendBox implements GuiComponent { return icon; } - private getTextToDisplay(element: Component | String | State) { + private getTextToDisplay(element: Component | string | State) { let textToDisplay = ""; if (typeof element === "string") { @@ -136,7 +134,7 @@ class LegendBox implements GuiComponent { private createHtmlElementText( renderedEquation: string, - element: Component | String | State + element: Component | string | State ) { const htmlElementText = document.createElement("div"); htmlElementText.innerHTML = renderedEquation; @@ -166,7 +164,7 @@ class LegendBox implements GuiComponent { }); } - private getIconClass(element: Component | String | State) { + private getIconClass(element: Component | string | State) { if (typeof element === "string" || element instanceof State) { return "point-icon"; } else if (element instanceof Plot) { @@ -178,7 +176,7 @@ class LegendBox implements GuiComponent { } } - private getIconColor(element: Component | String | State) { + private getIconColor(element: Component | string | State) { if (element instanceof Component) { return "#" + element.getColorAsString(); } else { @@ -186,7 +184,7 @@ class LegendBox implements GuiComponent { } } - public addElement(element: Component | String | State) { + public addElement(element: Component | string | State) { if (this.elements.includes(element)) { return; } diff --git a/src/Components/Plot.ts b/src/Components/Plot.ts index 2f50d16..cf38e56 100644 --- a/src/Components/Plot.ts +++ b/src/Components/Plot.ts @@ -1,8 +1,8 @@ +import { EventEmitter } from "events"; import { Vector3, CatmullRomCurve3, Vector2, OrthographicCamera } from "three"; import { parse } from "mathjs"; import { Line2, LineGeometry, LineMaterial } from "three-fatline"; import { Component } from "./interfaces"; -import { EventEmitter } from "events"; type PlotOptions = { numPoints?: number; diff --git a/src/Components/Point.ts b/src/Components/Point.ts index 74f674d..ebdd8d7 100644 --- a/src/Components/Point.ts +++ b/src/Components/Point.ts @@ -1,3 +1,4 @@ +import { EventEmitter } from "events"; import { CircleGeometry, MeshBasicMaterial, @@ -10,7 +11,6 @@ import { } from "three"; import Text from "./Text"; import { Collider, Component, DragListener, Draggable } from "./interfaces"; -import { EventEmitter } from "events"; type PointOptions = { label?: boolean; diff --git a/src/Core.ts b/src/Core.ts index 789532c..7628f79 100644 --- a/src/Core.ts +++ b/src/Core.ts @@ -10,6 +10,7 @@ import { import Stats from "stats.js"; import { OrbitControls } from "three/examples/jsm/controls/OrbitControls"; import { CSS3DRenderer } from "three/examples/jsm/renderers/CSS3DRenderer"; +import LegendBox from "./Components/LegendBox"; import { Component, ConstrainFunction, @@ -17,7 +18,6 @@ import { } from "./Components/interfaces"; import { InputPosition } from "./Components/types"; import { DragControls } from "./Controls/DragControls"; -import LegendBox from "./Components/LegendBox"; const ORBIT_CONTROL_OPTIONS = { LEFT: MOUSE.PAN,