ItemMenu.svelte 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <script lang="ts">
  2. import { DropdownMenu } from 'bits-ui';
  3. import { flyAndScale } from '$lib/utils/transitions';
  4. import { getContext, createEventDispatcher } from 'svelte';
  5. const dispatch = createEventDispatcher();
  6. import Dropdown from '$lib/components/common/Dropdown.svelte';
  7. import GarbageBin from '$lib/components/icons/GarbageBin.svelte';
  8. import Pencil from '$lib/components/icons/Pencil.svelte';
  9. import Tooltip from '$lib/components/common/Tooltip.svelte';
  10. import Tags from '$lib/components/chat/Tags.svelte';
  11. import Share from '$lib/components/icons/Share.svelte';
  12. import ArchiveBox from '$lib/components/icons/ArchiveBox.svelte';
  13. import DocumentDuplicate from '$lib/components/icons/DocumentDuplicate.svelte';
  14. import ArrowDownTray from '$lib/components/icons/ArrowDownTray.svelte';
  15. import ArrowUpCircle from '$lib/components/icons/ArrowUpCircle.svelte';
  16. import EllipsisHorizontal from '$lib/components/icons/EllipsisHorizontal.svelte';
  17. const i18n = getContext('i18n');
  18. export let onClose: Function = () => {};
  19. let show = false;
  20. </script>
  21. <Dropdown
  22. bind:show
  23. on:change={(e) => {
  24. if (e.detail === false) {
  25. onClose();
  26. }
  27. }}
  28. align="end"
  29. >
  30. <Tooltip content={$i18n.t('More')}>
  31. <slot
  32. ><button
  33. class="self-center w-fit text-sm p-1.5 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
  34. type="button"
  35. on:click={(e) => {
  36. e.stopPropagation();
  37. show = true;
  38. }}
  39. >
  40. <EllipsisHorizontal className="size-5" />
  41. </button>
  42. </slot>
  43. </Tooltip>
  44. <div slot="content">
  45. <DropdownMenu.Content
  46. 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"
  47. sideOffset={-2}
  48. side="bottom"
  49. align="end"
  50. transition={flyAndScale}
  51. >
  52. <DropdownMenu.Item
  53. 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"
  54. on:click={() => {
  55. dispatch('delete');
  56. }}
  57. >
  58. <GarbageBin strokeWidth="2" />
  59. <div class="flex items-center">{$i18n.t('Delete')}</div>
  60. </DropdownMenu.Item>
  61. </DropdownMenu.Content>
  62. </div>
  63. </Dropdown>