* cleanup: postactions styling * misc: fix first round of errors * pkg: remove vitest * fix: fix lint errors stage 2 * fix: fix lint errors stage 3 * fix: fix lint errors, stage 3 * misc: update eslint rules to warn for writable derived
67 lines
1.7 KiB
Svelte
67 lines
1.7 KiB
Svelte
<script lang="ts">
|
|
import { page } from '$app/state'
|
|
import { profile } from '$lib/auth.svelte'
|
|
import { searchParam } from '$lib/util.svelte'
|
|
import { Select } from 'mono-svelte'
|
|
import {
|
|
GlobeAmericas,
|
|
Icon,
|
|
MapPin,
|
|
Newspaper,
|
|
ShieldCheck,
|
|
} from 'svelte-hero-icons'
|
|
import { amModOfAny } from '../moderation/moderation'
|
|
import { t } from '$lib/i18n/translations'
|
|
import Option from 'mono-svelte/forms/select/Option.svelte'
|
|
import type { SelectProps } from 'mono-svelte/forms/select/Select.svelte'
|
|
|
|
interface Props extends SelectProps<string> {
|
|
selected: string
|
|
navigate?: boolean
|
|
changeDefault?: boolean
|
|
showLabel?: boolean
|
|
}
|
|
|
|
let {
|
|
selected = $bindable(),
|
|
navigate = true,
|
|
showLabel = true,
|
|
...rest
|
|
}: Props = $props()
|
|
</script>
|
|
|
|
<Select
|
|
{...rest}
|
|
bind:value={selected}
|
|
onchange={() => {
|
|
if (navigate) searchParam(page.url, 'type', selected, 'page', 'cursor')
|
|
}}
|
|
>
|
|
{#snippet customLabel()}
|
|
{#if showLabel}
|
|
<span class="flex items-center gap-1">
|
|
<Icon src={GlobeAmericas} size="16" micro />
|
|
{$t('filter.location.label')}
|
|
</span>
|
|
{/if}
|
|
{/snippet}
|
|
<Option value="All" icon={GlobeAmericas}>
|
|
{$t('filter.location.all')}
|
|
</Option>
|
|
<Option value="Local" icon={MapPin}>{$t('filter.location.local')}</Option>
|
|
<Option
|
|
value="Subscribed"
|
|
disabled={profile.data?.jwt == undefined}
|
|
icon={Newspaper}
|
|
>
|
|
{$t('filter.location.subscribed')}
|
|
</Option>
|
|
<Option
|
|
value="ModeratorView"
|
|
disabled={!profile.data?.jwt || !amModOfAny(profile.data?.user)}
|
|
icon={ShieldCheck}
|
|
>
|
|
{$t('filter.location.moderator')}
|
|
</Option>
|
|
</Select>
|