~james/core

core/web/src/lib/components/ui/DropdownGroup.svelte -rw-r--r-- 866 bytes
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 15 hours ago
                                                                                
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
29
30
31
32
33
<script lang="ts">
	import type { Component, Snippet } from "svelte";
	import type { SvelteHTMLElements } from "svelte/elements";
	import { buttonIcon } from "#lib/components/ui/Button.svelte";
	import { combobox } from "#lib/components/ui/Combobox.svelte";

	interface Props {
		label: string;
		icon?: Component<SvelteHTMLElements["svg"]>;
		children: Snippet;
	}

	let { label, icon: Icon, children }: Props = $props();

	const headingId = $props.id();
	const classes = combobox();
</script>

<div role="group" aria-labelledby={headingId} class="group/dropdown-group not-first:mt-xs">
	<div
		id={headingId}
		role="presentation"
		class={classes.groupHeading({
			class: "flex items-center gap-1.5 group-first/dropdown-group:pt-2xs"
		})}
	>
		{#if Icon}
			<Icon class={buttonIcon()} aria-hidden="true" />
		{/if}
		{label}
	</div>
	{@render children()}
</div>