summaryrefslogtreecommitdiffstatshomepage
path: root/frontend/src/lib/tabs/Tab.svelte
blob: f8dc67c2113a2a15e0d2f36e0a474b123f700a39 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<script lang="ts">
	import { fadeDefault } from '$lib/Transitions';
	import type { Snippet } from 'svelte';
	import { fade } from 'svelte/transition';
	import { getTabContext } from './Tabs.svelte';

	interface Props {
		id: string;
		title: string;
		initial?: boolean;
		children: Snippet;
	}

	let { id, title, initial = false, children }: Props = $props();

	const context = getTabContext();

	context.tabs = { ...context.tabs, [id]: { title } };
	if (initial) {
		context.current = id;
	}
</script>

{#if context.current === id}
	<div class="h-full overflow-auto py-2 pe-3 ps-1" in:fade={fadeDefault}>
		{@render children?.()}
	</div>
{/if}