WebSearchResults.svelte 2.7 KB

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