mirror of
https://github.com/LukeHagar/unicorn-utterances.git
synced 2025-12-06 04:21:55 +00:00
[UwU] Hook up home search box (#649)
This PR implements the home search box
This commit is contained in:
@@ -21,8 +21,8 @@ const tagsToDisplay = [...data.tags]
|
||||
{translate(Astro, "desc.looking_for_more")}
|
||||
</p>
|
||||
|
||||
<form class={style.searchbarRow} onsubmit="event.preventDefault()">
|
||||
<SearchInput class={style.searchbar} />
|
||||
<form id="searchForm" class={style.searchbarRow}>
|
||||
<SearchInput name="searchVal" type="text" class={style.searchbar} />
|
||||
<IconOnlyButton tag="button" type="submit" class={style.searchButton}>
|
||||
<Icon width="100%" height="100%" name="arrow_right" />
|
||||
</IconOnlyButton>
|
||||
@@ -40,3 +40,18 @@ const tagsToDisplay = [...data.tags]
|
||||
}
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
import { buildSearchQuery } from "../../utils/search";
|
||||
|
||||
const searchForm = document.getElementById("searchForm") as HTMLFormElement;
|
||||
searchForm.addEventListener("submit", (e) => {
|
||||
e.preventDefault();
|
||||
const searchVal = (searchForm.searchVal as HTMLInputElement)
|
||||
.value as string;
|
||||
if (!searchVal) return;
|
||||
window.location.href = `/search?${buildSearchQuery({
|
||||
searchQuery: searchVal,
|
||||
})}`;
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user