ProjectMenu.svelte 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. >
  36. <EllipsisHorizontal className="size-5" />
  37. </button>
  38. </slot>
  39. </Tooltip>
  40. <div slot="content">
  41. <DropdownMenu.Content
  42. 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"
  43. sideOffset={-2}
  44. side="bottom"
  45. align="end"
  46. transition={flyAndScale}
  47. >
  48. <DropdownMenu.Item
  49. 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"
  50. on:click={() => {
  51. dispatch('delete');
  52. }}
  53. >
  54. <GarbageBin strokeWidth="2" />
  55. <div class="flex items-center">{$i18n.t('Delete')}</div>
  56. </DropdownMenu.Item>
  57. </DropdownMenu.Content>
  58. </div>
  59. </Dropdown>