Before repair nav components
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 4s
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 4s
This commit is contained in:
33
components/discarted/modal.js
Normal file
33
components/discarted/modal.js
Normal file
@@ -0,0 +1,33 @@
|
||||
// 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")
|
||||
])
|
||||
]);
|
||||
};
|
||||
Reference in New Issue
Block a user