impr: improve community experience
This commit is contained in:
1 parent
815a6d2385
commit
4c7ae5d781
6 files changed
+51
-38
No files matched your search
@@ -51,7 +51,7 @@
|
|||||||
community.community.name,
|
community.community.name,
|
||||||
community.community.actor_id
|
community.community.actor_id
|
||||||
)}"
|
)}"
|
||||||
class="flex-1"
|
class="flex-1 w-full overflow-hidden"
|
||||||
data-sveltekit-preload-data="tap"
|
data-sveltekit-preload-data="tap"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
color="transparent"
|
color="transparent"
|
||||||
padding="none"
|
padding="none"
|
||||||
rounding="xl"
|
rounding="xl"
|
||||||
class="z-10 relative"
|
class="z-10 relative border-slate-200 dark:border-zinc-700"
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
>
|
>
|
||||||
{#if banner}
|
{#if banner}
|
||||||
|
|||||||
@@ -217,7 +217,10 @@
|
|||||||
},
|
},
|
||||||
"translators": "Translators",
|
"translators": "Translators",
|
||||||
"accounts": "Accounts",
|
"accounts": "Accounts",
|
||||||
"communities": "Communities",
|
"communities": {
|
||||||
|
"title": "Communities",
|
||||||
|
"trending": "Trending"
|
||||||
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"title": "Search",
|
"title": "Search",
|
||||||
"federating": "Federating",
|
"federating": "Federating",
|
||||||
|
|||||||
@@ -115,13 +115,13 @@
|
|||||||
community.community.actor_id
|
community.community.actor_id
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
<div class="flex items-center gap-2" slot="actions">
|
<div class="flex items-center gap-2 h-max">
|
||||||
{#if $profile?.jwt}
|
{#if $profile?.jwt}
|
||||||
<Subscribe let:subscribe bind:community let:subscribing>
|
<Subscribe let:subscribe bind:community let:subscribing>
|
||||||
<Button
|
<Button
|
||||||
disabled={subscribing}
|
disabled={subscribing}
|
||||||
loading={subscribing}
|
loading={subscribing}
|
||||||
size="md"
|
size="lg"
|
||||||
color={community.subscribed == 'NotSubscribed'
|
color={community.subscribed == 'NotSubscribed'
|
||||||
? 'primary'
|
? 'primary'
|
||||||
: 'secondary'}
|
: 'secondary'}
|
||||||
@@ -137,7 +137,7 @@
|
|||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
src={community.subscribed != 'NotSubscribed' ? Check : Plus}
|
src={community.subscribed != 'NotSubscribed' ? Check : Plus}
|
||||||
mini
|
micro
|
||||||
size="16"
|
size="16"
|
||||||
slot="prefix"
|
slot="prefix"
|
||||||
/>
|
/>
|
||||||
@@ -149,27 +149,31 @@
|
|||||||
</Subscribe>
|
</Subscribe>
|
||||||
{/if}
|
{/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
|
{#if $profile?.user && $profile.user.moderates
|
||||||
.map((c) => c.community.id)
|
.map((c) => c.community.id)
|
||||||
.includes(community.community.id)}
|
.includes(community.community.id)}
|
||||||
<Button
|
<Button
|
||||||
size="square-md"
|
size="square-lg"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
|
rounding="xl"
|
||||||
href="/c/{fullCommunityName(
|
href="/c/{fullCommunityName(
|
||||||
community.community.name,
|
community.community.name,
|
||||||
community.community.actor_id
|
community.community.actor_id
|
||||||
)}/settings"
|
)}/settings"
|
||||||
|
style="height: 38px; width: 38px;"
|
||||||
>
|
>
|
||||||
<Icon src={Cog6Tooth} size="16" mini />
|
<Icon src={Cog6Tooth} size="16" mini />
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
<Button
|
|
||||||
size="square-md"
|
|
||||||
color="secondary"
|
|
||||||
on:click={() => (sidebar = !sidebar)}
|
|
||||||
>
|
|
||||||
<Icon src={InformationCircle} size="16" mini />
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</EntityHeader>
|
</EntityHeader>
|
||||||
<Sort selected={data.sort} />
|
<Sort selected={data.sort} />
|
||||||
|
|||||||
@@ -9,7 +9,14 @@
|
|||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import Pageination from '$lib/components/ui/Pageination.svelte'
|
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||||
import { searchParam } from '$lib/util.js'
|
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 Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
||||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||||
import CommunityItem from '$lib/components/lemmy/community/CommunityItem.svelte'
|
import CommunityItem from '$lib/components/lemmy/community/CommunityItem.svelte'
|
||||||
@@ -32,11 +39,11 @@
|
|||||||
<svelte:window bind:scrollY={offset} />
|
<svelte:window bind:scrollY={offset} />
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>{$t('routes.communities')}</title>
|
<title>{$t('routes.communities.title')}</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<Header pageHeader class="justify-between">
|
<Header pageHeader class="justify-between">
|
||||||
<span>{$t('routes.communities')}</span>
|
<span>{$t('routes.communities.title')}</span>
|
||||||
<Popover
|
<Popover
|
||||||
openOnHover
|
openOnHover
|
||||||
class="!inline-flex"
|
class="!inline-flex"
|
||||||
@@ -133,17 +140,17 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/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">
|
<SectionTitle class="!border-0 pb-2">
|
||||||
{$t('routes.search.other')}
|
{$t('routes.search.other')}
|
||||||
</SectionTitle>
|
</SectionTitle>
|
||||||
{/if}
|
{/if}
|
||||||
{#if data.communities}
|
{#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}>
|
<div class="-mx-4 sm:-mx-6 h-full" bind:this={virtualList}>
|
||||||
{#each sliced as community}
|
{#each sliced as community}
|
||||||
<div
|
<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"
|
border-b border-slate-100 dark:border-zinc-800"
|
||||||
>
|
>
|
||||||
<CommunityItem {community} showCounts={false} class="py-3" />
|
<CommunityItem {community} showCounts={false} class="py-3" />
|
||||||
|
|||||||
@@ -1,44 +1,43 @@
|
|||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import { LINKED_INSTANCE_URL } from '$lib/instance.js'
|
import { LINKED_INSTANCE_URL } from '$lib/instance.js'
|
||||||
import { getClient } from '$lib/lemmy.js'
|
import { client, getClient } from '$lib/lemmy.js'
|
||||||
import type { ListingType, SortType } from 'lemmy-js-client'
|
import {
|
||||||
|
type ListCommunitiesResponse,
|
||||||
|
type ListingType,
|
||||||
|
type SortType,
|
||||||
|
} from 'lemmy-js-client'
|
||||||
import { get } from 'svelte/store'
|
import { get } from 'svelte/store'
|
||||||
|
|
||||||
export async function load({ url, fetch }) {
|
export async function load({ url, fetch }) {
|
||||||
const type =
|
const type =
|
||||||
(url.searchParams.get('type') as ListingType) ||
|
(url.searchParams.get('type') as ListingType) ||
|
||||||
(LINKED_INSTANCE_URL ? 'Local' : 'All')
|
(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 page = Number(url.searchParams.get('page')) || 1
|
||||||
const query = url.searchParams.get('q')
|
const query = url.searchParams.get('q') || ''
|
||||||
|
|
||||||
if (query) {
|
const communities =
|
||||||
return {
|
query != ''
|
||||||
...(await getClient(undefined, fetch).search({
|
? await getClient(undefined, fetch).search({
|
||||||
limit: 40,
|
limit: 40,
|
||||||
page: page,
|
page: page,
|
||||||
sort: sort,
|
sort: sort,
|
||||||
type_: 'Communities',
|
type_: 'Communities',
|
||||||
listing_type: type,
|
listing_type: type,
|
||||||
q: query,
|
q: query,
|
||||||
})),
|
})
|
||||||
type: type,
|
: await getClient(undefined, fetch).listCommunities({
|
||||||
sort: sort,
|
|
||||||
query: query,
|
|
||||||
page: page,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
...(await getClient(undefined, fetch).listCommunities({
|
|
||||||
limit: 40,
|
limit: 40,
|
||||||
page: page,
|
page: page,
|
||||||
sort: sort,
|
sort: sort,
|
||||||
type_: type,
|
type_: type,
|
||||||
})),
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
...communities,
|
||||||
type: type,
|
type: type,
|
||||||
sort: sort,
|
sort: sort,
|
||||||
query: query,
|
query: query,
|
||||||
page: page,
|
page: page,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Reference in new issue
Block a user