design: use new entityheader in community pages
This commit is contained in:
1 parent
008f224055
commit
c3e8fbb6a8
8 files changed
+93
-72
No files matched your search
@@ -197,7 +197,7 @@
|
|||||||
name={community_view.community.title}
|
name={community_view.community.title}
|
||||||
label="!{fullCommunityName(
|
label="!{fullCommunityName(
|
||||||
community_view.community.name,
|
community_view.community.name,
|
||||||
community_view.community.actor_id
|
community_view.community.actor_id,
|
||||||
)}"
|
)}"
|
||||||
>
|
>
|
||||||
<Avatar
|
<Avatar
|
||||||
@@ -287,7 +287,7 @@
|
|||||||
<Button
|
<Button
|
||||||
href="/c/{fullCommunityName(
|
href="/c/{fullCommunityName(
|
||||||
community_view.community.name,
|
community_view.community.name,
|
||||||
community_view.community.actor_id
|
community_view.community.actor_id,
|
||||||
)}/settings"
|
)}/settings"
|
||||||
size="square-md"
|
size="square-md"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
export let name: boolean = true
|
export let name: boolean = true
|
||||||
export let avatarSize: number = 24
|
export let avatarSize: number = 24
|
||||||
export let showInstance: boolean = $userSettings.showInstances.community
|
export let showInstance: boolean = $userSettings.showInstances.community
|
||||||
|
export let displayName: boolean = true
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
@@ -29,7 +30,9 @@
|
|||||||
|
|
||||||
{#if name}
|
{#if name}
|
||||||
<span class="flex gap-0 items-center max-w-full min-w-0 flex-shrink">
|
<span class="flex gap-0 items-center max-w-full min-w-0 flex-shrink">
|
||||||
<span class="font-medium username-text">{community.title}</span>
|
<span class="font-medium username-text">
|
||||||
|
{displayName ? community.title : community.name}
|
||||||
|
</span>
|
||||||
{#if showInstance}
|
{#if showInstance}
|
||||||
<span
|
<span
|
||||||
class="text-slate-500 dark:text-zinc-500 font-normal
|
class="text-slate-500 dark:text-zinc-500 font-normal
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<div class="max-h-36 overflow-visible">
|
<div class="max-h-36 overflow-visible">
|
||||||
<img
|
<img
|
||||||
src={banner}
|
src={banner}
|
||||||
class="w-full object-cover h-48 rounded-xl rounded-b-none"
|
class="w-full object-cover h-48 rounded-xl bg-white dark:bg-zinc-900"
|
||||||
height="192"
|
height="192"
|
||||||
alt="User banner"
|
alt="User banner"
|
||||||
/>
|
/>
|
||||||
@@ -31,8 +31,7 @@
|
|||||||
width={64}
|
width={64}
|
||||||
url={avatar}
|
url={avatar}
|
||||||
alt={name}
|
alt={name}
|
||||||
circle={false}
|
class="ring-4 ring-slate-25 dark:ring-zinc-925 bg-slate-25 dark:bg-zinc-925"
|
||||||
class="ring-4 rounded-3xl ring-slate-25 dark:ring-zinc-925"
|
|
||||||
/>
|
/>
|
||||||
<div>
|
<div>
|
||||||
<span class="text-lg font-semibold">
|
<span class="text-lg font-semibold">
|
||||||
|
|||||||
@@ -359,7 +359,8 @@
|
|||||||
"unblock": "Unblock",
|
"unblock": "Unblock",
|
||||||
"blockInstance": "Block instance",
|
"blockInstance": "Block instance",
|
||||||
"favorite": "Favorite",
|
"favorite": "Favorite",
|
||||||
"unfavorite": "Remove Favorite"
|
"unfavorite": "Remove Favorite",
|
||||||
|
"activeDay": "Active Today"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin": {
|
"admin": {
|
||||||
|
|||||||
@@ -15,9 +15,12 @@
|
|||||||
import {
|
import {
|
||||||
ArrowRight,
|
ArrowRight,
|
||||||
ChartBar,
|
ChartBar,
|
||||||
|
Check,
|
||||||
Cog6Tooth,
|
Cog6Tooth,
|
||||||
EllipsisHorizontal,
|
EllipsisHorizontal,
|
||||||
Icon,
|
Icon,
|
||||||
|
InformationCircle,
|
||||||
|
Plus,
|
||||||
XMark,
|
XMark,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||||
@@ -26,9 +29,14 @@
|
|||||||
import { userSettings } from '$lib/settings.js'
|
import { userSettings } from '$lib/settings.js'
|
||||||
import { site } from '$lib/lemmy.js'
|
import { site } from '$lib/lemmy.js'
|
||||||
import { postFeeds } from '$lib/lemmy/postfeed.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
|
export let data
|
||||||
|
|
||||||
|
$: community = data.community.community_view
|
||||||
|
|
||||||
let sidebar: boolean = false
|
let sidebar: boolean = false
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
@@ -51,62 +59,96 @@
|
|||||||
{#if sidebar}
|
{#if sidebar}
|
||||||
<Modal bind:open={sidebar}>
|
<Modal bind:open={sidebar}>
|
||||||
<span slot="title">About</span>
|
<span slot="title">About</span>
|
||||||
<div class="mx-auto">
|
<div>
|
||||||
<CommunityCard
|
<CommunityCard
|
||||||
community_view={data.community.community_view}
|
bind:community_view={community}
|
||||||
moderators={data.community.moderators}
|
moderators={data.community.moderators}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
{/if}
|
{/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-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">
|
<EntityHeader
|
||||||
<Avatar
|
banner={community.community.banner}
|
||||||
width={48}
|
avatar={community.community.icon}
|
||||||
url={data.community.community_view.community.icon}
|
name={community.community.title}
|
||||||
alt={data.community.community_view.community.name}
|
stats={[
|
||||||
/>
|
{
|
||||||
<div class="flex flex-col gap-0">
|
name: $t('cards.community.members'),
|
||||||
<h1 class="font-bold text-xl">
|
value: community.counts.subscribers.toString(),
|
||||||
{data.community.community_view.community.title}
|
},
|
||||||
</h1>
|
{
|
||||||
|
name: $t('content.posts'),
|
||||||
|
value: community.counts.posts.toString(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: $t('cards.community.activeDay'),
|
||||||
|
value: community.counts.users_active_day.toString(),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
navigator?.clipboard?.writeText?.(
|
navigator?.clipboard?.writeText?.(
|
||||||
`!${data.community.community_view.community.name}@${
|
fullCommunityName(
|
||||||
new URL(data.community.community_view.community.actor_id)
|
community.community.name,
|
||||||
.hostname
|
community.community.actor_id,
|
||||||
}`,
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
toast({ content: $t('toast.copied') })
|
toast({ content: $t('toast.copied') })
|
||||||
}}
|
}}
|
||||||
class="dark:text-zinc-400 text-slate-600 text-sm text-left"
|
class="text-sm flex gap-0 items-center"
|
||||||
|
slot="nameDetail"
|
||||||
>
|
>
|
||||||
!{data.community.community_view.community.name}@{new URL(
|
!{fullCommunityName(
|
||||||
data.community.community_view.community.actor_id,
|
community.community.name,
|
||||||
).hostname}
|
community.community.actor_id,
|
||||||
|
)}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
<div class="flex items-center gap-2" slot="actions">
|
||||||
<div class="flex items-center gap-2 w-max ml-auto">
|
{#if $profile?.jwt}
|
||||||
|
<Subscribe let:subscribe bind:community let:subscribing>
|
||||||
|
<Button
|
||||||
|
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={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>
|
||||||
|
</Subscribe>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if $profile?.user && $profile.user.moderates
|
{#if $profile?.user && $profile.user.moderates
|
||||||
.map((c) => c.community.id)
|
.map((c) => c.community.id)
|
||||||
.includes(data.community.community_view.community.id)}
|
.includes(community.community.id)}
|
||||||
<Button
|
<Button
|
||||||
size="square-md"
|
size="square-md"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
href="/c/{fullCommunityName(
|
href="/c/{fullCommunityName(
|
||||||
data.community.community_view.community.name,
|
community.community.name,
|
||||||
data.community.community_view.community.actor_id,
|
community.community.actor_id,
|
||||||
)}/settings"
|
)}/settings"
|
||||||
>
|
>
|
||||||
<Icon src={Cog6Tooth} size="16" mini />
|
<Icon src={Cog6Tooth} size="16" mini />
|
||||||
@@ -117,14 +159,14 @@
|
|||||||
color="secondary"
|
color="secondary"
|
||||||
on:click={() => (sidebar = !sidebar)}
|
on:click={() => (sidebar = !sidebar)}
|
||||||
>
|
>
|
||||||
<Icon src={EllipsisHorizontal} size="16" mini />
|
<Icon src={InformationCircle} size="16" mini />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</EntityHeader>
|
||||||
<div class="flex flex-row gap-4 max-w-full w-full items-end z-0">
|
<div class="flex flex-row gap-4 max-w-full w-full items-end z-0">
|
||||||
<Sort selected={data.sort} />
|
<Sort selected={data.sort} />
|
||||||
</div>
|
</div>
|
||||||
{#if data.community.community_view.blocked}
|
{#if community.blocked}
|
||||||
<Placeholder
|
<Placeholder
|
||||||
icon={XMark}
|
icon={XMark}
|
||||||
title="Blocked"
|
title="Blocked"
|
||||||
@@ -167,7 +209,6 @@
|
|||||||
</Pageination>
|
</Pageination>
|
||||||
</svelte:element>
|
</svelte:element>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
</style>
|
</style>
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import { client } from '$lib/lemmy.js'
|
|
||||||
import { postFeed } from '$lib/lemmy/postfeed.js'
|
import { postFeed } from '$lib/lemmy/postfeed.js'
|
||||||
import { userSettings } from '$lib/settings.js'
|
import { userSettings } from '$lib/settings.js'
|
||||||
import type { SortType } from 'lemmy-js-client'
|
import type { SortType } from 'lemmy-js-client'
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
async function subscribe(
|
async function subscribe(
|
||||||
id: number | undefined = community?.community.id,
|
id: number | undefined = community?.community.id,
|
||||||
subscribed: SubscribedType | undefined = community?.subscribed
|
subscribed: SubscribedType | undefined = community?.subscribed,
|
||||||
) {
|
) {
|
||||||
if (!$profile?.jwt) return
|
if (!$profile?.jwt) return
|
||||||
if (!id || !subscribed) return
|
if (!id || !subscribed) return
|
||||||
|
|||||||
@@ -1,17 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
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 {
|
import {
|
||||||
AdjustmentsHorizontal,
|
AdjustmentsHorizontal,
|
||||||
AtSymbol,
|
AtSymbol,
|
||||||
Bars3BottomRight,
|
|
||||||
Calendar,
|
|
||||||
ChartBar,
|
ChartBar,
|
||||||
ChatBubbleOvalLeftEllipsis,
|
|
||||||
EllipsisHorizontal,
|
EllipsisHorizontal,
|
||||||
Envelope,
|
Envelope,
|
||||||
Fire,
|
Fire,
|
||||||
@@ -28,14 +20,7 @@
|
|||||||
import { isCommentView } from '$lib/lemmy/item.js'
|
import { isCommentView } from '$lib/lemmy/item.js'
|
||||||
import { client, getClient } from '$lib/lemmy.js'
|
import { client, getClient } from '$lib/lemmy.js'
|
||||||
import { isBlocked } from '$lib/lemmy/user.js'
|
import { isBlocked } from '$lib/lemmy/user.js'
|
||||||
import {
|
import { Menu, MenuButton, removeToast, toast } from 'mono-svelte'
|
||||||
Material,
|
|
||||||
Menu,
|
|
||||||
MenuButton,
|
|
||||||
Popover,
|
|
||||||
removeToast,
|
|
||||||
toast,
|
|
||||||
} from 'mono-svelte'
|
|
||||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import { ban, isAdmin } from '$lib/components/lemmy/moderation/moderation.js'
|
import { ban, isAdmin } from '$lib/components/lemmy/moderation/moderation.js'
|
||||||
@@ -43,15 +28,11 @@
|
|||||||
import { searchParam } from '$lib/util.js'
|
import { searchParam } from '$lib/util.js'
|
||||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||||
import { Button, Modal, Select } from 'mono-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 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 Expandable from '$lib/components/ui/Expandable.svelte'
|
||||||
import { communityLink } from '$lib/lemmy/generic.js'
|
import { communityLink } from '$lib/lemmy/generic.js'
|
||||||
import ItemList from '$lib/components/lemmy/generic/ItemList.svelte'
|
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'
|
import EntityHeader from '$lib/components/ui/EntityHeader.svelte'
|
||||||
|
|
||||||
export let data
|
export let data
|
||||||
@@ -177,10 +158,7 @@
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<span
|
<span class="text-sm flex gap-0 items-center" slot="nameDetail">
|
||||||
class="text-sm text-slate-600 dark:text-zinc-400 flex gap-0 items-center"
|
|
||||||
slot="nameDetail"
|
|
||||||
>
|
|
||||||
@
|
@
|
||||||
<UserLink
|
<UserLink
|
||||||
showInstance
|
showInstance
|
||||||
|
|||||||
Reference in new issue
Block a user