feat: add sorting to search page
This commit is contained in:
1 parent
cb21ab02c5
commit
609c8c1b73
3 files changed
+25
-24
No files matched your search
@@ -53,7 +53,7 @@
|
|||||||
</Material>
|
</Material>
|
||||||
</Popover>
|
</Popover>
|
||||||
</h1>
|
</h1>
|
||||||
<div class="flex flex-row flex-wrap gap-4 mt-4">
|
<div class="flex flex-row flex-wrap gap-4 mt-4 items-center">
|
||||||
<Select
|
<Select
|
||||||
bind:value={data.type}
|
bind:value={data.type}
|
||||||
on:change={() => searchParam($page.url, 'type', data.type ?? 'All', 'page')}
|
on:change={() => searchParam($page.url, 'type', data.type ?? 'All', 'page')}
|
||||||
@@ -75,14 +75,15 @@
|
|||||||
bind:value={search}
|
bind:value={search}
|
||||||
placeholder="Search for a community..."
|
placeholder="Search for a community..."
|
||||||
label="Query"
|
label="Query"
|
||||||
size="sm"
|
size="md"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
submit
|
submit
|
||||||
color="ghost"
|
color="secondary"
|
||||||
size="square-md"
|
size="custom"
|
||||||
class="self-end"
|
class="self-end"
|
||||||
aria-label="Search"
|
style="width: 38px; height: 38px;"
|
||||||
|
title="Search"
|
||||||
>
|
>
|
||||||
<Icon src={MagnifyingGlass} size="16" mini />
|
<Icon src={MagnifyingGlass} size="16" mini />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import ObjectAutocomplete from '$lib/components/lemmy/ObjectAutocomplete.svelte'
|
import ObjectAutocomplete from '$lib/components/lemmy/ObjectAutocomplete.svelte'
|
||||||
|
import Sort from '$lib/components/lemmy/Sort.svelte'
|
||||||
import CommentItem from '$lib/components/lemmy/comment/CommentItem.svelte'
|
import CommentItem from '$lib/components/lemmy/comment/CommentItem.svelte'
|
||||||
import CommunityItem from '$lib/components/lemmy/community/CommunityItem.svelte'
|
import CommunityItem from '$lib/components/lemmy/community/CommunityItem.svelte'
|
||||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||||
@@ -56,7 +57,7 @@
|
|||||||
>
|
>
|
||||||
<span slot="label" class="flex items-center gap-1">
|
<span slot="label" class="flex items-center gap-1">
|
||||||
<Icon src={AdjustmentsHorizontal} mini size="15" />
|
<Icon src={AdjustmentsHorizontal} mini size="15" />
|
||||||
Type
|
Filter
|
||||||
</span>
|
</span>
|
||||||
<option value="All">All</option>
|
<option value="All">All</option>
|
||||||
<option value="Posts">Posts</option>
|
<option value="Posts">Posts</option>
|
||||||
@@ -64,25 +65,27 @@
|
|||||||
<option value="Communities">Communities</option>
|
<option value="Communities">Communities</option>
|
||||||
<option value="Users">Users</option>
|
<option value="Users">Users</option>
|
||||||
</Select>
|
</Select>
|
||||||
|
<Sort navigate bind:selected={data.sort} />
|
||||||
<form
|
<form
|
||||||
class="flex flex-row gap-2 items-center ml-auto"
|
|
||||||
on:submit|preventDefault={() => searchParam($page.url, 'q', query, 'page')}
|
on:submit|preventDefault={() => searchParam($page.url, 'q', query, 'page')}
|
||||||
|
class="flex flex-col sm:flex-row gap-2 sm:ml-auto items-center"
|
||||||
>
|
>
|
||||||
<TextInput
|
<TextInput
|
||||||
label="Query"
|
|
||||||
bind:value={query}
|
bind:value={query}
|
||||||
placeholder="!community@instance.com"
|
placeholder="Search for a keyword..."
|
||||||
inlineAffixes
|
label="Query"
|
||||||
|
size="md"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
submit
|
||||||
|
color="secondary"
|
||||||
|
size="custom"
|
||||||
|
class="self-end"
|
||||||
|
style="width: 38px; height: 38px;"
|
||||||
|
title="Search"
|
||||||
>
|
>
|
||||||
<button
|
<Icon src={MagnifyingGlass} size="16" mini />
|
||||||
type="submit"
|
</Button>
|
||||||
aria-label="Search"
|
|
||||||
slot="suffix"
|
|
||||||
class="flex items-center"
|
|
||||||
>
|
|
||||||
<Icon src={MagnifyingGlass} size="20" mini />
|
|
||||||
</button>
|
|
||||||
</TextInput>
|
|
||||||
</form>
|
</form>
|
||||||
<Button
|
<Button
|
||||||
slot="summary"
|
slot="summary"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export async function load({ url, fetch }) {
|
|||||||
community_id: community ?? undefined,
|
community_id: community ?? undefined,
|
||||||
limit: 20,
|
limit: 20,
|
||||||
page: page,
|
page: page,
|
||||||
sort: (sort as SortType) || 'New',
|
sort: (sort as SortType) || 'TopAll',
|
||||||
listing_type: 'All',
|
listing_type: 'All',
|
||||||
type_: (type as SearchType) ?? 'All',
|
type_: (type as SearchType) ?? 'All',
|
||||||
})
|
})
|
||||||
@@ -37,10 +37,7 @@ export async function load({ url, fetch }) {
|
|||||||
results.communities,
|
results.communities,
|
||||||
]
|
]
|
||||||
|
|
||||||
const everything = [...posts, ...comments, ...users, ...communities].sort(
|
const everything = [...posts, ...comments, ...users, ...communities]
|
||||||
(a, b) =>
|
|
||||||
Date.parse(getItemPublished(b)) - Date.parse(getItemPublished(a))
|
|
||||||
)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: type,
|
type: type,
|
||||||
|
|||||||
Reference in new issue
Block a user