|
1 | 1 | <div |
2 | 2 | id="search-container" |
3 | | - class="fixed inset-x-0 top-10 hidden flex items-center justify-center z-50 mx-10" |
4 | | - role="dialog" |
5 | | - aria-labelledby="search-dialog-title" |
6 | | - aria-hidden="true" |
| 3 | + class="fixed inset-0 bg-slate-900/25 backdrop-blur transition-opacity w-screen h-screen hidden flex z-50" |
7 | 4 | > |
8 | 5 | <div |
9 | | - class="bg-white dark:bg-neutral-700 w-full max-w-xl rounded-lg shadow-xl relative" |
| 6 | + role="dialog" |
| 7 | + aria-labelledby="search-dialog-title" |
| 8 | + aria-hidden="true" |
| 9 | + class="fixed inset-0 z-50 flex items-start justify-center pt-16 sm:pt-24" |
10 | 10 | > |
11 | 11 | <div |
12 | | - class="p-2 border-b border-b-neutral-100 dark:border-b-neutral-700 outline-none relative flex items-center" |
| 12 | + class="bg-white dark:bg-neutral-700 w-full max-w-xl rounded-lg shadow-xl relative" |
13 | 13 | > |
14 | | - <!-- Search Icon --> |
15 | | - <i |
16 | | - class="fa-solid fa-magnifying-glass p-2 text-neutral-600 dark:text-neutral-100 hover:text-amber-400 text-lg pl-2" |
17 | | - ></i> |
18 | | - |
19 | | - <!-- Search Input --> |
20 | | - <input |
21 | | - id="search-input" |
22 | | - type="text" |
23 | | - class="text-sm bg-transparent outline-none border-none placeholder-neutral-500 dark:placeholder-neutral-300 dark:text-neutral-300 focus:ring-0 pl-4 pr-10" |
24 | | - placeholder="Type to search..." |
25 | | - aria-label="Search input" |
26 | | - /> |
27 | | - |
28 | | - <!-- Close Button --> |
29 | | - <button |
30 | | - onclick="closeSearch()" |
31 | | - class="absolute right-0 top-1/2 transform -translate-y-1/2 text-neutral-400 hover:text-black focus:outline-none focus:ring-0" |
32 | | - aria-label="Close search dialog" |
| 14 | + <div |
| 15 | + class="p-3 border-b border-b-neutral-100 dark:border-b-neutral-700 outline-none relative flex items-center justify-between" |
33 | 16 | > |
| 17 | + <!-- Search Input --> |
| 18 | + <input |
| 19 | + id="search-input" |
| 20 | + type="text" |
| 21 | + class="flex-1 text-sm bg-transparent outline-none border-none placeholder-neutral-500 dark:placeholder-neutral-300 dark:text-neutral-300 focus:ring-0" |
| 22 | + placeholder="Type to search..." |
| 23 | + aria-label="Search input" |
| 24 | + /> |
| 25 | + |
| 26 | + <!-- Search Icon --> |
34 | 27 | <i |
35 | | - class="fa-solid fa-close p-2 text-neutral-600 dark:text-neutral-100 hover:text-amber-400 text-lg mr-3" |
| 28 | + class="fa-solid fa-magnifying-glass p-2 text-neutral-600 dark:text-neutral-100 hover:text-amber-400 text-lg cursor-pointer" |
36 | 29 | ></i> |
37 | | - </button> |
| 30 | + </div> |
| 31 | + <ul id="results-container" class="pb-2"></ul> |
38 | 32 | </div> |
39 | | - <ul id="results-container" class="space-y-2 py-2"></ul> |
40 | 33 | </div> |
41 | 34 | </div> |
42 | 35 |
|
|
49 | 42 | console.error("Search container not found"); |
50 | 43 | } |
51 | 44 | } |
| 45 | + |
52 | 46 | // Initialize SimpleJekyllSearch |
53 | 47 | document.addEventListener("DOMContentLoaded", () => { |
54 | 48 | const searchInput = document.getElementById("search-input"); |
55 | 49 | const resultsContainer = document.getElementById("results-container"); |
56 | 50 |
|
| 51 | + // Add ESC key listener |
| 52 | + document.addEventListener("keydown", (e) => { |
| 53 | + if (e.key === "Escape") { |
| 54 | + e.preventDefault(); // Prevent default to avoid bubbling |
| 55 | + closeSearch(); |
| 56 | + } |
| 57 | + }); |
| 58 | + |
57 | 59 | // Inject site.baseurl from Jekyll into the JSON path |
58 | | - const jsonPath = "{{ site.baseurl }}/assets/search.json"; // Inject site.baseurl here |
| 60 | + const jsonPath = "{{ site.baseurl }}/assets/search.json"; |
59 | 61 |
|
60 | 62 | if (!searchInput || !resultsContainer) { |
61 | 63 | console.error("Search input or results container not found"); |
|
70 | 72 | <li> |
71 | 73 | <a href="{url}" class="flex items-center p-2 dark:text-neutral-100 hover:bg-neutral-100 dark:hover:bg-neutral-600"> |
72 | 74 | <div class="flex flex-row"> |
73 | | - <img src="{{ site.baseurl }}/{image}" alt="{title}" class="w-auto h-12 rounded-lg" /> |
| 75 | + <img src="{{ site.baseurl }}/{image}" alt="{title}" class="w-auto h-12 rounded" /> |
74 | 76 | <div class="flex flex-col ml-2"> |
75 | 77 | <p class="text-sm font-bold">{title}</p> |
76 | 78 | <p class="text-sm">{description}</p> |
|
0 commit comments