Skip to content

Commit

Permalink
Search UI (#627)
Browse files Browse the repository at this point in the history
* use new search in frontend

* fix wrong types for search return

* fix loading show on backspace, don't query classbadge

* refactor index filtering and log error

* adjust search weights

* handle translation server side

* handle empty search input and refine result filtering

* use i18n route resolver

* add error handling to search component and server actions

* add committee, refactor to reduce duplication

* add search unit tests

* explicit primary key when adding to meilisearch

* use class name for search result
  • Loading branch information
alfredgrip authored Dec 11, 2024
1 parent a9c07f4 commit d6dce6a
Show file tree
Hide file tree
Showing 19 changed files with 1,026 additions and 291 deletions.
115 changes: 0 additions & 115 deletions src/lib/components/Search.svelte

This file was deleted.

23 changes: 23 additions & 0 deletions src/lib/components/search/ArticleSearchResult.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script lang="ts">
import type { ArticleSearchReturnAttributes } from "$lib/search/searchTypes";
export let article: ArticleSearchReturnAttributes;
</script>

<li>
<a
href={"/news/" + article.slug}
class="search-result border border-transparent focus:border-primary"
>
<div class="avatar aspect-square w-8 overflow-hidden rounded-full">
<span class="i-mdi-newspaper text-2xl"></span>
</div>
<div>
<h4 class="text-balance">
{article.header}
</h4>
<p class="line-clamp-1 text-gray-500">
{article.body}
</p>
</div>
</a>
</li>
29 changes: 29 additions & 0 deletions src/lib/components/search/CommitteeSearchResult.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script lang="ts">
import type { CommitteeSearchReturnAttributes } from "$lib/search/searchTypes";
import CommitteeIcon from "$lib/components/images/CommitteeIcon.svelte";
export let committee: CommitteeSearchReturnAttributes;
</script>

<li>
<a
href={"/committees/" + committee.shortName}
class="search-result border border-transparent focus:border-primary"
>
<div class="avatar aspect-square w-8 overflow-hidden rounded-full">
<figure class="relative w-full">
<CommitteeIcon {committee} />
</figure>
</div>
<div>
<h4>
<b>
{committee.name}
</b>
</h4>
<p class="line-clamp-1 text-gray-500">
{committee.description}
</p>
</div></a
>
</li>
23 changes: 23 additions & 0 deletions src/lib/components/search/EventSearchResult.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script lang="ts">
import type { EventSearchReturnAttributes } from "$lib/search/searchTypes";
export let event: EventSearchReturnAttributes;
</script>

<li>
<a
href={"/events/" + event.slug}
class="search-result border border-transparent focus:border-primary"
>
<div class="avatar aspect-square w-8 overflow-hidden rounded-full">
<span class="i-mdi-calendar text-2xl"></span>
</div>
<div>
<h4>
{event.title}
</h4>
<p class="line-clamp-1 text-gray-500">
{event.description}
</p>
</div>
</a>
</li>
Loading

0 comments on commit d6dce6a

Please sign in to comment.