mirror of
https://github.com/immich-app/ui.git
synced 2026-09-30 13:32:54 +08:00
* chore: formatter use 2 spaces instead of tabs * chore: format * chore: use defaults * chore: 120 width --------- Co-authored-by: Jason Rasmussen <jason@rasm.me>
29 lines
748 B
Svelte
29 lines
748 B
Svelte
<script lang="ts">
|
|
import { ChildKey } from '$lib/constants.js';
|
|
import type { ChildData } from '$lib/types.js';
|
|
import { withPrefix } from '$lib/utils.js';
|
|
import { getContext, type Snippet } from 'svelte';
|
|
|
|
type ContextType = {
|
|
register: (key: ChildKey, data: () => ChildData) => void;
|
|
};
|
|
type Props = {
|
|
for: ChildKey;
|
|
as: ChildKey;
|
|
class?: string;
|
|
children: Snippet;
|
|
};
|
|
|
|
const { for: key, as, children, class: className }: Props = $props();
|
|
|
|
const context = getContext<ContextType>(withPrefix(key));
|
|
|
|
const data = $derived({ snippet: children, class: className });
|
|
|
|
if (context) {
|
|
context.register(as, () => data);
|
|
} else {
|
|
console.log('Unable to find context for key:', key);
|
|
}
|
|
</script>
|