ChatMenu.svelte 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <script lang="ts">
  2. import { DropdownMenu } from 'bits-ui';
  3. import { flyAndScale } from '$lib/utils/transitions';
  4. import { getContext } from 'svelte'
  5. import Dropdown from '$lib/components/common/Dropdown.svelte';
  6. import GarbageBin from '$lib/components/icons/GarbageBin.svelte';
  7. import Pencil from '$lib/components/icons/Pencil.svelte';
  8. import Tooltip from '$lib/components/common/Tooltip.svelte';
  9. import Tags from '$lib/components/chat/Tags.svelte';
  10. import Share from '$lib/components/icons/Share.svelte';
  11. const i18n = getContext('i18n');
  12. export let shareHandler: Function;
  13. export let renameHandler: Function;
  14. export let deleteHandler: Function;
  15. export let onClose: Function;
  16. export let chatId = '';
  17. let show = false;
  18. </script>
  19. <Dropdown
  20. bind:show
  21. on:change={(e) => {
  22. if (e.detail === false) {
  23. onClose();
  24. }
  25. }}
  26. >
  27. <Tooltip content={$i18n.t('More')}>
  28. <slot />
  29. </Tooltip>
  30. <div slot="content">
  31. <DropdownMenu.Content
  32. 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"
  33. sideOffset={-2}
  34. side="bottom"
  35. align="start"
  36. transition={flyAndScale}
  37. >
  38. <DropdownMenu.Item
  39. class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer dark:hover:bg-gray-850 rounded-md"
  40. on:click={() => {
  41. shareHandler();
  42. }}
  43. >
  44. <Share />
  45. <div class="flex items-center">Share</div>
  46. </DropdownMenu.Item>
  47. <DropdownMenu.Item
  48. class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer dark:hover:bg-gray-850 rounded-md"
  49. on:click={() => {
  50. renameHandler();
  51. }}
  52. >
  53. <Pencil strokeWidth="2" />
  54. <div class="flex items-center">Rename</div>
  55. </DropdownMenu.Item>
  56. <DropdownMenu.Item
  57. class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer dark:hover:bg-gray-850 rounded-md"
  58. on:click={() => {
  59. deleteHandler();
  60. }}
  61. >
  62. <GarbageBin strokeWidth="2" />
  63. <div class="flex items-center">Delete</div>
  64. </DropdownMenu.Item>
  65. <hr class="border-gray-100 dark:border-gray-800 mt-2.5 mb-1.5" />
  66. <div class="flex p-1">
  67. <Tags {chatId} />
  68. </div>
  69. </DropdownMenu.Content>
  70. </div>
  71. </Dropdown>