Migrate ui/ (#14)

* Rename js to ts

* Fix all tsc errors
This commit is contained in:
Chenlei Hu
2024-06-14 20:53:25 -04:00
committed by GitHub
parent 1376459cd8
commit 0ef74392ca
8 changed files with 30 additions and 13 deletions

35
src/scripts/ui/dialog.ts Normal file
View File

@@ -0,0 +1,35 @@
import { $el } from "../ui";
export class ComfyDialog {
element: HTMLElement;
textElement: HTMLElement;
constructor() {
this.element = $el("div.comfy-modal", { parent: document.body }, [
$el("div.comfy-modal-content", [$el("p", { $: (p) => (this.textElement = p) }), ...this.createButtons()]),
]);
}
createButtons() {
return [
$el("button", {
type: "button",
textContent: "Close",
onclick: () => this.close(),
}),
];
}
close() {
this.element.style.display = "none";
}
show(html) {
if (typeof html === "string") {
this.textElement.innerHTML = html;
} else {
this.textElement.replaceChildren(html);
}
this.element.style.display = "flex";
}
}