ChatMenu.svelte 2.31 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

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

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

	export let chatId = '';

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

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

	<div slot="content">
		<DropdownMenu.Content
Timothy J. Baek's avatar
Timothy J. Baek committed
39
			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
40
			sideOffset={-2}
Timothy J. Baek's avatar
Timothy J. Baek committed
41
42
			side="bottom"
			align="start"
Timothy J. Baek's avatar
Timothy J. Baek committed
43
			transition={flyAndScale}
Timothy J. Baek's avatar
Timothy J. Baek committed
44
		>
Timothy J. Baek's avatar
Timothy J. Baek committed
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 />
52
				<div class="flex items-center">{$i18n.t('Share')}</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
53
54
			</DropdownMenu.Item>

Timothy J. Baek's avatar
Timothy J. Baek committed
55
			<DropdownMenu.Item
Timothy J. Baek's avatar
Timothy J. Baek committed
56
				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
57
58
59
60
61
				on:click={() => {
					renameHandler();
				}}
			>
				<Pencil strokeWidth="2" />
62
				<div class="flex items-center">{$i18n.t('Rename')}</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
63
64
65
			</DropdownMenu.Item>

			<DropdownMenu.Item
Timothy J. Baek's avatar
Timothy J. Baek committed
66
				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
67
68
69
70
71
				on:click={() => {
					deleteHandler();
				}}
			>
				<GarbageBin strokeWidth="2" />
72
				<div class="flex items-center">{$i18n.t('Delete')}</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
73
			</DropdownMenu.Item>
Timothy J. Baek's avatar
Timothy J. Baek committed
74
75
76
77

			<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
78
79
80
81
82
83
84
				<Tags
					{chatId}
					on:close={() => {
						show = false;
						onClose();
					}}
				/>
Timothy J. Baek's avatar
Timothy J. Baek committed
85
			</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
86
87
88
		</DropdownMenu.Content>
	</div>
</Dropdown>