ChatMenu.svelte 1.75 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
	import { flyAndScale } from '$lib/utils/transitions';
Timothy J. Baek's avatar
Timothy J. Baek committed
4
5
6
7

	import Dropdown from '$lib/components/common/Dropdown.svelte';
	import GarbageBin from '$lib/components/icons/GarbageBin.svelte';
	import Pencil from '$lib/components/icons/Pencil.svelte';
8
	import Tooltip from '$lib/components/common/Tooltip.svelte';
Timothy J. Baek's avatar
Timothy J. Baek committed
9
	import Tags from '$lib/components/chat/Tags.svelte';
Timothy J. Baek's avatar
Timothy J. Baek committed
10
11
12

	export let renameHandler: Function;
	export let deleteHandler: Function;
Timothy J. Baek's avatar
Timothy J. Baek committed
13
	export let onClose: Function;
Timothy J. Baek's avatar
Timothy J. Baek committed
14
15
16
17

	export let chatId = '';

	let show = false;
Timothy J. Baek's avatar
Timothy J. Baek committed
18
19
</script>

Timothy J. Baek's avatar
Timothy J. Baek committed
20
<Dropdown
Timothy J. Baek's avatar
Timothy J. Baek committed
21
	bind:show
Timothy J. Baek's avatar
Timothy J. Baek committed
22
23
24
25
26
27
	on:change={(e) => {
		if (e.detail === false) {
			onClose();
		}
	}}
>
28
29
30
	<Tooltip content="More">
		<slot />
	</Tooltip>
Timothy J. Baek's avatar
Timothy J. Baek committed
31
32
33

	<div slot="content">
		<DropdownMenu.Content
Timothy J. Baek's avatar
Timothy J. Baek committed
34
			class="w-full max-w-[150px] rounded-lg px-1 py-1.5 border border-gray-300/30 dark:border-gray-700/50 z-50 bg-white dark:bg-gray-900 dark:text-white shadow"
Timothy J. Baek's avatar
Timothy J. Baek committed
35
			sideOffset={-2}
Timothy J. Baek's avatar
Timothy J. Baek committed
36
37
			side="bottom"
			align="start"
Timothy J. Baek's avatar
Timothy J. Baek committed
38
			transition={flyAndScale}
Timothy J. Baek's avatar
Timothy J. Baek committed
39
40
		>
			<DropdownMenu.Item
Timothy J. Baek's avatar
Timothy J. Baek committed
41
				class="flex gap-2 items-center px-3 py-2 text-sm  font-medium cursor-pointer dark:hover:bg-gray-850 rounded-md"
Timothy J. Baek's avatar
Timothy J. Baek committed
42
43
44
45
46
47
48
49
50
				on:click={() => {
					renameHandler();
				}}
			>
				<Pencil strokeWidth="2" />
				<div class="flex items-center">Rename</div>
			</DropdownMenu.Item>

			<DropdownMenu.Item
Timothy J. Baek's avatar
Timothy J. Baek committed
51
				class="flex  gap-2  items-center px-3 py-2 text-sm  font-medium cursor-pointer dark:hover:bg-gray-850 rounded-md"
Timothy J. Baek's avatar
Timothy J. Baek committed
52
53
54
55
56
57
58
				on:click={() => {
					deleteHandler();
				}}
			>
				<GarbageBin strokeWidth="2" />
				<div class="flex items-center">Delete</div>
			</DropdownMenu.Item>
Timothy J. Baek's avatar
Timothy J. Baek committed
59
60
61
62
63
64

			<hr class="border-gray-100 dark:border-gray-800 mt-2.5 mb-1.5" />

			<div class="flex p-1">
				<Tags {chatId} />
			</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
65
66
67
		</DropdownMenu.Content>
	</div>
</Dropdown>