redesign: entity headers
This commit is contained in:
1 parent
c85f98cdcb
commit
fef0df76ce
9 files changed
+204
-213
No files matched your search
+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