Added function on modal button

This commit is contained in:
Patrick Alvin Alcala 2025-10-01 16:18:36 +08:00
parent a31e7a59b3
commit 3022a084be

View file

@ -14,12 +14,16 @@ interface Props {
width?: number
wide?: boolean
class?: string
function?: () => Promise<void>
}
export default (props: Props) => {
const [isOpen, setIsOpen] = createSignal(false)
const openHandler = () => {
const openHandler = async () => {
if (props.function) {
await props.function()
}
setIsOpen(true)
}
@ -32,6 +36,7 @@ export default (props: Props) => {
<Show when={!isOpen()}>
<Button label={props.label} edges={props.edges} design={props.design} onClick={openHandler} />
</Show>
<Show when={isOpen()}>
<div class="modal" onClick={closeHandler}>
<Show when={props.border}>