|
2 | 2 | import '../app.css'; |
3 | 3 | import { page } from '$app/state'; |
4 | 4 | import { Menu, Portal } from '@skeletonlabs/skeleton-svelte'; |
5 | | - import { invalidate } from '$app/navigation'; |
6 | 5 |
|
7 | 6 | import IconSearch from '$lib/svg/IconSearch.svelte'; |
8 | 7 | import MenuIcon from 'lucide-svelte/icons/menu'; |
|
12 | 11 | import LoginAccountButton from '$lib/LoginAccountButton.svelte'; |
13 | 12 | import NavTabs from '$lib/NavTabs.svelte'; |
14 | 13 |
|
15 | | - import { goto } from '$app/navigation'; |
16 | | -
|
17 | | - let searchTerm: string = $state(''); |
18 | | -
|
19 | | - function navigateToSearch(event: any) { |
20 | | - if (event.key === 'Enter' && searchTerm.trim() !== '') { |
21 | | - // Replace spaces with '+' |
22 | | - const encodedSearchTerm = encodeURIComponent(searchTerm.replace(/\s+/g, '+')); |
23 | | -
|
24 | | - // Navigate to the search route |
25 | | - goto(`/search/${encodedSearchTerm}`); |
26 | | - } |
27 | | - } |
28 | | -
|
29 | 14 | let { children } = $props(); |
30 | 15 | </script> |
31 | 16 |
|
|
55 | 40 |
|
56 | 41 | <AppBar.Trail class="overflow-hidden flex justify-end"> |
57 | 42 | <div class="flex gap-1 md:gap-2"> |
58 | | - <div class="input-group grid-cols-[auto_1fr_auto]"> |
59 | | - <div class="ig-cell preset-tonal p-2 md:p-4"> |
60 | | - <IconSearch /> |
61 | | - </div> |
62 | | - <input |
63 | | - class="ig-input md:hidden" |
64 | | - type="search" |
65 | | - placeholder="Search Apps..." |
66 | | - bind:value={searchTerm} |
67 | | - onkeydown={navigateToSearch} |
68 | | - /> |
| 43 | + <form |
| 44 | + action="/search" |
| 45 | + method="GET" |
| 46 | + class="input-group grid-cols-[1fr_auto]" |
| 47 | + role="search" |
| 48 | + > |
69 | 49 | <input |
70 | | - class="ig-input hidden md:block" |
| 50 | + class="ig-input" |
71 | 51 | type="search" |
| 52 | + name="term" |
72 | 53 | placeholder="Search Apps & Companies" |
73 | | - bind:value={searchTerm} |
74 | | - onkeydown={navigateToSearch} |
| 54 | + required |
75 | 55 | /> |
76 | | - </div> |
| 56 | + <button class="ig-cell preset-tonal p-2 md:p-4" type="submit" aria-label="Search"> |
| 57 | + <IconSearch /> |
| 58 | + </button> |
| 59 | + </form> |
77 | 60 |
|
78 | 61 | <LoginAccountButton /> |
79 | 62 | </div> |
|
0 commit comments