This commit is contained in:
Ian Gulliver
2026-10-15 22:21:20 -07:00
parent 84de97cec9
commit a1a4b83f39
22 changed files with 171 additions and 204 deletions
-22
View File
@@ -109,28 +109,6 @@ function modal(content: string | Node[], buttons: { label: string; value: string
});
}
export function openPanel(title: string, mount: (root: HTMLElement) => () => void): void {
if (document.querySelector("dialog.panel[open]")) {
return;
}
const close = h("button", { type: "button", class: "panel-close", title: "Close (Esc)" }, "×");
const body = h("div", { class: "panel-body" });
const dialog = h("dialog", { class: "modal panel" }, h("header", { class: "panel-head" }, h("h2", {}, title), close), body);
close.onclick = () => dialog.close();
dialog.onclick = (e) => {
if (e.target === dialog || (e.target as Element).closest("a[href^='#']")) {
dialog.close();
}
};
document.body.append(dialog);
const dispose = mount(body);
dialog.onclose = () => {
dispose();
dialog.remove();
};
dialog.showModal();
}
export async function showAlert(text: string): Promise<void> {
await modal(text, [{ label: "OK", value: "ok", class: "primary" }]);
}