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

+15 -11
View File
@@ -115,13 +115,13 @@
community.community.actor_id
)}
</button>
<div class="flex items-center gap-2" slot="actions">
<div class="flex items-center gap-2 h-max">
{#if $profile?.jwt}
<Subscribe let:subscribe bind:community let:subscribing>
<Button
disabled={subscribing}
loading={subscribing}
size="md"
size="lg"
color={community.subscribed == 'NotSubscribed'
? 'primary'
: 'secondary'}
@@ -137,7 +137,7 @@
>
<Icon
src={community.subscribed != 'NotSubscribed' ? Check : Plus}
mini
micro
size="16"
slot="prefix"
/>
@@ -149,27 +149,31 @@
</Subscribe>
{/if}
<Button
size="lg"
color="secondary"
class="flex-1"
on:click={() => (sidebar = !sidebar)}
>
<Icon src={InformationCircle} size="16" micro />
{$t('cards.site.about')}
</Button>
{#if $profile?.user && $profile.user.moderates
.map((c) => c.community.id)
.includes(community.community.id)}
<Button
size="square-md"
size="square-lg"
color="secondary"
rounding="xl"
href="/c/{fullCommunityName(
community.community.name,
community.community.actor_id
)}/settings"
style="height: 38px; width: 38px;"
>
<Icon src={Cog6Tooth} size="16" mini />
</Button>
{/if}
<Button
size="square-md"
color="secondary"
on:click={() => (sidebar = !sidebar)}
>
<Icon src={InformationCircle} size="16" mini />
</Button>
</div>
</EntityHeader>
<Sort selected={data.sort} />
+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,
}
}