From 2822eafef67372a67355f744cea84653a3e4bbfe Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Thu, 1 Aug 2024 19:42:32 +0200 Subject: [PATCH] Refactoring: Remove some unused or deprecated classes --- src/UI/Base/Button.ts | 25 ------------------------- src/UI/Base/DivContainer.ts | 19 ------------------- src/UI/Base/Hotkeys.ts | 8 +------- src/UI/Base/TableOfContents.ts | 1 - src/UI/Input/Toggle.ts | 14 -------------- src/UI/i18n/Translations.ts | 6 ------ 6 files changed, 1 insertion(+), 72 deletions(-) delete mode 100644 src/UI/Base/Button.ts delete mode 100644 src/UI/Base/DivContainer.ts diff --git a/src/UI/Base/Button.ts b/src/UI/Base/Button.ts deleted file mode 100644 index ea514be65..000000000 --- a/src/UI/Base/Button.ts +++ /dev/null @@ -1,25 +0,0 @@ -import Translations from "../i18n/Translations" -import BaseUIElement from "../BaseUIElement" - -export class Button extends BaseUIElement { - private _text: BaseUIElement - - constructor(text: string | BaseUIElement, onclick: () => void | Promise) { - super() - this._text = Translations.W(text) - this.onClick(onclick) - } - - protected InnerConstructElement(): HTMLElement { - const el = this._text.ConstructElement() - if (el === undefined) { - return undefined - } - const form = document.createElement("form") - const button = document.createElement("button") - button.type = "button" - button.appendChild(el) - form.appendChild(button) - return form - } -} diff --git a/src/UI/Base/DivContainer.ts b/src/UI/Base/DivContainer.ts deleted file mode 100644 index f36b041d6..000000000 --- a/src/UI/Base/DivContainer.ts +++ /dev/null @@ -1,19 +0,0 @@ -import BaseUIElement from "../BaseUIElement" - -/** - * Introduces a new element which has an ID - * Mostly a workaround for the import viewer - */ -export default class DivContainer extends BaseUIElement { - private readonly _id: string - - constructor(id: string) { - super() - this._id = id - } - protected InnerConstructElement(): HTMLElement { - const e = document.createElement("div") - e.id = this._id - return e - } -} diff --git a/src/UI/Base/Hotkeys.ts b/src/UI/Base/Hotkeys.ts index 03dfb1b28..a7fe3bf82 100644 --- a/src/UI/Base/Hotkeys.ts +++ b/src/UI/Base/Hotkeys.ts @@ -1,12 +1,6 @@ import { Utils } from "../../Utils" -import Combine from "./Combine" -import BaseUIElement from "../BaseUIElement" -import Title from "./Title" -import Table from "./Table" -import { Store, UIEventSource } from "../../Logic/UIEventSource" -import { VariableUiElement } from "./VariableUIElement" +import { UIEventSource } from "../../Logic/UIEventSource" import { Translation } from "../i18n/Translation" -import { FixedUiElement } from "./FixedUiElement" import Translations from "../i18n/Translations" import MarkdownUtils from "../../Utils/MarkdownUtils" import Locale from "../i18n/Locale" diff --git a/src/UI/Base/TableOfContents.ts b/src/UI/Base/TableOfContents.ts index e75ee7b31..5240d7b44 100644 --- a/src/UI/Base/TableOfContents.ts +++ b/src/UI/Base/TableOfContents.ts @@ -2,7 +2,6 @@ import BaseUIElement from "../BaseUIElement" import List from "./List" import { marked } from "marked" import { parse as parse_html } from "node-html-parser" -import { default as turndown } from "turndown" import { Utils } from "../../Utils" export default class TableOfContents { diff --git a/src/UI/Input/Toggle.ts b/src/UI/Input/Toggle.ts index 85412fb1e..c37b1c27d 100644 --- a/src/UI/Input/Toggle.ts +++ b/src/UI/Input/Toggle.ts @@ -1,7 +1,6 @@ import { Store, UIEventSource } from "../../Logic/UIEventSource" import BaseUIElement from "../BaseUIElement" import { VariableUiElement } from "../Base/VariableUIElement" -import Lazy from "../Base/Lazy" /** * The 'Toggle' is a UIElement showing either one of two elements, depending on the state. @@ -19,12 +18,6 @@ export default class Toggle extends VariableUiElement { this.isEnabled = isEnabled } - public static If(condition: Store, constructor: () => BaseUIElement): BaseUIElement { - if (constructor === undefined) { - return undefined - } - return new Toggle(new Lazy(constructor), undefined, condition) - } } /** @@ -42,11 +35,4 @@ export class ClickableToggle extends Toggle { this.isEnabled = isEnabled } - public ToggleOnClick(): ClickableToggle { - const self = this - this.onClick(() => { - self.isEnabled.setData(!self.isEnabled.data) - }) - return this - } } diff --git a/src/UI/i18n/Translations.ts b/src/UI/i18n/Translations.ts index da6b2591d..2006a5e89 100644 --- a/src/UI/i18n/Translations.ts +++ b/src/UI/i18n/Translations.ts @@ -34,12 +34,6 @@ export default class Translations { return s } const v = JSON.stringify(s) - if (v.length > 100) { - const shortened = v.substring(0, 100) + "..." - return new ClickableToggle(v, shortened) - .ToggleOnClick() - .SetClass("literal-code button") - } return new FixedUiElement(v).SetClass("literal-code") } return s