feat: add dropdown to multiselect

This commit is contained in:
Xyphyn committed 2023-08-04 14:37:32 -07:00
1 parent af1bdf194c
commit dc1aba6c17
8 files changed
+107 -62

No files matched your search

+4 -20
View File
@@ -12,6 +12,8 @@
import Pageination from '$lib/components/ui/Pageination.svelte'
import Modal from '$lib/components/ui/modal/Modal.svelte'
import { profile } from '$lib/auth.js'
import Sort from '$lib/components/lemmy/Sort.svelte'
import { searchParam } from '$lib/util.js'
export let data
@@ -54,20 +56,7 @@
})
}}
/>
<MultiSelect
options={['Active', 'Hot', 'TopAll', 'New', 'Old']}
optionNames={['Active', 'Hot', 'Top', 'New', 'Old']}
selected={data.sort}
on:select={(e) => {
const url = $page.url
url.searchParams.set('sort', e.detail)
url.searchParams.delete('page')
goto(url, {
invalidateAll: true,
})
}}
class="w-full md:max-w-[20rem]"
/>
<Sort selected={data.sort} />
</div>
<section class="flex flex-col gap-4">
{#if data.posts.posts.length == 0}
@@ -99,12 +88,7 @@
</section>
<Pageination
page={data.page}
on:change={(p) => {
$page.url.searchParams.set('page', p.detail.toString())
goto($page.url.toString(), {
invalidateAll: true,
})
}}
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
/>
</div>
<aside class="hidden xl:block">
+4 -20
View File
@@ -13,6 +13,8 @@
import Modal from '$lib/components/ui/modal/Modal.svelte'
import Pageination from '$lib/components/ui/Pageination.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
import Sort from '$lib/components/lemmy/Sort.svelte'
import { searchParam } from '$lib/util.js'
export let data
@@ -61,20 +63,7 @@
</Button>
</div>
<div class="flex flex-col sm:flex-row gap-4 max-w-full w-full">
<MultiSelect
options={['Active', 'Hot', 'TopAll', 'New', 'Old']}
optionNames={['Active', 'Hot', 'Top', 'New', 'Old']}
selected={$page.url.searchParams.get('sort') ??
$userSettings.defaultSort.sort}
on:select={(e) => {
const url = $page.url
url.searchParams.set('sort', e.detail)
url.searchParams.delete('page')
goto(url, {
invalidateAll: true,
})
}}
/>
<Sort selected={data.sort} />
</div>
{#each data.posts.posts as post, index (post.post.id)}
<div in:fly={{ y: -8, opacity: 0, delay: index < 4 ? index * 100 : 0 }}>
@@ -83,12 +72,7 @@
{/each}
<Pageination
page={data.page}
on:change={(p) => {
$page.url.searchParams.set('page', p.detail.toString())
goto($page.url.toString(), {
invalidateAll: true,
})
}}
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
/>
</div>
<div class="hidden xl:block">