WebSearchResults.svelte 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <script lang="ts">
  2. import ChevronDown from '$lib/components/icons/ChevronDown.svelte';
  3. import ChevronUp from '$lib/components/icons/ChevronUp.svelte';
  4. import MagnifyingGlass from '$lib/components/icons/MagnifyingGlass.svelte';
  5. import { Collapsible } from 'bits-ui';
  6. import { slide } from 'svelte/transition';
  7. export let status = { urls: [], query: '' };
  8. let state = false;
  9. </script>
  10. <Collapsible.Root class="w-full space-y-1" bind:open={state}>
  11. <Collapsible.Trigger>
  12. <div
  13. class="flex items-center gap-2 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition"
  14. >
  15. <slot />
  16. {#if state}
  17. <ChevronUp strokeWidth="3.5" className="size-3.5 " />
  18. {:else}
  19. <ChevronDown strokeWidth="3.5" className="size-3.5 " />
  20. {/if}
  21. </div>
  22. </Collapsible.Trigger>
  23. <Collapsible.Content
  24. class=" text-sm border border-gray-300/30 dark:border-gray-700/50 rounded-xl"
  25. transition={slide}
  26. >
  27. {#if status?.query}
  28. <a
  29. href="https://www.google.com/search?q={status.query}"
  30. target="_blank"
  31. class="flex w-full items-center p-3 px-4 border-b border-gray-300/30 dark:border-gray-700/50 group/item justify-between font-normal text-gray-800 dark:text-gray-300 no-underline"
  32. >
  33. <div class="flex gap-2 items-center">
  34. <MagnifyingGlass />
  35. <div class=" line-clamp-1">
  36. {status.query}
  37. </div>
  38. </div>
  39. <div
  40. class=" ml-1 text-white dark:text-gray-900 group-hover/item:text-gray-600 dark:group-hover/item:text-white transition"
  41. >
  42. <!-- -->
  43. <svg
  44. xmlns="http://www.w3.org/2000/svg"
  45. viewBox="0 0 16 16"
  46. fill="currentColor"
  47. class="size-4"
  48. >
  49. <path
  50. fill-rule="evenodd"
  51. d="M4.22 11.78a.75.75 0 0 1 0-1.06L9.44 5.5H5.75a.75.75 0 0 1 0-1.5h5.5a.75.75 0 0 1 .75.75v5.5a.75.75 0 0 1-1.5 0V6.56l-5.22 5.22a.75.75 0 0 1-1.06 0Z"
  52. clip-rule="evenodd"
  53. />
  54. </svg>
  55. </div>
  56. </a>
  57. {/if}
  58. {#each status.urls as url, urlIdx}
  59. <a
  60. href={url}
  61. target="_blank"
  62. class="flex w-full items-center p-3 px-4 {urlIdx === status.urls.length - 1
  63. ? ''
  64. : 'border-b border-gray-300/30 dark:border-gray-700/50'} group/item justify-between font-normal text-gray-800 dark:text-gray-300"
  65. >
  66. <div class=" line-clamp-1">
  67. {url}
  68. </div>
  69. <div
  70. class=" ml-1 text-white dark:text-gray-900 group-hover/item:text-gray-600 dark:group-hover/item:text-white transition"
  71. >
  72. <!-- -->
  73. <svg
  74. xmlns="http://www.w3.org/2000/svg"
  75. viewBox="0 0 16 16"
  76. fill="currentColor"
  77. class="size-4"
  78. >
  79. <path
  80. fill-rule="evenodd"
  81. d="M4.22 11.78a.75.75 0 0 1 0-1.06L9.44 5.5H5.75a.75.75 0 0 1 0-1.5h5.5a.75.75 0 0 1 .75.75v5.5a.75.75 0 0 1-1.5 0V6.56l-5.22 5.22a.75.75 0 0 1-1.06 0Z"
  82. clip-rule="evenodd"
  83. />
  84. </svg>
  85. </div>
  86. </a>
  87. {/each}
  88. </Collapsible.Content>
  89. </Collapsible.Root>