Dropdown.svelte 1.15 KB
Newer Older
Timothy J. Baek's avatar
Timothy J. Baek committed
1
2
<script lang="ts">
	import { DropdownMenu } from 'bits-ui';
Timothy J. Baek's avatar
Timothy J. Baek committed
3
4
	import { createEventDispatcher } from 'svelte';

Timothy J. Baek's avatar
Timothy J. Baek committed
5
6
	import { flyAndScale } from '$lib/utils/transitions';

Timothy J. Baek's avatar
Timothy J. Baek committed
7
	export let show = false;
Timothy J. Baek's avatar
Timothy J. Baek committed
8
	const dispatch = createEventDispatcher();
Timothy J. Baek's avatar
Timothy J. Baek committed
9
10
</script>

Timothy J. Baek's avatar
Timothy J. Baek committed
11
<DropdownMenu.Root
Timothy J. Baek's avatar
Timothy J. Baek committed
12
	bind:open={show}
Timothy J. Baek's avatar
Timothy J. Baek committed
13
	closeFocus={false}
Timothy J. Baek's avatar
Timothy J. Baek committed
14
15
16
17
	onOpenChange={(state) => {
		dispatch('change', state);
	}}
>
Timothy J. Baek's avatar
Timothy J. Baek committed
18
19
20
21
22
23
24
25
26
27
	<DropdownMenu.Trigger>
		<slot />
	</DropdownMenu.Trigger>

	<slot name="content">
		<DropdownMenu.Content
			class="w-full max-w-[130px] rounded-lg px-1 py-1.5 border border-gray-700 z-50 bg-gray-850 text-white"
			sideOffset={8}
			side="bottom"
			align="start"
Timothy J. Baek's avatar
Timothy J. Baek committed
28
			transition={flyAndScale}
Timothy J. Baek's avatar
Timothy J. Baek committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
		>
			<DropdownMenu.Item class="flex items-center px-3 py-2 text-sm  font-medium">
				<div class="flex items-center">Profile</div>
			</DropdownMenu.Item>

			<DropdownMenu.Item class="flex items-center px-3 py-2 text-sm  font-medium">
				<div class="flex items-center">Profile</div>
			</DropdownMenu.Item>

			<DropdownMenu.Item class="flex items-center px-3 py-2 text-sm  font-medium">
				<div class="flex items-center">Profile</div>
			</DropdownMenu.Item>
		</DropdownMenu.Content>
	</slot>
</DropdownMenu.Root>