WebSearchResults.svelte 2.7 KB

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