design: improve communities page
This commit is contained in:
1 parent
e8f5d743d8
commit
f54c444fe6
6 files changed
+194
-52
No files matched your search
@@ -24,32 +24,62 @@
|
|||||||
import Entity from '$lib/components/ui/Entity.svelte'
|
import Entity from '$lib/components/ui/Entity.svelte'
|
||||||
|
|
||||||
export let community: CommunityView
|
export let community: CommunityView
|
||||||
|
export let view: 'cozy' | 'compact' = 'compact'
|
||||||
|
export let showCounts: boolean = true
|
||||||
|
|
||||||
let showInfo = false
|
let showInfo = false
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if showInfo}
|
{#if showInfo}
|
||||||
<Modal title={$t('routes.community.title')} bind:open={showInfo}>
|
<Modal title={$t('form.post.community')} bind:open={showInfo}>
|
||||||
<CommunityCard community_view={community} />
|
<CommunityCard community_view={community} />
|
||||||
</Modal>
|
</Modal>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="py-4 flex flex-col gap-2 text-sm max-w-full relative">
|
<div
|
||||||
<div class="flex flex-row items-center max-w-full w-full">
|
class={$$props.class ??
|
||||||
|
'py-4 flex flex-col gap-4 text-sm max-w-full relative'}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="flex
|
||||||
|
{view == 'cozy'
|
||||||
|
? 'flex-col gap-2'
|
||||||
|
: 'flex-row'} items-center max-w-full w-full"
|
||||||
|
>
|
||||||
<a
|
<a
|
||||||
href="/c/{fullCommunityName(
|
href="/c/{fullCommunityName(
|
||||||
community.community.name,
|
community.community.name,
|
||||||
community.community.actor_id
|
community.community.actor_id
|
||||||
)}"
|
)}"
|
||||||
class="hover:underline"
|
class="flex-1"
|
||||||
>
|
>
|
||||||
<Entity
|
<div
|
||||||
icon={community.community.icon}
|
class="flex {view == 'cozy'
|
||||||
label={new URL(community.community.actor_id).hostname}
|
? 'flex-col gap-2'
|
||||||
name={community.community.title}
|
: 'flex-row'} gap-2 items-center"
|
||||||
></Entity>
|
>
|
||||||
|
<slot name="icon">
|
||||||
|
<Avatar
|
||||||
|
url={community.community.icon}
|
||||||
|
width={32}
|
||||||
|
alt={community.community.name}
|
||||||
|
/>
|
||||||
|
</slot>
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<div class="font-medium text-base">
|
||||||
|
{community.community.title}
|
||||||
|
</div>
|
||||||
|
<div class="text-sm text-slate-600 dark:text-zinc-400">
|
||||||
|
<span>{new URL(community.community.actor_id).hostname}</span>
|
||||||
|
{#if !showCounts}
|
||||||
|
•
|
||||||
|
<FormattedNumber number={community.counts.subscribers} />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<div class="ml-auto flex flex-row items-center gap-2">
|
<div class="flex flex-row items-center gap-2">
|
||||||
<Button size="square-md" on:click={() => (showInfo = !showInfo)}>
|
<Button size="square-md" on:click={() => (showInfo = !showInfo)}>
|
||||||
<Icon src={InformationCircle} size="16" micro />
|
<Icon src={InformationCircle} size="16" micro />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -93,8 +123,8 @@
|
|||||||
</Subscribe>
|
</Subscribe>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{#if community.counts}
|
{#if showCounts}
|
||||||
<div class="flex flex-row gap-3 items-center">
|
<div class="flex flex-row gap-3 items-center justify-center">
|
||||||
{#if community.counts.posts}
|
{#if community.counts.posts}
|
||||||
<LabelStat
|
<LabelStat
|
||||||
content={community.counts.posts.toString()}
|
content={community.counts.posts.toString()}
|
||||||
|
|||||||
@@ -7,29 +7,61 @@
|
|||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||||
|
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
||||||
|
import { userLink } from '$lib/lemmy/generic'
|
||||||
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
|
|
||||||
export let user: PersonView
|
export let user: PersonView
|
||||||
|
export let view: 'cozy' | 'compact' = 'compact'
|
||||||
|
export let showCounts: boolean = true
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="py-2
|
class={$$props.class ??
|
||||||
flex flex-col gap-3 text-sm max-w-full"
|
'py-4 flex flex-col gap-4 text-sm max-w-full relative'}
|
||||||
>
|
>
|
||||||
<div class="flex flex-row items-center">
|
<div
|
||||||
<span
|
class="flex
|
||||||
class="break-words max-w-full w-max text-base font-bold text-sky-400 hover:underline"
|
{view == 'cozy'
|
||||||
|
? 'flex-col gap-2'
|
||||||
|
: 'flex-row'} items-center max-w-full w-full"
|
||||||
>
|
>
|
||||||
<UserLink avatar user={user.person} />
|
<a href={userLink(user.person)} class="flex-1">
|
||||||
</span>
|
<div
|
||||||
|
class="flex {view == 'cozy'
|
||||||
|
? 'flex-col gap-2'
|
||||||
|
: 'flex-row'} gap-2 items-center"
|
||||||
|
>
|
||||||
|
<slot name="icon">
|
||||||
|
<Avatar url={user.person.avatar} width={32} alt={user.person.name} />
|
||||||
|
</slot>
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<div class="font-medium text-base">
|
||||||
|
{user.person.display_name ?? user.person.name}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row gap-3 items-center">
|
<div class="text-sm text-slate-600 dark:text-zinc-400">
|
||||||
<div class="flex flex-row gap-1 items-center" title="Post count">
|
{new URL(user.person.actor_id).hostname}
|
||||||
<Icon src={PencilSquare} mini width={16} />
|
|
||||||
<FormattedNumber number={user.counts.post_count} />
|
|
||||||
</div>
|
|
||||||
<div class="flex flex-row gap-1 items-center" title="Comment count">
|
|
||||||
<Icon src={ChatBubbleOvalLeftEllipsis} mini width={16} />
|
|
||||||
<FormattedNumber number={user.counts.comment_count} />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{#if showCounts}
|
||||||
|
<div class="flex flex-row gap-3 items-center justify-center">
|
||||||
|
{#if user.counts.post_count}
|
||||||
|
<LabelStat
|
||||||
|
content={user.counts.post_count.toString()}
|
||||||
|
formatted
|
||||||
|
label="Posts"
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
{#if user.counts.comment_count}
|
||||||
|
<LabelStat
|
||||||
|
content={user.counts.comment_count.toString()}
|
||||||
|
formatted
|
||||||
|
label="Comments"
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
@@ -226,7 +226,9 @@
|
|||||||
"title": "No Results",
|
"title": "No Results",
|
||||||
"description": "There are no results that match that filter. Try refining your search.",
|
"description": "There are no results that match that filter. Try refining your search.",
|
||||||
"alt": "Search across the fediverse"
|
"alt": "Search across the fediverse"
|
||||||
}
|
},
|
||||||
|
"top": "Top results",
|
||||||
|
"other": "Other results"
|
||||||
},
|
},
|
||||||
"saved": "Saved",
|
"saved": "Saved",
|
||||||
"createPost": "Create Post",
|
"createPost": "Create Post",
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
|
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
|
||||||
import { t } from '$lib/translations.js'
|
import { t } from '$lib/translations.js'
|
||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||||
|
import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte'
|
||||||
|
import { contentPadding } from '$lib/components/ui/layout/Shell.svelte'
|
||||||
|
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
||||||
|
|
||||||
export let data
|
export let data
|
||||||
|
|
||||||
@@ -55,35 +58,41 @@
|
|||||||
</p>
|
</p>
|
||||||
</Material>
|
</Material>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
</Header>
|
||||||
|
<div
|
||||||
|
class="mt-4 mb-0 sticky z-30"
|
||||||
|
style="top: max(1.5rem, {$contentPadding.top}px);"
|
||||||
|
>
|
||||||
|
<Tabs routes={[]} class="p-2 dark:bg-zinc-925/70">
|
||||||
<form
|
<form
|
||||||
on:submit|preventDefault={() => searchParam($page.url, 'q', search, 'page')}
|
on:submit|preventDefault={() =>
|
||||||
class="flex gap-2 flex-row items-center"
|
searchParam($page.url, 'q', search, 'page')}
|
||||||
slot="extended"
|
class="flex gap-2 flex-row items-center w-full text-base h-10"
|
||||||
>
|
>
|
||||||
<TextInput
|
<TextInput
|
||||||
bind:value={search}
|
bind:value={search}
|
||||||
aria-label={$t('routes.search.query')}
|
aria-label={$t('routes.search.query')}
|
||||||
size="md"
|
size="lg"
|
||||||
class="flex-1"
|
class="flex-1 !rounded-full h-full !text-base"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
submit
|
submit
|
||||||
color="secondary"
|
color="secondary"
|
||||||
size="custom"
|
size="custom"
|
||||||
class="self-end"
|
class="flex-shrink-0 h-full aspect-square"
|
||||||
style="width: 38px; height: 38px;"
|
|
||||||
title="Search"
|
title="Search"
|
||||||
|
rounding="pill"
|
||||||
>
|
>
|
||||||
<Icon src={MagnifyingGlass} size="16" mini />
|
<Icon src={MagnifyingGlass} size="16" mini />
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
</Header>
|
</Tabs>
|
||||||
|
</div>
|
||||||
<div class="flex flex-row flex-wrap gap-4 mt-4 items-center">
|
<div class="flex flex-row flex-wrap gap-4 mt-4 items-center">
|
||||||
<Location selected={data.type} />
|
<Location selected={data.type} />
|
||||||
<Sort selected={data.sort} />
|
<Sort selected={data.sort} />
|
||||||
</div>
|
</div>
|
||||||
<ul class="flex flex-col divide-y divide-slate-200 dark:divide-zinc-800">
|
<ul class="flex flex-col divide-y divide-slate-200 dark:divide-zinc-800 my-6">
|
||||||
{#if data.communities.length == 0}
|
{#if data.communities.length == 0}
|
||||||
<Placeholder
|
<Placeholder
|
||||||
icon={QuestionMarkCircle}
|
icon={QuestionMarkCircle}
|
||||||
@@ -91,8 +100,43 @@
|
|||||||
description={$t('routes.search.noResults.description')}
|
description={$t('routes.search.noResults.description')}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{#each data.communities as community}
|
|
||||||
<CommunityItem {community} />
|
{#if (data.query ?? '' != '') && data.communities.length > 0}
|
||||||
|
<SectionTitle class="!border-0 pb-2">
|
||||||
|
{$t('routes.search.top')}
|
||||||
|
</SectionTitle>
|
||||||
|
<div
|
||||||
|
class="grid md:grid-cols-2 lg:grid-cols-3 gap-4 items-center mb-6 !border-0"
|
||||||
|
>
|
||||||
|
{#each data.communities.slice(0, 3) as community}
|
||||||
|
<Material
|
||||||
|
color="distinct"
|
||||||
|
padding="none"
|
||||||
|
rounding="xl"
|
||||||
|
class="dark:border-t-zinc-800 h-full"
|
||||||
|
>
|
||||||
|
<CommunityItem
|
||||||
|
{community}
|
||||||
|
showCounts={false}
|
||||||
|
class="w-full p-4 text-center"
|
||||||
|
view="cozy"
|
||||||
|
/>
|
||||||
|
</Material>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if data.communities.slice(data.query ?? '' != '' ? 3 : 0).length > 0}
|
||||||
|
<SectionTitle class="!border-0 pb-2">
|
||||||
|
{$t('routes.search.other')}
|
||||||
|
</SectionTitle>
|
||||||
|
{/if}
|
||||||
|
{#each data.communities.slice(data.query ?? '' != '' ? 3 : 0) as community}
|
||||||
|
<div
|
||||||
|
class="-mx-4 sm:-mx-6 px-6 hover:bg-slate-100 hover:dark:bg-zinc-800 transition-colors"
|
||||||
|
>
|
||||||
|
<CommunityItem {community} showCounts={false} class="py-3" />
|
||||||
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
{#if data.communities.length > 0}
|
{#if data.communities.length > 0}
|
||||||
|
|||||||
@@ -35,6 +35,8 @@
|
|||||||
import { slide } from 'svelte/transition'
|
import { slide } from 'svelte/transition'
|
||||||
import { t } from '$lib/translations.js'
|
import { t } from '$lib/translations.js'
|
||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||||
|
import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte'
|
||||||
|
import { contentPadding } from '$lib/components/ui/layout/Shell.svelte'
|
||||||
|
|
||||||
type Result = PostView | CommentView | PersonView | CommunityView
|
type Result = PostView | CommentView | PersonView | CommunityView
|
||||||
|
|
||||||
@@ -53,29 +55,36 @@
|
|||||||
|
|
||||||
<Header pageHeader>
|
<Header pageHeader>
|
||||||
{$t('routes.search.title')}
|
{$t('routes.search.title')}
|
||||||
|
</Header>
|
||||||
|
<div
|
||||||
|
class="mt-4 mb-0 sticky z-30"
|
||||||
|
style="top: max(1.5rem, {$contentPadding.top}px);"
|
||||||
|
>
|
||||||
|
<Tabs routes={[]} class="p-2 dark:bg-zinc-925/70">
|
||||||
<form
|
<form
|
||||||
on:submit|preventDefault={() => searchParam($page.url, 'q', query, 'page')}
|
on:submit|preventDefault={() =>
|
||||||
class="flex flex-row gap-2 items-center"
|
searchParam($page.url, 'q', query, 'page')}
|
||||||
slot="extended"
|
class="flex gap-2 flex-row items-center w-full text-base h-10"
|
||||||
>
|
>
|
||||||
<TextInput
|
<TextInput
|
||||||
bind:value={query}
|
bind:value={query}
|
||||||
aria-label={$t('routes.search.query')}
|
aria-label={$t('routes.search.query')}
|
||||||
size="md"
|
size="lg"
|
||||||
class="flex-1 rounded-lg"
|
class="flex-1 !rounded-full h-full !text-base"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
submit
|
submit
|
||||||
color="secondary"
|
color="secondary"
|
||||||
size="custom"
|
size="custom"
|
||||||
class="self-end"
|
class="flex-shrink-0 h-full aspect-square"
|
||||||
style="width: 38px; height: 38px;"
|
|
||||||
title="Search"
|
title="Search"
|
||||||
|
rounding="pill"
|
||||||
>
|
>
|
||||||
<Icon src={MagnifyingGlass} size="16" mini />
|
<Icon src={MagnifyingGlass} size="16" mini />
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
</Header>
|
</Tabs>
|
||||||
|
</div>
|
||||||
<div class="flex flex-row flex-wrap items-center gap-4 mt-4">
|
<div class="flex flex-row flex-wrap items-center gap-4 mt-4">
|
||||||
<Select
|
<Select
|
||||||
bind:value={data.type}
|
bind:value={data.type}
|
||||||
@@ -136,7 +145,15 @@
|
|||||||
{#if object}
|
{#if object}
|
||||||
<div transition:slide={{ axis: 'y', easing: expoOut }}>
|
<div transition:slide={{ axis: 'y', easing: expoOut }}>
|
||||||
{#if object.community}
|
{#if object.community}
|
||||||
<CommunityItem community={object.community} />
|
<div
|
||||||
|
class="-mx-4 sm:-mx-6 px-6 hover:bg-slate-100 hover:dark:bg-zinc-800 transition-colors"
|
||||||
|
>
|
||||||
|
<CommunityItem
|
||||||
|
community={object.community}
|
||||||
|
showCounts={false}
|
||||||
|
class="py-3"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if object.post}
|
{#if object.post}
|
||||||
<Post post={object.post} />
|
<Post post={object.post} />
|
||||||
@@ -161,9 +178,17 @@
|
|||||||
{:else if isCommentView(result)}
|
{:else if isCommentView(result)}
|
||||||
<CommentItem comment={result} />
|
<CommentItem comment={result} />
|
||||||
{:else if isCommunityView(result)}
|
{:else if isCommunityView(result)}
|
||||||
<CommunityItem community={result} />
|
<div
|
||||||
|
class="-mx-4 sm:-mx-6 px-6 hover:bg-slate-100 hover:dark:bg-zinc-800 transition-colors"
|
||||||
|
>
|
||||||
|
<CommunityItem community={result} showCounts={false} class="py-3" />
|
||||||
|
</div>
|
||||||
{:else if isUser(result)}
|
{:else if isUser(result)}
|
||||||
<UserItem user={result} />
|
<div
|
||||||
|
class="-mx-4 sm:-mx-6 px-6 hover:bg-slate-100 hover:dark:bg-zinc-800 transition-colors"
|
||||||
|
>
|
||||||
|
<UserItem user={result} showCounts={false} class="py-3" />
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ export async function load({ url, fetch }) {
|
|||||||
const community = Number(url.searchParams.get('community')) || undefined
|
const community = Number(url.searchParams.get('community')) || undefined
|
||||||
const sort = url.searchParams.get('sort') || 'New'
|
const sort = url.searchParams.get('sort') || 'New'
|
||||||
const type = url.searchParams.get('type') || 'All'
|
const type = url.searchParams.get('type') || 'All'
|
||||||
const listing_type = url.searchParams.get('listing_type') as ListingType || 'All'
|
const listing_type =
|
||||||
|
(url.searchParams.get('listing_type') as ListingType) || 'All'
|
||||||
|
|
||||||
if (query) {
|
if (query) {
|
||||||
const results = await client({ func: fetch }).search({
|
const results = await client({ func: fetch }).search({
|
||||||
@@ -41,6 +42,14 @@ export async function load({ url, fetch }) {
|
|||||||
|
|
||||||
const everything = [...posts, ...comments, ...users, ...communities]
|
const everything = [...posts, ...comments, ...users, ...communities]
|
||||||
|
|
||||||
|
if (sort == 'New') {
|
||||||
|
everything.sort(
|
||||||
|
(a, b) =>
|
||||||
|
new Date(getItemPublished(b)).getTime() -
|
||||||
|
new Date(getItemPublished(a)).getTime()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: type,
|
type: type,
|
||||||
sort: sort,
|
sort: sort,
|
||||||
|
|||||||
Reference in new issue
Block a user