ChatMenu.svelte 2.12 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
	import Share from '$lib/components/icons/Share.svelte';
Timothy J. Baek's avatar
Timothy J. Baek committed
11

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

	export let chatId = '';

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

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

	<div slot="content">
		<DropdownMenu.Content
Timothy J. Baek's avatar
Timothy J. Baek committed
36
			class="w-full max-w-[180px] 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
37
			sideOffset={-2}
Timothy J. Baek's avatar
Timothy J. Baek committed
38
39
			side="bottom"
			align="start"
Timothy J. Baek's avatar
Timothy J. Baek committed
40
			transition={flyAndScale}
Timothy J. Baek's avatar
Timothy J. Baek committed
41
		>
Timothy J. Baek's avatar
Timothy J. Baek committed
42
43
44
45
46
47
48
49
50
51
			<DropdownMenu.Item
				class="flex gap-2 items-center px-3 py-2 text-sm  font-medium cursor-pointer dark:hover:bg-gray-850 rounded-md"
				on:click={() => {
					shareHandler();
				}}
			>
				<Share />
				<div class="flex items-center">Share</div>
			</DropdownMenu.Item>

Timothy J. Baek's avatar
Timothy J. Baek committed
52
			<DropdownMenu.Item
Timothy J. Baek's avatar
Timothy J. Baek committed
53
				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
54
55
56
57
58
59
60
61
62
				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
63
				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
64
65
66
67
68
69
70
				on:click={() => {
					deleteHandler();
				}}
			>
				<GarbageBin strokeWidth="2" />
				<div class="flex items-center">Delete</div>
			</DropdownMenu.Item>
Timothy J. Baek's avatar
Timothy J. Baek committed
71
72
73
74
75
76

			<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
77
78
79
		</DropdownMenu.Content>
	</div>
</Dropdown>