Skip to content

Commit

Permalink
Formatting fix
Browse files Browse the repository at this point in the history
  • Loading branch information
amaliejvik committed Jul 3, 2024
1 parent 09f307a commit bb269c8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
22 changes: 10 additions & 12 deletions src/Components/LegendBox.ts
Original file line number Diff line number Diff line change
@@ -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<number>)[];
elements: (Component | string | State<number>)[];
states: { [key: string]: State<number> };
htmlElement: HTMLElement;

constructor(elements?: (Component | String | State<number>)[]) {
constructor(elements?: (Component | string | State<number>)[]) {
this.elements = elements || [];
this.states = {};
this.htmlElement = this.createLegendBoxWrapper();
Expand Down Expand Up @@ -84,7 +82,7 @@ class LegendBox implements GuiComponent {
this.elements.length === 0 ? "none" : "block";
}

private processElement(element: Component | String | State<number>) {
private processElement(element: Component | string | State<number>) {
const functionContainer = document.createElement("div");
functionContainer.className = "function-container";
const icon = this.createIcon(element);
Expand All @@ -105,7 +103,7 @@ class LegendBox implements GuiComponent {
this.htmlElement.appendChild(functionContainer);
}

private createIcon(element: Component | String | State<number>) {
private createIcon(element: Component | string | State<number>) {
const icon = document.createElement("span");
icon.className = this.getIconClass(element);
if (icon.className === "triangle-icon") {
Expand All @@ -116,7 +114,7 @@ class LegendBox implements GuiComponent {
return icon;
}

private getTextToDisplay(element: Component | String | State<number>) {
private getTextToDisplay(element: Component | string | State<number>) {
let textToDisplay = "";

if (typeof element === "string") {
Expand All @@ -136,7 +134,7 @@ class LegendBox implements GuiComponent {

private createHtmlElementText(
renderedEquation: string,
element: Component | String | State<number>
element: Component | string | State<number>
) {
const htmlElementText = document.createElement("div");
htmlElementText.innerHTML = renderedEquation;
Expand Down Expand Up @@ -166,7 +164,7 @@ class LegendBox implements GuiComponent {
});
}

private getIconClass(element: Component | String | State<number>) {
private getIconClass(element: Component | string | State<number>) {
if (typeof element === "string" || element instanceof State) {
return "point-icon";
} else if (element instanceof Plot) {
Expand All @@ -178,15 +176,15 @@ class LegendBox implements GuiComponent {
}
}

private getIconColor(element: Component | String | State<number>) {
private getIconColor(element: Component | string | State<number>) {
if (element instanceof Component) {
return "#" + element.getColorAsString();
} else {
return "#faa307";
}
}

public addElement(element: Component | String | State<number>) {
public addElement(element: Component | string | State<number>) {
if (this.elements.includes(element)) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Plot.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Point.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EventEmitter } from "events";
import {
CircleGeometry,
MeshBasicMaterial,
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ 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,
GuiComponent,
} 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,
Expand Down

0 comments on commit bb269c8

Please sign in to comment.