flotilla/src/lib/components/ModalTitle.svelte

23 lines
628 B
Svelte
Raw Normal View History

2026-02-02 18:09:14 +00:00
<script lang="ts">
import {getContext} from "svelte"
2026-02-02 18:09:14 +00:00
import type {Snippet} from "svelte"
import cx from "classnames"
import {randomId} from "@welshman/lib"
import type {DialogContext} from "@lib/components/dialog"
import {DIALOG_CONTEXT} from "@lib/components/dialog"
2026-02-02 18:09:14 +00:00
type Props = {
class?: string
2026-02-02 18:09:14 +00:00
children: Snippet
}
const {children, ...props}: Props = $props()
const id = randomId()
const context = getContext<DialogContext | undefined>(DIALOG_CONTEXT)
$effect(() => context?.registerTitle(id))
2026-02-02 18:09:14 +00:00
</script>
<h1 {id} class={cx("heading", props.class)} tabindex="-1">{@render children()}</h1>