design: use new entityheader in community pages
This commit is contained in:
1 parent
008f224055
commit
c3e8fbb6a8
8 files changed
+154
-133
No files matched your search
@@ -15,9 +15,12 @@
|
||||
import {
|
||||
ArrowRight,
|
||||
ChartBar,
|
||||
Check,
|
||||
Cog6Tooth,
|
||||
EllipsisHorizontal,
|
||||
Icon,
|
||||
InformationCircle,
|
||||
Plus,
|
||||
XMark,
|
||||
} from 'svelte-hero-icons'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
@@ -26,9 +29,14 @@
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import { site } from '$lib/lemmy.js'
|
||||
import { postFeeds } from '$lib/lemmy/postfeed.js'
|
||||
import EntityHeader from '$lib/components/ui/EntityHeader.svelte'
|
||||
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
|
||||
import Subscribe from '../../communities/Subscribe.svelte'
|
||||
|
||||
export let data
|
||||
|
||||
$: community = data.community.community_view
|
||||
|
||||
let sidebar: boolean = false
|
||||
|
||||
onMount(() => {
|
||||
@@ -51,122 +59,155 @@
|
||||
{#if sidebar}
|
||||
<Modal bind:open={sidebar}>
|
||||
<span slot="title">About</span>
|
||||
<div class="mx-auto">
|
||||
<div>
|
||||
<CommunityCard
|
||||
community_view={data.community.community_view}
|
||||
bind:community_view={community}
|
||||
moderators={data.community.moderators}
|
||||
/>
|
||||
</div>
|
||||
</Modal>
|
||||
{/if}
|
||||
|
||||
{#if data.community.community_view.community.banner}
|
||||
<img
|
||||
src={data.community.community_view.community.banner}
|
||||
class="absolute top-0 right-0 object-cover w-full h-40 banner"
|
||||
alt="Community banner"
|
||||
/>
|
||||
{/if}
|
||||
<div class="flex flex-col md:flex-row gap-4 w-full">
|
||||
<div class="flex flex-col gap-3 sm:gap-4 max-w-full w-full min-w-0">
|
||||
<div class="flex flex-row gap-3 items-center z-0">
|
||||
<Avatar
|
||||
width={48}
|
||||
url={data.community.community_view.community.icon}
|
||||
alt={data.community.community_view.community.name}
|
||||
/>
|
||||
<div class="flex flex-col gap-0">
|
||||
<h1 class="font-bold text-xl">
|
||||
{data.community.community_view.community.title}
|
||||
</h1>
|
||||
<button
|
||||
on:click={() => {
|
||||
navigator?.clipboard?.writeText?.(
|
||||
`!${data.community.community_view.community.name}@${
|
||||
new URL(data.community.community_view.community.actor_id)
|
||||
.hostname
|
||||
}`,
|
||||
)
|
||||
|
||||
toast({ content: $t('toast.copied') })
|
||||
}}
|
||||
class="dark:text-zinc-400 text-slate-600 text-sm text-left"
|
||||
>
|
||||
!{data.community.community_view.community.name}@{new URL(
|
||||
data.community.community_view.community.actor_id,
|
||||
).hostname}
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex items-center gap-2 w-max ml-auto">
|
||||
{#if $profile?.user && $profile.user.moderates
|
||||
.map((c) => c.community.id)
|
||||
.includes(data.community.community_view.community.id)}
|
||||
<div class="flex flex-col gap-3 sm:gap-4 max-w-full w-full min-w-0">
|
||||
<EntityHeader
|
||||
banner={community.community.banner}
|
||||
avatar={community.community.icon}
|
||||
name={community.community.title}
|
||||
stats={[
|
||||
{
|
||||
name: $t('cards.community.members'),
|
||||
value: community.counts.subscribers.toString(),
|
||||
},
|
||||
{
|
||||
name: $t('content.posts'),
|
||||
value: community.counts.posts.toString(),
|
||||
},
|
||||
{
|
||||
name: $t('cards.community.activeDay'),
|
||||
value: community.counts.users_active_day.toString(),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<button
|
||||
on:click={() => {
|
||||
navigator?.clipboard?.writeText?.(
|
||||
fullCommunityName(
|
||||
community.community.name,
|
||||
community.community.actor_id,
|
||||
),
|
||||
)
|
||||
toast({ content: $t('toast.copied') })
|
||||
}}
|
||||
class="text-sm flex gap-0 items-center"
|
||||
slot="nameDetail"
|
||||
>
|
||||
!{fullCommunityName(
|
||||
community.community.name,
|
||||
community.community.actor_id,
|
||||
)}
|
||||
</button>
|
||||
<div class="flex items-center gap-2" slot="actions">
|
||||
{#if $profile?.jwt}
|
||||
<Subscribe let:subscribe bind:community let:subscribing>
|
||||
<Button
|
||||
size="square-md"
|
||||
color="secondary"
|
||||
href="/c/{fullCommunityName(
|
||||
data.community.community_view.community.name,
|
||||
data.community.community_view.community.actor_id,
|
||||
)}/settings"
|
||||
disabled={subscribing}
|
||||
loading={subscribing}
|
||||
size="md"
|
||||
color={community.subscribed == 'NotSubscribed'
|
||||
? 'primary'
|
||||
: 'secondary'}
|
||||
on:click={async () => {
|
||||
community.subscribed =
|
||||
(await subscribe())?.community_view.subscribed ??
|
||||
'NotSubscribed'
|
||||
|
||||
if ($page.data.slots?.sidebar?.props.community_view)
|
||||
$page.data.slots.sidebar.props.community_view = community
|
||||
}}
|
||||
class="flex-1 relative z-[inherit]"
|
||||
>
|
||||
<Icon src={Cog6Tooth} size="16" mini />
|
||||
<Icon
|
||||
src={community.subscribed != 'NotSubscribed' ? Check : Plus}
|
||||
mini
|
||||
size="16"
|
||||
slot="prefix"
|
||||
/>
|
||||
{community.subscribed == 'Subscribed' ||
|
||||
community.subscribed == 'Pending'
|
||||
? $t('cards.community.subscribed')
|
||||
: $t('cards.community.subscribe')}
|
||||
</Button>
|
||||
{/if}
|
||||
</Subscribe>
|
||||
{/if}
|
||||
|
||||
{#if $profile?.user && $profile.user.moderates
|
||||
.map((c) => c.community.id)
|
||||
.includes(community.community.id)}
|
||||
<Button
|
||||
size="square-md"
|
||||
color="secondary"
|
||||
on:click={() => (sidebar = !sidebar)}
|
||||
href="/c/{fullCommunityName(
|
||||
community.community.name,
|
||||
community.community.actor_id,
|
||||
)}/settings"
|
||||
>
|
||||
<Icon src={EllipsisHorizontal} size="16" mini />
|
||||
<Icon src={Cog6Tooth} size="16" mini />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-row gap-4 max-w-full w-full items-end z-0">
|
||||
<Sort selected={data.sort} />
|
||||
</div>
|
||||
{#if data.community.community_view.blocked}
|
||||
<Placeholder
|
||||
icon={XMark}
|
||||
title="Blocked"
|
||||
description="You've blocked this community."
|
||||
{/if}
|
||||
<Button
|
||||
size="square-md"
|
||||
color="secondary"
|
||||
on:click={() => (sidebar = !sidebar)}
|
||||
>
|
||||
<Button href="/profile/blocks">
|
||||
<Icon src={ArrowRight} size="16" mini slot="suffix" />
|
||||
Blocked Communities
|
||||
</Button>
|
||||
</Placeholder>
|
||||
{:else}
|
||||
<svelte:component
|
||||
this={browser ? VirtualFeed : PostFeed}
|
||||
posts={data.posts.posts.posts}
|
||||
bind:feedData={data.posts}
|
||||
lastSeen={$postFeeds.community.lastSeen}
|
||||
feedId="main"
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<svelte:element
|
||||
this={$userSettings.infiniteScroll ? 'noscript' : 'div'}
|
||||
class="mt-auto"
|
||||
>
|
||||
<Pageination
|
||||
page={data.page}
|
||||
cursor={{ next: data.posts.cursor.next }}
|
||||
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
|
||||
on:cursor={(c) => {
|
||||
searchParam($page.url, 'cursor', c.detail)
|
||||
}}
|
||||
>
|
||||
<span class="flex flex-row items-center gap-1">
|
||||
<Icon src={ChartBar} size="16" mini />
|
||||
{$t('routes.frontpage.footer', {
|
||||
// @ts-ignore
|
||||
users: $site?.site_view.counts.users_active_day ?? '??',
|
||||
})}
|
||||
</span>
|
||||
</Pageination>
|
||||
</svelte:element>
|
||||
<Icon src={InformationCircle} size="16" mini />
|
||||
</Button>
|
||||
</div>
|
||||
</EntityHeader>
|
||||
<div class="flex flex-row gap-4 max-w-full w-full items-end z-0">
|
||||
<Sort selected={data.sort} />
|
||||
</div>
|
||||
{#if community.blocked}
|
||||
<Placeholder
|
||||
icon={XMark}
|
||||
title="Blocked"
|
||||
description="You've blocked this community."
|
||||
>
|
||||
<Button href="/profile/blocks">
|
||||
<Icon src={ArrowRight} size="16" mini slot="suffix" />
|
||||
Blocked Communities
|
||||
</Button>
|
||||
</Placeholder>
|
||||
{:else}
|
||||
<svelte:component
|
||||
this={browser ? VirtualFeed : PostFeed}
|
||||
posts={data.posts.posts.posts}
|
||||
bind:feedData={data.posts}
|
||||
lastSeen={$postFeeds.community.lastSeen}
|
||||
feedId="main"
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<svelte:element
|
||||
this={$userSettings.infiniteScroll ? 'noscript' : 'div'}
|
||||
class="mt-auto"
|
||||
>
|
||||
<Pageination
|
||||
page={data.page}
|
||||
cursor={{ next: data.posts.cursor.next }}
|
||||
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
|
||||
on:cursor={(c) => {
|
||||
searchParam($page.url, 'cursor', c.detail)
|
||||
}}
|
||||
>
|
||||
<span class="flex flex-row items-center gap-1">
|
||||
<Icon src={ChartBar} size="16" mini />
|
||||
{$t('routes.frontpage.footer', {
|
||||
// @ts-ignore
|
||||
users: $site?.site_view.counts.users_active_day ?? '??',
|
||||
})}
|
||||
</span>
|
||||
</Pageination>
|
||||
</svelte:element>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { client } from '$lib/lemmy.js'
|
||||
import { postFeed } from '$lib/lemmy/postfeed.js'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import type { SortType } from 'lemmy-js-client'
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
async function subscribe(
|
||||
id: number | undefined = community?.community.id,
|
||||
subscribed: SubscribedType | undefined = community?.subscribed
|
||||
subscribed: SubscribedType | undefined = community?.subscribed,
|
||||
) {
|
||||
if (!$profile?.jwt) return
|
||||
if (!id || !subscribed) return
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
<script lang="ts">
|
||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||
import {
|
||||
AdjustmentsHorizontal,
|
||||
AtSymbol,
|
||||
Bars3BottomRight,
|
||||
Calendar,
|
||||
ChartBar,
|
||||
ChatBubbleOvalLeftEllipsis,
|
||||
EllipsisHorizontal,
|
||||
Envelope,
|
||||
Fire,
|
||||
@@ -28,14 +20,7 @@
|
||||
import { isCommentView } from '$lib/lemmy/item.js'
|
||||
import { client, getClient } from '$lib/lemmy.js'
|
||||
import { isBlocked } from '$lib/lemmy/user.js'
|
||||
import {
|
||||
Material,
|
||||
Menu,
|
||||
MenuButton,
|
||||
Popover,
|
||||
removeToast,
|
||||
toast,
|
||||
} from 'mono-svelte'
|
||||
import { Menu, MenuButton, removeToast, toast } from 'mono-svelte'
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { ban, isAdmin } from '$lib/components/lemmy/moderation/moderation.js'
|
||||
@@ -43,15 +28,11 @@
|
||||
import { searchParam } from '$lib/util.js'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import { Button, Modal, Select } from 'mono-svelte'
|
||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
import PrivateMessageModal from '$lib/components/lemmy/modal/PrivateMessageModal.svelte'
|
||||
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
||||
import PostBody from '$lib/components/lemmy/post/PostBody.svelte'
|
||||
import Expandable from '$lib/components/ui/Expandable.svelte'
|
||||
import { communityLink } from '$lib/lemmy/generic.js'
|
||||
import ItemList from '$lib/components/lemmy/generic/ItemList.svelte'
|
||||
import { locale, t } from '$lib/translations.js'
|
||||
import { t } from '$lib/translations.js'
|
||||
import EntityHeader from '$lib/components/ui/EntityHeader.svelte'
|
||||
|
||||
export let data
|
||||
@@ -177,10 +158,7 @@
|
||||
},
|
||||
]}
|
||||
>
|
||||
<span
|
||||
class="text-sm text-slate-600 dark:text-zinc-400 flex gap-0 items-center"
|
||||
slot="nameDetail"
|
||||
>
|
||||
<span class="text-sm flex gap-0 items-center" slot="nameDetail">
|
||||
@
|
||||
<UserLink
|
||||
showInstance
|
||||
|
||||
Reference in new issue
Block a user