Files
ComfyUI_frontend/src/scripts/ui/dialog.js
Chenlei Hu bcf3a39de7 Migreate ui.js (#8)
* Rename js to ts

* Migrate ui.js
2024-06-14 14:28:39 -04:00

33 lines
649 B
JavaScript

import { $el } from "../ui";
export class ComfyDialog {
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";
}
}