ChatMenu.svelte 2.8 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';
4
	import { getContext } from 'svelte';
Timothy J. Baek's avatar
Timothy J. Baek committed
5
6
7
8

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

14
15
	const i18n = getContext('i18n');

Timothy J. Baek's avatar
Timothy J. Baek committed
16
	export let shareHandler: Function;
Timothy J. Baek's avatar
Timothy J. Baek committed
17
	export let archiveChatHandler: Function;
Timothy J. Baek's avatar
Timothy J. Baek committed
18
19
	export let renameHandler: Function;
	export let deleteHandler: Function;
Timothy J. Baek's avatar
Timothy J. Baek committed
20
	export let onClose: Function;
Timothy J. Baek's avatar
Timothy J. Baek committed
21
22
23
24

	export let chatId = '';

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

Timothy J. Baek's avatar
Timothy J. Baek committed
27
<Dropdown
Timothy J. Baek's avatar
Timothy J. Baek committed
28
	bind:show
Timothy J. Baek's avatar
Timothy J. Baek committed
29
30
31
32
33
34
	on:change={(e) => {
		if (e.detail === false) {
			onClose();
		}
	}}
>
35
	<Tooltip content={$i18n.t('More')}>
36
37
		<slot />
	</Tooltip>
Timothy J. Baek's avatar
Timothy J. Baek committed
38
39
40

	<div slot="content">
		<DropdownMenu.Content
Timothy J. Baek's avatar
Timothy J. Baek committed
41
			class="w-full max-w-[160px] rounded-xl px-1 py-1.5 border border-gray-300/30 dark:border-gray-700/50 z-50 bg-white dark:bg-gray-850 dark:text-white shadow"
Timothy J. Baek's avatar
Timothy J. Baek committed
42
			sideOffset={-2}
Timothy J. Baek's avatar
Timothy J. Baek committed
43
44
			side="bottom"
			align="start"
Timothy J. Baek's avatar
Timothy J. Baek committed
45
			transition={flyAndScale}
Timothy J. Baek's avatar
Timothy J. Baek committed
46
		>
Timothy J. Baek's avatar
Timothy J. Baek committed
47
			<DropdownMenu.Item
Timothy J. Baek's avatar
Timothy J. Baek committed
48
				class="flex gap-2 items-center px-3 py-2 text-sm  font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800  rounded-md"
Timothy J. Baek's avatar
Timothy J. Baek committed
49
50
51
52
53
				on:click={() => {
					shareHandler();
				}}
			>
				<Share />
54
				<div class="flex items-center">{$i18n.t('Share')}</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
55
56
			</DropdownMenu.Item>

Timothy J. Baek's avatar
Timothy J. Baek committed
57
			<DropdownMenu.Item
Timothy J. Baek's avatar
Timothy J. Baek committed
58
				class="flex gap-2 items-center px-3 py-2 text-sm  font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md"
Timothy J. Baek's avatar
Timothy J. Baek committed
59
60
61
62
63
				on:click={() => {
					renameHandler();
				}}
			>
				<Pencil strokeWidth="2" />
64
				<div class="flex items-center">{$i18n.t('Rename')}</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
65
66
			</DropdownMenu.Item>

Timothy J. Baek's avatar
Timothy J. Baek committed
67
			<DropdownMenu.Item
Timothy J. Baek's avatar
Timothy J. Baek committed
68
				class="flex gap-2 items-center px-3 py-2 text-sm  font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md"
Timothy J. Baek's avatar
Timothy J. Baek committed
69
70
71
72
73
74
75
76
				on:click={() => {
					archiveChatHandler();
				}}
			>
				<ArchiveBox strokeWidth="2" />
				<div class="flex items-center">{$i18n.t('Archive')}</div>
			</DropdownMenu.Item>

Timothy J. Baek's avatar
Timothy J. Baek committed
77
			<DropdownMenu.Item
Timothy J. Baek's avatar
Timothy J. Baek committed
78
				class="flex  gap-2  items-center px-3 py-2 text-sm  font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md"
Timothy J. Baek's avatar
Timothy J. Baek committed
79
80
81
82
83
				on:click={() => {
					deleteHandler();
				}}
			>
				<GarbageBin strokeWidth="2" />
84
				<div class="flex items-center">{$i18n.t('Delete')}</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
85
			</DropdownMenu.Item>
Timothy J. Baek's avatar
Timothy J. Baek committed
86
87
88
89

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

			<div class="flex p-1">
Timothy J. Baek's avatar
Timothy J. Baek committed
90
91
92
93
94
95
96
				<Tags
					{chatId}
					on:close={() => {
						show = false;
						onClose();
					}}
				/>
Timothy J. Baek's avatar
Timothy J. Baek committed
97
			</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
98
99
100
		</DropdownMenu.Content>
	</div>
</Dropdown>