InputMenu.svelte 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <script lang="ts">
  2. import { DropdownMenu } from 'bits-ui';
  3. import { flyAndScale } from '$lib/utils/transitions';
  4. import { getContext, onMount, tick } from 'svelte';
  5. import { config, user, tools as _tools, mobile } from '$lib/stores';
  6. import { getTools } from '$lib/apis/tools';
  7. import Dropdown from '$lib/components/common/Dropdown.svelte';
  8. import Tooltip from '$lib/components/common/Tooltip.svelte';
  9. import DocumentArrowUpSolid from '$lib/components/icons/DocumentArrowUpSolid.svelte';
  10. import Switch from '$lib/components/common/Switch.svelte';
  11. import GlobeAltSolid from '$lib/components/icons/GlobeAltSolid.svelte';
  12. import WrenchSolid from '$lib/components/icons/WrenchSolid.svelte';
  13. import CameraSolid from '$lib/components/icons/CameraSolid.svelte';
  14. const i18n = getContext('i18n');
  15. export let screenCaptureHandler: Function;
  16. export let uploadFilesHandler: Function;
  17. export let onClose: Function = () => {};
  18. let show = false;
  19. $: if (show) {
  20. init();
  21. }
  22. const init = async () => {};
  23. </script>
  24. <Dropdown
  25. bind:show
  26. on:change={(e) => {
  27. if (e.detail === false) {
  28. onClose();
  29. }
  30. }}
  31. >
  32. <Tooltip content={$i18n.t('More')}>
  33. <slot />
  34. </Tooltip>
  35. <div slot="content">
  36. <DropdownMenu.Content
  37. class="w-full max-w-[200px] rounded-xl px-1 py-1 border-gray-300/30 dark:border-gray-700/50 z-50 bg-white dark:bg-gray-850 dark:text-white shadow"
  38. sideOffset={15}
  39. alignOffset={-8}
  40. side="top"
  41. align="start"
  42. transition={flyAndScale}
  43. >
  44. {#if !$mobile}
  45. <DropdownMenu.Item
  46. 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-xl"
  47. on:click={() => {
  48. screenCaptureHandler();
  49. }}
  50. >
  51. <CameraSolid />
  52. <div class=" line-clamp-1">{$i18n.t('Capture')}</div>
  53. </DropdownMenu.Item>
  54. {/if}
  55. <DropdownMenu.Item
  56. 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-xl"
  57. on:click={() => {
  58. uploadFilesHandler();
  59. }}
  60. >
  61. <DocumentArrowUpSolid />
  62. <div class="line-clamp-1">{$i18n.t('Upload Files')}</div>
  63. </DropdownMenu.Item>
  64. </DropdownMenu.Content>
  65. </div>
  66. </Dropdown>