All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 3s
33 lines
927 B
JavaScript
33 lines
927 B
JavaScript
// components/Modal.js
|
|
import { h, watch } from "sigpro";
|
|
|
|
export const Modal = (props) => {
|
|
let dialogRef = null;
|
|
|
|
watch(() => {
|
|
const isOpen = typeof props.open === "function" ? props.open() : props.open;
|
|
if (!dialogRef) return;
|
|
isOpen ? dialogRef.showModal() : dialogRef.close();
|
|
});
|
|
|
|
const close = () => typeof props.open === "function" && props.open(false);
|
|
|
|
return h("dialog", {
|
|
...props,
|
|
ref: el => dialogRef = el,
|
|
class: `modal ${props.class ?? ''}`,
|
|
onclose: close,
|
|
oncancel: close
|
|
}, [
|
|
h("div", { class: "modal-box" }, [
|
|
props.title && h("h3", { class: "text-lg font-bold" }, props.title),
|
|
props.children,
|
|
h("div", { class: "modal-action" }, [
|
|
props.actions || h("button", { class: "btn", onclick: close }, "Cerrar")
|
|
])
|
|
]),
|
|
h("form", { method: "dialog", class: "modal-backdrop" }, [
|
|
h("button", {}, "close")
|
|
])
|
|
]);
|
|
}; |