1
0

AddFunctionMenu.svelte 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 Tooltip from '$lib/components/common/Tooltip.svelte';
  8. import Share from '$lib/components/icons/Share.svelte';
  9. import DocumentDuplicate from '$lib/components/icons/DocumentDuplicate.svelte';
  10. import ArrowDownTray from '$lib/components/icons/ArrowDownTray.svelte';
  11. import Switch from '$lib/components/common/Switch.svelte';
  12. import GlobeAlt from '$lib/components/icons/GlobeAlt.svelte';
  13. import Github from '$lib/components/icons/Github.svelte';
  14. import Plus from '$lib/components/icons/Plus.svelte';
  15. import Pencil from '$lib/components/icons/Pencil.svelte';
  16. import PencilSolid from '$lib/components/icons/PencilSolid.svelte';
  17. import Link from '$lib/components/icons/Link.svelte';
  18. const i18n = getContext('i18n');
  19. export let createHandler: Function;
  20. export let importFromLinkHandler: Function;
  21. export let onClose: Function = () => {};
  22. let show = false;
  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('Create')}>
  33. <slot />
  34. </Tooltip>
  35. <div slot="content">
  36. <DropdownMenu.Content
  37. class="w-full max-w-[190px] text-sm rounded-xl px-1 py-1.5 z-50 bg-white dark:bg-gray-850 dark:text-white shadow-lg font-primary"
  38. sideOffset={-2}
  39. side="bottom"
  40. align="start"
  41. transition={flyAndScale}
  42. >
  43. <button
  44. class="flex rounded-md py-1.5 px-3 w-full hover:bg-gray-50 dark:hover:bg-gray-800 transition"
  45. on:click={async () => {
  46. createHandler();
  47. show = false;
  48. }}
  49. >
  50. <div class=" self-center mr-2">
  51. <PencilSolid />
  52. </div>
  53. <div class=" self-center truncate">{$i18n.t('New Function')}</div>
  54. </button>
  55. <button
  56. class="flex rounded-md py-1.5 px-3 w-full hover:bg-gray-50 dark:hover:bg-gray-800 transition"
  57. on:click={async () => {
  58. importFromLinkHandler();
  59. show = false;
  60. }}
  61. >
  62. <div class=" self-center mr-2">
  63. <Link />
  64. </div>
  65. <div class=" self-center truncate">{$i18n.t('Import From Link')}</div>
  66. </button>
  67. </DropdownMenu.Content>
  68. </div>
  69. </Dropdown>