redesign: entity headers
This commit is contained in:
1 parent
c85f98cdcb
commit
fef0df76ce
9 files changed
+204
-213
No files matched your search
@@ -4,27 +4,14 @@
|
||||
import { navigating, page } from '$app/state'
|
||||
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
|
||||
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
||||
import { fullCommunityName, searchParam } from '$lib/util.svelte.js'
|
||||
import { onDestroy, onMount } from 'svelte'
|
||||
import { setSessionStorage } from '$lib/session.js'
|
||||
import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte'
|
||||
import VirtualFeed from '$lib/components/lemmy/post/feed/VirtualFeed.svelte'
|
||||
import { Button, Modal, toast } from 'mono-svelte'
|
||||
import { afterNavigate } from '$app/navigation'
|
||||
import { browser } from '$app/environment'
|
||||
import {
|
||||
ArrowRight,
|
||||
ChartBar,
|
||||
Check,
|
||||
Cog6Tooth,
|
||||
EllipsisHorizontal,
|
||||
Icon,
|
||||
InformationCircle,
|
||||
Plus,
|
||||
XMark,
|
||||
} from 'svelte-hero-icons'
|
||||
import { ArrowRight, ChartBar, Icon, XMark } from 'svelte-hero-icons'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import { t } from '$lib/translations.js'
|
||||
import { settings } from '$lib/settings.svelte.js'
|
||||
@@ -33,7 +20,11 @@
|
||||
import CommunityHeader from '$lib/components/lemmy/community/CommunityHeader.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
|
||||
let { data = $bindable() } = $props()
|
||||
let { data: pageData } = $props()
|
||||
let data = $state(pageData)
|
||||
$effect(() => {
|
||||
data = pageData
|
||||
})
|
||||
|
||||
let sidebar: boolean = $state(false)
|
||||
|
||||
@@ -77,14 +68,16 @@
|
||||
|
||||
<div class="flex flex-col gap-4 max-w-full w-full min-w-0">
|
||||
<Header pageHeader>
|
||||
<CommunityHeader
|
||||
bind:community={data.community.community_view.community}
|
||||
bind:subscribed={data.community.community_view.subscribed}
|
||||
blocked={data.community.community_view.blocked}
|
||||
moderators={data.community.moderators}
|
||||
counts={data.community.community_view.counts}
|
||||
class="w-full relative"
|
||||
/>
|
||||
<div class="flex flex-col w-full">
|
||||
<CommunityHeader
|
||||
bind:community={data.community.community_view.community}
|
||||
bind:subscribed={data.community.community_view.subscribed}
|
||||
blocked={data.community.community_view.blocked}
|
||||
moderators={data.community.moderators}
|
||||
counts={data.community.community_view.counts}
|
||||
class="w-full relative"
|
||||
/>
|
||||
</div>
|
||||
{#snippet extended()}
|
||||
<Sort selected={data.sort} />
|
||||
{/snippet}
|
||||
|
||||
@@ -70,8 +70,8 @@
|
||||
size="square-lg"
|
||||
rounding="pill"
|
||||
color="none"
|
||||
class="bg-[#fff]/60 dark:bg-neutral-800/60
|
||||
border border-gray-200/60 dark:border-neutral-800
|
||||
class="bg-white/60 dark:bg-zinc-800/60
|
||||
border border-slate-200/60 dark:border-zinc-800
|
||||
backdrop-blur-xl shadow-xl hover:bg-slate-100 hover:dark:bg-zinc-800
|
||||
flex-shrink-0"
|
||||
>
|
||||
|
||||
@@ -53,25 +53,20 @@
|
||||
/>
|
||||
</span>
|
||||
{/snippet}
|
||||
{#if (data.moderates ?? []).length > 0}
|
||||
<Expandable
|
||||
class="border rounded-xl bg-white/50 dark:bg-zinc-900/50 w-full p-3 px-4
|
||||
dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text-zinc-300 transition-colors"
|
||||
>
|
||||
{#if data.moderates && data.moderates.length > 0}
|
||||
<Expandable class="">
|
||||
{#snippet title()}
|
||||
<span class="flex items-center gap-1">
|
||||
<ShieldIcon width={14} filled />
|
||||
{$t('routes.profile.moderates')}
|
||||
</span>
|
||||
{$t('routes.profile.moderates')}
|
||||
<hr class="flex-1 w-full border-slate-200 dark:border-zinc-800 mx-3" />
|
||||
{/snippet}
|
||||
<ItemList
|
||||
items={data.moderates?.map((m) => ({
|
||||
items={data.moderates.map((m) => ({
|
||||
id: m.community.id,
|
||||
name: m.community.title,
|
||||
url: communityLink(m.community),
|
||||
avatar: m.community.icon,
|
||||
instance: new URL(m.community.actor_id).hostname,
|
||||
})) ?? []}
|
||||
}))}
|
||||
/>
|
||||
</Expandable>
|
||||
{/if}
|
||||
|
||||
+122
-122
@@ -39,6 +39,7 @@
|
||||
import { formatRelativeDate } from '$lib/components/util/RelativeDate.svelte'
|
||||
import Option from 'mono-svelte/forms/select/Option.svelte'
|
||||
import type { PageData } from './$types'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
|
||||
interface Props {
|
||||
data: PageData
|
||||
@@ -150,147 +151,146 @@
|
||||
|
||||
<div class="flex flex-col gap-4 max-w-full w-full">
|
||||
{#if !inline}
|
||||
<div class="">
|
||||
<EntityHeader
|
||||
avatar={data.person_view.person.avatar}
|
||||
name={data.person_view.person.display_name ||
|
||||
data.person_view.person.name}
|
||||
banner={data.person_view.person.banner}
|
||||
bio={data.person_view.person.bio}
|
||||
stats={[
|
||||
{
|
||||
name: $t('content.posts'),
|
||||
value: data.person_view.counts.post_count.toString(),
|
||||
},
|
||||
{
|
||||
name: $t('content.comments'),
|
||||
value: data.person_view.counts.comment_count.toString(),
|
||||
},
|
||||
{
|
||||
name: $t('stats.joined'),
|
||||
value: formatRelativeDate(
|
||||
publishedToDate(data.person_view.person.published),
|
||||
{ style: 'short' },
|
||||
).toString(),
|
||||
format: false,
|
||||
},
|
||||
]}
|
||||
>
|
||||
{#snippet nameDetail()}
|
||||
<span class="text-sm flex gap-0 items-center w-max">
|
||||
@
|
||||
<UserLink
|
||||
showInstance
|
||||
user={data.person_view.person}
|
||||
displayName={false}
|
||||
class="font-normal"
|
||||
/>
|
||||
</span>
|
||||
{/snippet}
|
||||
{#if (data.moderates ?? []).length > 0}
|
||||
<Expandable
|
||||
class="border rounded-xl bg-white/50 dark:bg-zinc-900/50 w-full p-3 px-4
|
||||
dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text-zinc-300 transition-colors"
|
||||
>
|
||||
{#snippet title()}
|
||||
<span class="flex items-center gap-1">
|
||||
<ShieldIcon width={14} filled />
|
||||
<Header pageHeader>
|
||||
<div class="w-full">
|
||||
<EntityHeader
|
||||
avatar={data.person_view.person.avatar}
|
||||
name={data.person_view.person.display_name ||
|
||||
data.person_view.person.name}
|
||||
banner={data.person_view.person.banner}
|
||||
bio={data.person_view.person.bio}
|
||||
stats={[
|
||||
{
|
||||
name: $t('content.posts'),
|
||||
value: data.person_view.counts.post_count.toString(),
|
||||
},
|
||||
{
|
||||
name: $t('content.comments'),
|
||||
value: data.person_view.counts.comment_count.toString(),
|
||||
},
|
||||
{
|
||||
name: $t('stats.joined'),
|
||||
value: formatRelativeDate(
|
||||
publishedToDate(data.person_view.person.published),
|
||||
{ style: 'short' },
|
||||
).toString(),
|
||||
format: false,
|
||||
},
|
||||
]}
|
||||
>
|
||||
{#snippet nameDetail()}
|
||||
<span class="text-sm flex gap-0 items-center w-max">
|
||||
@
|
||||
<UserLink
|
||||
showInstance
|
||||
user={data.person_view.person}
|
||||
displayName={false}
|
||||
class="font-normal"
|
||||
/>
|
||||
</span>
|
||||
{/snippet}
|
||||
{#if (data.moderates ?? []).length > 0}
|
||||
<Expandable class="">
|
||||
{#snippet title()}
|
||||
{$t('routes.profile.moderates')}
|
||||
</span>
|
||||
{/snippet}
|
||||
<ItemList
|
||||
items={data.moderates.map((m) => ({
|
||||
id: m.community.id,
|
||||
name: m.community.title,
|
||||
url: communityLink(m.community),
|
||||
avatar: m.community.icon,
|
||||
instance: new URL(m.community.actor_id).hostname,
|
||||
}))}
|
||||
/>
|
||||
</Expandable>
|
||||
{/if}
|
||||
{#snippet actions()}
|
||||
{#if $profile?.user && $profile.jwt && data.person_view.person.id != $profile.user.local_user_view.person.id}
|
||||
<div class="flex items-center gap-2 w-full">
|
||||
<Button
|
||||
size="square-md"
|
||||
color="secondary"
|
||||
href="/inbox/messages/{data.person_view.person.id}"
|
||||
title="Message"
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon solid size="16" src={Envelope} />
|
||||
{/snippet}
|
||||
</Button>
|
||||
{#if data.person_view.person.matrix_user_id}
|
||||
<hr
|
||||
class="flex-1 w-full border-slate-200 dark:border-zinc-800 mx-3"
|
||||
/>
|
||||
{/snippet}
|
||||
<ItemList
|
||||
items={data.moderates.map((m) => ({
|
||||
id: m.community.id,
|
||||
name: m.community.title,
|
||||
url: communityLink(m.community),
|
||||
avatar: m.community.icon,
|
||||
instance: new URL(m.community.actor_id).hostname,
|
||||
}))}
|
||||
/>
|
||||
</Expandable>
|
||||
{/if}
|
||||
{#snippet actions()}
|
||||
{#if $profile?.user && $profile.jwt && data.person_view.person.id != $profile.user.local_user_view.person.id}
|
||||
<div class="flex items-center gap-2 w-full">
|
||||
<Button
|
||||
size="square-md"
|
||||
color="secondary"
|
||||
href="https://matrix.to/#/{data.person_view.person
|
||||
.matrix_user_id}"
|
||||
title="Matrix User"
|
||||
href="/inbox/messages/{data.person_view.person.id}"
|
||||
title="Message"
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon solid size="16" src={AtSymbol} />
|
||||
<Icon solid size="16" src={Envelope} />
|
||||
{/snippet}
|
||||
</Button>
|
||||
{/if}
|
||||
{#if isAdmin($profile?.user)}
|
||||
<Menu class="ml-auto" placement="bottom-end">
|
||||
{#if data.person_view.person.matrix_user_id}
|
||||
<Button
|
||||
size="square-md"
|
||||
color="secondary"
|
||||
href="https://matrix.to/#/{data.person_view.person
|
||||
.matrix_user_id}"
|
||||
title="Matrix User"
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon solid size="16" src={AtSymbol} />
|
||||
{/snippet}
|
||||
</Button>
|
||||
{/if}
|
||||
{#if isAdmin($profile?.user)}
|
||||
<Menu class="ml-auto" placement="bottom-end">
|
||||
{#snippet target()}
|
||||
<Button size="square-md">
|
||||
<ShieldIcon width={16} filled />
|
||||
</Button>
|
||||
{/snippet}
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
onclick={() =>
|
||||
ban(
|
||||
data.person_view.person.banned,
|
||||
data.person_view.person,
|
||||
)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon mini size="16" src={ShieldExclamation} />
|
||||
{/snippet}
|
||||
{data.person_view.person.banned ? 'Unban' : 'Ban'}
|
||||
</MenuButton>
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
onclick={() => (purgingUser = !purgingUser)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon mini size="16" src={Fire} />
|
||||
{/snippet}
|
||||
Purge
|
||||
</MenuButton>
|
||||
</Menu>
|
||||
{/if}
|
||||
<Menu placement="bottom-end">
|
||||
{#snippet target()}
|
||||
<Button size="square-md">
|
||||
<ShieldIcon width={16} filled />
|
||||
{#snippet prefix()}
|
||||
<Icon src={EllipsisHorizontal} size="16" mini />
|
||||
{/snippet}
|
||||
</Button>
|
||||
{/snippet}
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
onclick={() =>
|
||||
ban(
|
||||
data.person_view.person.banned,
|
||||
data.person_view.person,
|
||||
)}
|
||||
onclick={() => blockUser(data.person_view.person.id)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon mini size="16" src={ShieldExclamation} />
|
||||
<Icon mini size="16" src={NoSymbol} />
|
||||
{/snippet}
|
||||
{data.person_view.person.banned ? 'Unban' : 'Ban'}
|
||||
</MenuButton>
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
onclick={() => (purgingUser = !purgingUser)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon mini size="16" src={Fire} />
|
||||
{/snippet}
|
||||
Purge
|
||||
{isBlocked($profile.user, data.person_view.person.id)
|
||||
? 'Unblock'
|
||||
: 'Block'}
|
||||
</MenuButton>
|
||||
</Menu>
|
||||
{/if}
|
||||
<Menu placement="bottom-end">
|
||||
{#snippet target()}
|
||||
<Button size="square-md">
|
||||
{#snippet prefix()}
|
||||
<Icon src={EllipsisHorizontal} size="16" mini />
|
||||
{/snippet}
|
||||
</Button>
|
||||
{/snippet}
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
onclick={() => blockUser(data.person_view.person.id)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon mini size="16" src={NoSymbol} />
|
||||
{/snippet}
|
||||
{isBlocked($profile.user, data.person_view.person.id)
|
||||
? 'Unblock'
|
||||
: 'Block'}
|
||||
</MenuButton>
|
||||
</Menu>
|
||||
</div>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</EntityHeader>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</EntityHeader>
|
||||
</div>
|
||||
</Header>
|
||||
{/if}
|
||||
|
||||
<div class="flex flex-col gap-4 max-w-full w-full min-w-0">
|
||||
|
||||
Reference in new issue
Block a user