AIMenu.svelte 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <script lang="ts">
  2. import { DropdownMenu } from 'bits-ui';
  3. import { createEventDispatcher, getContext, onMount } from 'svelte';
  4. import { showSettings, mobile, showSidebar, user } from '$lib/stores';
  5. import { fade, slide } from 'svelte/transition';
  6. import PencilSquare from '../icons/PencilSquare.svelte';
  7. import ChatBubbleOval from '../icons/ChatBubbleOval.svelte';
  8. import Sparkles from '../icons/Sparkles.svelte';
  9. const i18n = getContext('i18n');
  10. export let show = false;
  11. export let className = 'max-w-[170px]';
  12. export let onEdit = () => {};
  13. export let onChat = () => {};
  14. export let onChange = () => {};
  15. </script>
  16. <DropdownMenu.Root bind:open={show} onOpenChange={onChange}>
  17. <DropdownMenu.Trigger>
  18. <slot />
  19. </DropdownMenu.Trigger>
  20. <slot name="content">
  21. <DropdownMenu.Content
  22. class="w-full {className} text-sm rounded-xl px-1 py-1.5 z-50 bg-white dark:bg-gray-850 dark:text-white shadow-lg font-primary"
  23. sideOffset={8}
  24. side="bottom"
  25. align="start"
  26. transition={(e) => fade(e, { duration: 100 })}
  27. >
  28. <button
  29. class="flex rounded-md py-1.5 px-3 w-full hover:bg-gray-50 dark:hover:bg-gray-800 transition"
  30. on:click={async () => {
  31. onEdit();
  32. show = false;
  33. }}
  34. >
  35. <div class=" self-center mr-2">
  36. <Sparkles className="size-4" strokeWidth="2" />
  37. </div>
  38. <div class=" self-center truncate">{$i18n.t('Enhance')}</div>
  39. </button>
  40. <button
  41. class="flex rounded-md py-1.5 px-3 w-full hover:bg-gray-50 dark:hover:bg-gray-800 transition"
  42. on:click={() => {
  43. onChat();
  44. show = false;
  45. }}
  46. >
  47. <div class=" self-center mr-2">
  48. <ChatBubbleOval className="size-4" strokeWidth="2" />
  49. </div>
  50. <div class=" self-center truncate">{$i18n.t('Chat')}</div>
  51. </button>
  52. </DropdownMenu.Content>
  53. </slot>
  54. </DropdownMenu.Root>