feat: use select menu for sort

This commit is contained in:
Xyphyn committed 2023-09-03 17:43:45 -07:00
1 parent 79d85cec9e
commit 7358486ee0
3 files changed
+68 -51

No files matched your search

+52 -44
View File
@@ -1,52 +1,60 @@
<script lang="ts"> <script lang="ts">
import { page } from '$app/stores' import { page } from '$app/stores'
import { searchParam } from '$lib/util.js' import { searchParam } from '$lib/util.js'
import MultiSelect from '../input/MultiSelect.svelte' import { Select } from 'mono-svelte'
import { ChartBar, Clock, Icon } from 'svelte-hero-icons'
import { fly } from 'svelte/transition'
export let selected: string export let selected: string
export let navigate: boolean = true export let navigate: boolean = true
let sort: string
const setSelected = () => (selected = sort)
</script> </script>
<MultiSelect <div class="flex flex-row gap-4 flex-wrap">
options={[ {#if selected?.startsWith('Top')}
'Active', <div class="w-32" transition:fly={{ x: 4 }}>
'Hot', <Select
'TopAll', bind:value={selected}
'New', on:change={(e) => {
'Old', sort = 'TopAll'
'TopNineMonths', if (navigate) searchParam($page.url, 'sort', selected, 'page')
'TopSixMonths', }}
'TopThreeMonths', >
'TopMonth', <span slot="label" class="flex items-center gap-1">
'TopWeek', <Icon src={Clock} size="16" mini />
'TopDay', Time
'TopTwelveHour', </span>
'TopSixHour', <option value="TopAll">All</option>
'TopHour', <option value="TopNineMonths">9 Months</option>
'MostComments', <option value="TopSixMonths">6 Months</option>
'NewComments', <option value="TopThreeMonths">3 Months</option>
]} <option value="TopMonth">Month</option>
optionNames={[ <option value="TopWeek">Week</option>
'Active', <option value="TopDay">Day</option>
'Hot', <option value="TopTwelveHour">12 Hours</option>
'Top', <option value="TopSixHour">6 Hours</option>
'New', <option value="TopHour">Hour</option>
'Old', </Select>
'Top 9 Months', </div>
'Top 6 Months', {/if}
'Top 3 Months', <Select
'Top Month', bind:value={sort}
'Top Week', on:change={(e) => {
'Top Day', setSelected()
'Top 12 Hours', if (navigate) searchParam($page.url, 'sort', selected, 'page')
'Top 6 Hours', }}
'Top Hour', class="w-32"
'Most Comments', >
'New Comments', <span slot="label" class="flex items-center gap-1">
]} <Icon src={ChartBar} size="14" mini />
bind:selected Sort
on:select={(e) => { </span>
if (navigate) searchParam($page.url, 'sort', e.detail, 'page') <option value="Active">Active</option>
}} <option value="Hot">Hot</option>
class="w-full" <option value="TopAll">Top</option>
/> <option value="New">New</option>
<option value="Old">Old</option>
</Select>
</div>
+16 -7
View File
@@ -9,7 +9,8 @@
import Sort from '$lib/components/lemmy/Sort.svelte' import Sort from '$lib/components/lemmy/Sort.svelte'
import { searchParam } from '$lib/util.js' import { searchParam } from '$lib/util.js'
import PostFeed from '$lib/components/lemmy/post/PostFeed.svelte' import PostFeed from '$lib/components/lemmy/post/PostFeed.svelte'
import { Button, Modal } from 'mono-svelte' import { Button, Modal, Select } from 'mono-svelte'
import { GlobeAmericas, Icon } from 'svelte-hero-icons'
export let data export let data
@@ -40,12 +41,20 @@
<div <div
class="flex flex-row gap-4 max-w-full w-full justify-between flex-wrap" class="flex flex-row gap-4 max-w-full w-full justify-between flex-wrap"
> >
<MultiSelect <Select
options={['Subscribed', 'Local', 'All']} bind:value={data.listingType}
disabled={[$profile?.jwt == undefined]} on:change={() =>
selected={data.listingType} searchParam($page.url, 'type', data.listingType, 'page')}
on:select={(e) => searchParam($page.url, 'type', e.detail, 'page')} class="w-28"
/> >
<span slot="label" class="flex items-center gap-1">
<Icon src={GlobeAmericas} size="16" mini />
Location
</span>
<option value="All">All</option>
<option value="Local">Local</option>
<option value="Subscribed">Subscribed</option>
</Select>
<Sort selected={data.sort} /> <Sort selected={data.sort} />
</div> </div>
<section class="flex flex-col gap-3 sm:gap-4 h-full"> <section class="flex flex-col gap-3 sm:gap-4 h-full">
Binary file not shown.