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

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

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

	export let chatId = '';

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

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

	<div slot="content">
		<DropdownMenu.Content
Timothy J. Baek's avatar
Timothy J. Baek committed
43
			class="w-full max-w-[180px] 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
44
			sideOffset={-2}
Timothy J. Baek's avatar
Timothy J. Baek committed
45
46
			side="bottom"
			align="start"
Timothy J. Baek's avatar
Timothy J. Baek committed
47
			transition={flyAndScale}
Timothy J. Baek's avatar
Timothy J. Baek committed
48
		>
Timothy J. Baek's avatar
Timothy J. Baek committed
49
			<DropdownMenu.Item
Timothy J. Baek's avatar
Timothy J. Baek committed
50
				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
51
				on:click={() => {
Timothy J. Baek's avatar
Timothy J. Baek committed
52
					renameHandler();
Timothy J. Baek's avatar
Timothy J. Baek committed
53
54
				}}
			>
Timothy J. Baek's avatar
Timothy J. Baek committed
55
56
				<Pencil strokeWidth="2" />
				<div class="flex items-center">{$i18n.t('Rename')}</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
57
58
			</DropdownMenu.Item>

Timothy J. Baek's avatar
Timothy J. Baek committed
59
			<DropdownMenu.Item
Timothy J. Baek's avatar
Timothy J. Baek committed
60
				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
61
				on:click={() => {
Timothy J. Baek's avatar
Timothy J. Baek committed
62
					cloneChatHandler();
Timothy J. Baek's avatar
Timothy J. Baek committed
63
64
				}}
			>
Timothy J. Baek's avatar
Timothy J. Baek committed
65
66
				<DocumentDuplicate strokeWidth="2" />
				<div class="flex items-center">{$i18n.t('Clone')}</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
67
68
			</DropdownMenu.Item>

Timothy J. Baek's avatar
Timothy J. Baek committed
69
			<DropdownMenu.Item
Timothy J. Baek's avatar
Timothy J. Baek committed
70
				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
71
72
73
74
75
76
77
78
				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
79
80
81
82
83
84
85
86
87
88
			<DropdownMenu.Item
				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"
				on:click={() => {
					shareHandler();
				}}
			>
				<Share />
				<div class="flex items-center">{$i18n.t('Share')}</div>
			</DropdownMenu.Item>

Timothy J. Baek's avatar
Timothy J. Baek committed
89
			<DropdownMenu.Item
Timothy J. Baek's avatar
Timothy J. Baek committed
90
				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
91
92
93
94
95
				on:click={() => {
					deleteHandler();
				}}
			>
				<GarbageBin strokeWidth="2" />
96
				<div class="flex items-center">{$i18n.t('Delete')}</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
97
			</DropdownMenu.Item>
Timothy J. Baek's avatar
Timothy J. Baek committed
98
99
100
101

			<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
102
103
104
105
106
107
108
				<Tags
					{chatId}
					on:close={() => {
						show = false;
						onClose();
					}}
				/>
Timothy J. Baek's avatar
Timothy J. Baek committed
109
			</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
110
111
112
		</DropdownMenu.Content>
	</div>
</Dropdown>