impr: improve community experience

This commit is contained in:
Xylight committed 2024-09-06 16:23:47 -07:00
1 parent 815a6d2385
commit 4c7ae5d781
6 files changed
+65 -52

No files matched your search

+13 -6
View File
@@ -9,7 +9,14 @@
} from 'svelte-hero-icons'
import Pageination from '$lib/components/ui/Pageination.svelte'
import { searchParam } from '$lib/util.js'
import { Button, Material, Popover, Select, TextInput } from 'mono-svelte'
import {
Button,
Material,
Popover,
Select,
Spinner,
TextInput,
} from 'mono-svelte'
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import CommunityItem from '$lib/components/lemmy/community/CommunityItem.svelte'
@@ -32,11 +39,11 @@
<svelte:window bind:scrollY={offset} />
<svelte:head>
<title>{$t('routes.communities')}</title>
<title>{$t('routes.communities.title')}</title>
</svelte:head>
<Header pageHeader class="justify-between">
<span>{$t('routes.communities')}</span>
<span>{$t('routes.communities.title')}</span>
<Popover
openOnHover
class="!inline-flex"
@@ -133,17 +140,17 @@
</div>
{/if}
{#if data.communities.slice(data.query ?? '' != '' ? 3 : 0).length > 0}
{#if data.communities.slice((data.query ?? '' != '') ? 3 : 0).length > 0}
<SectionTitle class="!border-0 pb-2">
{$t('routes.search.other')}
</SectionTitle>
{/if}
{#if data.communities}
{@const sliced = data.communities.slice(data.query ?? '' != '' ? 3 : 0)}
{@const sliced = data.communities.slice((data.query ?? '' != '') ? 3 : 0)}
<div class="-mx-4 sm:-mx-6 h-full" bind:this={virtualList}>
{#each sliced as community}
<div
class="px-6 hover:bg-slate-100 hover:dark:bg-zinc-900 transition-colors @container
class="px-6 hover:bg-slate-50 hover:dark:bg-zinc-900 transition-colors @container
border-b border-slate-100 dark:border-zinc-800"
>
<CommunityItem {community} showCounts={false} class="py-3" />
+31 -32
View File
@@ -1,44 +1,43 @@
import { profile } from '$lib/auth.js'
import { LINKED_INSTANCE_URL } from '$lib/instance.js'
import { getClient } from '$lib/lemmy.js'
import type { ListingType, SortType } from 'lemmy-js-client'
import { client, getClient } from '$lib/lemmy.js'
import {
type ListCommunitiesResponse,
type ListingType,
type SortType,
} from 'lemmy-js-client'
import { get } from 'svelte/store'
export async function load({ url, fetch }) {
const type =
(url.searchParams.get('type') as ListingType) ||
(LINKED_INSTANCE_URL ? 'Local' : 'All')
const sort = (url.searchParams.get('sort') as SortType) || 'TopAll'
const sort = (url.searchParams.get('sort') as SortType) || 'TopDay'
const page = Number(url.searchParams.get('page')) || 1
const query = url.searchParams.get('q')
const query = url.searchParams.get('q') || ''
if (query) {
return {
...(await getClient(undefined, fetch).search({
limit: 40,
page: page,
sort: sort,
type_: 'Communities',
listing_type: type,
q: query,
})),
type: type,
sort: sort,
query: query,
page: page,
}
} else {
return {
...(await getClient(undefined, fetch).listCommunities({
limit: 40,
page: page,
sort: sort,
type_: type,
})),
type: type,
sort: sort,
query: query,
page: page,
}
const communities =
query != ''
? await getClient(undefined, fetch).search({
limit: 40,
page: page,
sort: sort,
type_: 'Communities',
listing_type: type,
q: query,
})
: await getClient(undefined, fetch).listCommunities({
limit: 40,
page: page,
sort: sort,
type_: type,
})
return {
...communities,
type: type,
sort: sort,
query: query,
page: page,
}
}