feat: add admin and moderator badges to posts and comments
This commit is contained in:
1 parent
3f5c49d4c4
commit
3c74cfe4e6
7 files changed
+85
-36
No files matched your search
@@ -46,12 +46,16 @@
|
||||
community={hideCommunity ? undefined : post.community}
|
||||
user={post.creator}
|
||||
published={publishedToDate(post.post.published)}
|
||||
deleted={post.post.deleted}
|
||||
removed={post.post.removed}
|
||||
locked={post.post.locked}
|
||||
featured={post.post.featured_local || post.post.featured_community}
|
||||
nsfw={post.post.nsfw}
|
||||
saved={post.saved}
|
||||
badges={{
|
||||
deleted: post.post.deleted,
|
||||
removed: post.post.removed,
|
||||
locked: post.post.locked,
|
||||
featured: post.post.featured_local || post.post.featured_community,
|
||||
nsfw: post.post.nsfw,
|
||||
saved: post.saved,
|
||||
admin: post.creator_is_admin,
|
||||
moderator: post.creator_is_moderator,
|
||||
}}
|
||||
subscribed={$profile?.user?.follows
|
||||
.map((c) => c.community.id)
|
||||
.includes(post.community.id)
|
||||
@@ -64,10 +68,18 @@
|
||||
</PostMeta>
|
||||
<PostMedia bind:post={post.post} {view} {type} />
|
||||
{#if view == 'list' || view == 'compact'}
|
||||
<PostMediaCompact {view} bind:post={post.post} style="grid-area: media; grid-column: span 2 / span 2;" />
|
||||
<PostMediaCompact
|
||||
{view}
|
||||
bind:post={post.post}
|
||||
style="grid-area: media; grid-column: span 2 / span 2;"
|
||||
/>
|
||||
{/if}
|
||||
{#if post.post.body && !post.post.nsfw && view != 'compact'}
|
||||
<PostBody body={post.post.body} {view} style="grid-area: body; grid-column: span 1 / span 1;" />
|
||||
<PostBody
|
||||
body={post.post.body}
|
||||
{view}
|
||||
style="grid-area: body; grid-column: span 1 / span 1;"
|
||||
/>
|
||||
{/if}
|
||||
{#if actions}
|
||||
<PostActions
|
||||
@@ -96,4 +108,4 @@
|
||||
grid-template-rows: 3;
|
||||
grid-template-columns: 2;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@@ -17,6 +17,7 @@
|
||||
import { getInstance } from '$lib/lemmy.js'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import Subscribe from '../../../../routes/communities/Subscribe.svelte'
|
||||
import ShieldIcon from '../moderation/ShieldIcon.svelte'
|
||||
|
||||
export let community: Community | undefined = undefined
|
||||
export let subscribed: SubscribedType | undefined = undefined
|
||||
@@ -27,12 +28,16 @@
|
||||
export let id: number | undefined = undefined
|
||||
|
||||
// Badges
|
||||
export let nsfw: boolean = false
|
||||
export let saved: boolean = false
|
||||
export let featured: boolean = false
|
||||
export let deleted: boolean = false
|
||||
export let removed: boolean = false
|
||||
export let locked: boolean = false
|
||||
export let badges = {
|
||||
nsfw: false,
|
||||
saved: false,
|
||||
featured: false,
|
||||
deleted: false,
|
||||
removed: false,
|
||||
locked: false,
|
||||
moderator: false,
|
||||
admin: false,
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
@@ -81,7 +86,16 @@
|
||||
style="grid-area: stats;"
|
||||
>
|
||||
{#if user}
|
||||
<UserLink avatarSize={20} {user} avatar={!community} />
|
||||
<UserLink avatarSize={20} {user} avatar={!community}>
|
||||
<svelte:fragment slot="badges">
|
||||
{#if badges.moderator}
|
||||
<ShieldIcon filled width={14} class="text-green-500" />
|
||||
{/if}
|
||||
{#if badges.admin}
|
||||
<ShieldIcon filled width={14} class="text-red-500" />
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</UserLink>
|
||||
{/if}
|
||||
{#if published}
|
||||
<RelativeDate date={published} />
|
||||
@@ -92,34 +106,34 @@
|
||||
class="flex flex-row items-center place-self-end overflow-auto [&>*]:flex-shrink-0"
|
||||
style="grid-area: badges;"
|
||||
>
|
||||
{#if nsfw}
|
||||
{#if badges.nsfw}
|
||||
<Badge color="red-subtle">NSFW</Badge>
|
||||
{/if}
|
||||
{#if saved}
|
||||
{#if badges.saved}
|
||||
<Badge label="Saved" color="yellow-subtle">
|
||||
<Icon src={Bookmark} mini size="12" />
|
||||
<span class="max-md:hidden">Saved</span>
|
||||
</Badge>
|
||||
{/if}
|
||||
{#if locked}
|
||||
{#if badges.locked}
|
||||
<Badge label="Locked" color="yellow-subtle">
|
||||
<Icon src={LockClosed} mini size="14" />
|
||||
<span class="max-md:hidden">Locked</span>
|
||||
</Badge>
|
||||
{/if}
|
||||
{#if removed}
|
||||
{#if badges.removed}
|
||||
<Badge label="Removed" color="red-subtle">
|
||||
<Icon src={Trash} mini size="14" />
|
||||
<span class="max-md:hidden">Removed</span>
|
||||
</Badge>
|
||||
{/if}
|
||||
{#if deleted}
|
||||
{#if badges.deleted}
|
||||
<Badge label="Deleted" color="red-subtle">
|
||||
<Icon src={Trash} mini size="14" />
|
||||
<span class="max-md:hidden">Deleted</span>
|
||||
</Badge>
|
||||
{/if}
|
||||
{#if featured}
|
||||
{#if badges.featured}
|
||||
<Badge label="Featured" color="green-subtle">
|
||||
<Icon src={Megaphone} mini size="14" />
|
||||
<span class="max-md:hidden">Featured</span>
|
||||
|
||||
Reference in new issue
Block a user