misc: tweak some sort handling
This commit is contained in:
1 parent
6e3be451b9
commit
ff89ec9fb5
8 files changed
+182
-62
No files matched your search
@@ -0,0 +1,51 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores'
|
||||
import { profile } from '$lib/auth'
|
||||
import { userSettings } from '$lib/settings'
|
||||
import { searchParam } from '$lib/util'
|
||||
import { Select } from 'mono-svelte'
|
||||
import { GlobeAmericas, Icon } from 'svelte-hero-icons'
|
||||
import { amModOfAny } from '../moderation/moderation'
|
||||
|
||||
export let selected: string
|
||||
export let navigate: boolean = true
|
||||
export let changeDefault: boolean = false
|
||||
export let showLabel: boolean = true
|
||||
|
||||
let feed: string = selected
|
||||
const setSelected = () => (selected = feed)
|
||||
$: changeDefault
|
||||
? ($userSettings.defaultSort.feed = selected as
|
||||
| 'All'
|
||||
| 'Subscribed'
|
||||
| 'Local')
|
||||
: undefined
|
||||
</script>
|
||||
|
||||
<Select
|
||||
{...$$restProps}
|
||||
bind:value={feed}
|
||||
on:change={() => {
|
||||
if (navigate) searchParam($page.url, 'type', feed, 'page', 'cursor')
|
||||
}}
|
||||
>
|
||||
<svelte:fragment slot="label">
|
||||
{#if showLabel}
|
||||
<span class="flex items-center gap-1">
|
||||
<Icon src={GlobeAmericas} size="16" mini />
|
||||
Location
|
||||
</span>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
<option value="All">All</option>
|
||||
<option value="Local">Local</option>
|
||||
<option value="Subscribed" disabled={$profile?.jwt == undefined}>
|
||||
Subscribed
|
||||
</option>
|
||||
<option
|
||||
value="ModeratorView"
|
||||
disabled={!$profile?.jwt || !amModOfAny($profile?.user)}
|
||||
>
|
||||
Moderator
|
||||
</option>
|
||||
</Select>
|
||||
@@ -7,7 +7,8 @@
|
||||
import type { SortType } from 'lemmy-js-client'
|
||||
import { Select } from 'mono-svelte'
|
||||
import { ChartBar, Clock, Icon } from 'svelte-hero-icons'
|
||||
import { fly } from 'svelte/transition'
|
||||
import { backOut } from 'svelte/easing'
|
||||
import { fly, slide } from 'svelte/transition'
|
||||
|
||||
export let selected: string
|
||||
export let navigate: boolean = true
|
||||
@@ -20,10 +21,38 @@
|
||||
: undefined
|
||||
</script>
|
||||
|
||||
<div class="flex flex-row gap-2 {$$props.class}">
|
||||
<div class="flex flex-row {$$props.class}">
|
||||
<Select
|
||||
{...$$restProps}
|
||||
class={selected?.startsWith('Top') ? 'rounded-r-none' : ''}
|
||||
bind:value={sort}
|
||||
on:change={(e) => {
|
||||
setSelected()
|
||||
if (navigate) searchParam($page.url, 'sort', selected, 'page', 'cursor')
|
||||
}}
|
||||
>
|
||||
<span slot="label" class="flex items-center gap-1">
|
||||
<Icon src={ChartBar} size="13" mini />
|
||||
Sort
|
||||
</span>
|
||||
<option value="Active">Active</option>
|
||||
<option value="Hot">Hot</option>
|
||||
{#if feature('scaledSort', $site?.version)}
|
||||
<option value="Scaled">Scaled</option>
|
||||
{/if}
|
||||
<option value="TopAll">Top</option>
|
||||
<option value="New">New</option>
|
||||
{#if feature('controversialSort', $site?.version)}
|
||||
<option value="Controversial">Controversial</option>
|
||||
{/if}
|
||||
<option value="Old">Old</option>
|
||||
<option value="MostComments">Comments</option>
|
||||
<option value="NewComments">New Replies</option>
|
||||
</Select>
|
||||
{#if selected?.startsWith('Top')}
|
||||
<div transition:fly={{ x: 4 }}>
|
||||
<div transition:fly={{ easing: backOut, x: 2 }}>
|
||||
<Select
|
||||
class="border-l-0 rounded-l-none"
|
||||
bind:value={selected}
|
||||
on:change={(e) => {
|
||||
sort = 'TopAll'
|
||||
@@ -48,29 +77,4 @@
|
||||
</Select>
|
||||
</div>
|
||||
{/if}
|
||||
<Select
|
||||
bind:value={sort}
|
||||
on:change={(e) => {
|
||||
setSelected()
|
||||
if (navigate) searchParam($page.url, 'sort', selected, 'page', 'cursor')
|
||||
}}
|
||||
>
|
||||
<span slot="label" class="flex items-center gap-1">
|
||||
<Icon src={ChartBar} size="13" mini />
|
||||
Sort
|
||||
</span>
|
||||
<option value="Active">Active</option>
|
||||
<option value="Hot">Hot</option>
|
||||
{#if feature('scaledSort', $site?.version)}
|
||||
<option value="Scaled">Scaled</option>
|
||||
{/if}
|
||||
<option value="TopAll">Top</option>
|
||||
<option value="New">New</option>
|
||||
{#if feature('controversialSort', $site?.version)}
|
||||
<option value="Controversial">Controversial</option>
|
||||
{/if}
|
||||
<option value="Old">Old</option>
|
||||
<option value="MostComments">Most Comments</option>
|
||||
<option value="NewComments">New Comments</option>
|
||||
</Select>
|
||||
</div>
|
||||
@@ -6,7 +6,7 @@
|
||||
export let showLabel = true
|
||||
</script>
|
||||
|
||||
<Select bind:value={$userSettings.view}>
|
||||
<Select {...$$restProps} bind:value={$userSettings.view}>
|
||||
<svelte:fragment slot="label">
|
||||
{#if showLabel}
|
||||
<span class="flex items-center gap-1">
|
||||
|
||||
Reference in new issue
Block a user