flotilla/src/lib/components/Modal.svelte

30 lines
743 B
Svelte
Raw Normal View History

2026-01-30 22:14:12 +00:00
<script lang="ts">
import cx from "classnames"
import {getContext} from "svelte"
2026-01-30 22:14:12 +00:00
import type {Snippet} from "svelte"
import type {DialogContext} from "@lib/components/dialog"
import {DIALOG_CONTEXT} from "@lib/components/dialog"
2026-01-30 22:14:12 +00:00
type Props = {
label?: string
2026-01-30 22:14:12 +00:00
tag?: string
class?: string
children?: Snippet
[key: string]: any
}
const {children, label, tag = "div", ...props}: Props = $props()
const context = getContext<DialogContext | undefined>(DIALOG_CONTEXT)
$effect(() => {
if (label) {
return context?.registerLabel(label)
}
})
2026-01-30 22:14:12 +00:00
</script>
2026-02-03 22:18:58 +00:00
<svelte:element this={tag} {...props} class={cx("flex flex-col overflow-hidden", props.class)}>
2026-01-30 22:14:12 +00:00
{@render children?.()}
</svelte:element>