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
@@ -19,6 +19,7 @@
|
|||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import { Button, Modal } from 'mono-svelte'
|
import { Button, Modal } from 'mono-svelte'
|
||||||
import { publishedToDate } from '$lib/components/util/date.js'
|
import { publishedToDate } from '$lib/components/util/date.js'
|
||||||
|
import ShieldIcon from '../moderation/ShieldIcon.svelte'
|
||||||
|
|
||||||
export let node: CommentNodeI
|
export let node: CommentNodeI
|
||||||
export let postId: number
|
export let postId: number
|
||||||
@@ -104,7 +105,16 @@
|
|||||||
avatarSize={22}
|
avatarSize={22}
|
||||||
avatar
|
avatar
|
||||||
user={node.comment_view.creator}
|
user={node.comment_view.creator}
|
||||||
/>
|
>
|
||||||
|
<svelte:fragment slot="badges">
|
||||||
|
{#if node.comment_view.creator_is_moderator}
|
||||||
|
<ShieldIcon filled width={14} class="text-green-500" />
|
||||||
|
{/if}
|
||||||
|
{#if node.comment_view.creator_is_admin}
|
||||||
|
<ShieldIcon filled width={14} class="text-red-500" />
|
||||||
|
{/if}
|
||||||
|
</svelte:fragment>
|
||||||
|
</UserLink>
|
||||||
{#if op}
|
{#if op}
|
||||||
<span class="text-sky-500">OP</span>
|
<span class="text-sky-500">OP</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -21,11 +21,18 @@
|
|||||||
>
|
>
|
||||||
<div class="flex flex-row justify-between items-center">
|
<div class="flex flex-row justify-between items-center">
|
||||||
<PostMeta
|
<PostMeta
|
||||||
deleted={false}
|
badges={{
|
||||||
featured={false}
|
nsfw: comment.post.nsfw,
|
||||||
nsfw={comment.post.nsfw}
|
removed: comment.post.removed,
|
||||||
|
admin: false,
|
||||||
|
moderator: false,
|
||||||
|
saved: false,
|
||||||
|
deleted: comment.post.deleted,
|
||||||
|
featured:
|
||||||
|
comment.post.featured_community || comment.post.featured_local,
|
||||||
|
locked: comment.post.locked,
|
||||||
|
}}
|
||||||
published={publishedToDate(comment.comment.published)}
|
published={publishedToDate(comment.comment.published)}
|
||||||
saved={false}
|
|
||||||
community={community ? comment.community : undefined}
|
community={community ? comment.community : undefined}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
viewBox="0 0 20 22"
|
viewBox="0 0 20 22"
|
||||||
fill="none"
|
fill="none"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class="inline"
|
class="inline {$$props.class}"
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
d="M10.516 1.17C10.3767 1.03791 10.192 0.964283 10 0.964283C9.80801 0.964283 9.62333 1.03791 9.484 1.17C7.36127 3.18588 4.53412 4.29133 1.607 4.25C1.44753 4.24793 1.29156 4.29674 1.16172 4.38935C1.03189 4.48196 0.934957 4.61355 0.885 4.765C0.462973 6.05116 0.248618 7.39637 0.25 8.75C0.25 14.692 4.314 19.683 9.813 21.098C9.93566 21.1296 10.0643 21.1296 10.187 21.098C15.686 19.683 19.75 14.692 19.75 8.75C19.75 7.36 19.527 6.02 19.115 4.765C19.0652 4.61336 18.9684 4.48156 18.8385 4.38875C18.7087 4.29595 18.5526 4.247 18.393 4.249L18.25 4.25C15.254 4.25 12.533 3.08 10.516 1.17Z"
|
d="M10.516 1.17C10.3767 1.03791 10.192 0.964283 10 0.964283C9.80801 0.964283 9.62333 1.03791 9.484 1.17C7.36127 3.18588 4.53412 4.29133 1.607 4.25C1.44753 4.24793 1.29156 4.29674 1.16172 4.38935C1.03189 4.48196 0.934957 4.61355 0.885 4.765C0.462973 6.05116 0.248618 7.39637 0.25 8.75C0.25 14.692 4.314 19.683 9.813 21.098C9.93566 21.1296 10.0643 21.1296 10.187 21.098C15.686 19.683 19.75 14.692 19.75 8.75C19.75 7.36 19.527 6.02 19.115 4.765C19.0652 4.61336 18.9684 4.48156 18.8385 4.38875C18.7087 4.29595 18.5526 4.247 18.393 4.249L18.25 4.25C15.254 4.25 12.533 3.08 10.516 1.17Z"
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
viewBox="0 0 20 22"
|
viewBox="0 0 20 22"
|
||||||
fill="none"
|
fill="none"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class="inline"
|
class="inline {$$props.class}"
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
fill-rule="evenodd"
|
fill-rule="evenodd"
|
||||||
|
|||||||
@@ -46,12 +46,16 @@
|
|||||||
community={hideCommunity ? undefined : post.community}
|
community={hideCommunity ? undefined : post.community}
|
||||||
user={post.creator}
|
user={post.creator}
|
||||||
published={publishedToDate(post.post.published)}
|
published={publishedToDate(post.post.published)}
|
||||||
deleted={post.post.deleted}
|
badges={{
|
||||||
removed={post.post.removed}
|
deleted: post.post.deleted,
|
||||||
locked={post.post.locked}
|
removed: post.post.removed,
|
||||||
featured={post.post.featured_local || post.post.featured_community}
|
locked: post.post.locked,
|
||||||
nsfw={post.post.nsfw}
|
featured: post.post.featured_local || post.post.featured_community,
|
||||||
saved={post.saved}
|
nsfw: post.post.nsfw,
|
||||||
|
saved: post.saved,
|
||||||
|
admin: post.creator_is_admin,
|
||||||
|
moderator: post.creator_is_moderator,
|
||||||
|
}}
|
||||||
subscribed={$profile?.user?.follows
|
subscribed={$profile?.user?.follows
|
||||||
.map((c) => c.community.id)
|
.map((c) => c.community.id)
|
||||||
.includes(post.community.id)
|
.includes(post.community.id)
|
||||||
@@ -64,10 +68,18 @@
|
|||||||
</PostMeta>
|
</PostMeta>
|
||||||
<PostMedia bind:post={post.post} {view} {type} />
|
<PostMedia bind:post={post.post} {view} {type} />
|
||||||
{#if view == 'list' || view == 'compact'}
|
{#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}
|
||||||
{#if post.post.body && !post.post.nsfw && view != 'compact'}
|
{#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}
|
||||||
{#if actions}
|
{#if actions}
|
||||||
<PostActions
|
<PostActions
|
||||||
@@ -96,4 +108,4 @@
|
|||||||
grid-template-rows: 3;
|
grid-template-rows: 3;
|
||||||
grid-template-columns: 2;
|
grid-template-columns: 2;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
import { getInstance } from '$lib/lemmy.js'
|
import { getInstance } from '$lib/lemmy.js'
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import Subscribe from '../../../../routes/communities/Subscribe.svelte'
|
import Subscribe from '../../../../routes/communities/Subscribe.svelte'
|
||||||
|
import ShieldIcon from '../moderation/ShieldIcon.svelte'
|
||||||
|
|
||||||
export let community: Community | undefined = undefined
|
export let community: Community | undefined = undefined
|
||||||
export let subscribed: SubscribedType | undefined = undefined
|
export let subscribed: SubscribedType | undefined = undefined
|
||||||
@@ -27,12 +28,16 @@
|
|||||||
export let id: number | undefined = undefined
|
export let id: number | undefined = undefined
|
||||||
|
|
||||||
// Badges
|
// Badges
|
||||||
export let nsfw: boolean = false
|
export let badges = {
|
||||||
export let saved: boolean = false
|
nsfw: false,
|
||||||
export let featured: boolean = false
|
saved: false,
|
||||||
export let deleted: boolean = false
|
featured: false,
|
||||||
export let removed: boolean = false
|
deleted: false,
|
||||||
export let locked: boolean = false
|
removed: false,
|
||||||
|
locked: false,
|
||||||
|
moderator: false,
|
||||||
|
admin: false,
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -81,7 +86,16 @@
|
|||||||
style="grid-area: stats;"
|
style="grid-area: stats;"
|
||||||
>
|
>
|
||||||
{#if user}
|
{#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}
|
||||||
{#if published}
|
{#if published}
|
||||||
<RelativeDate date={published} />
|
<RelativeDate date={published} />
|
||||||
@@ -92,34 +106,34 @@
|
|||||||
class="flex flex-row items-center place-self-end overflow-auto [&>*]:flex-shrink-0"
|
class="flex flex-row items-center place-self-end overflow-auto [&>*]:flex-shrink-0"
|
||||||
style="grid-area: badges;"
|
style="grid-area: badges;"
|
||||||
>
|
>
|
||||||
{#if nsfw}
|
{#if badges.nsfw}
|
||||||
<Badge color="red-subtle">NSFW</Badge>
|
<Badge color="red-subtle">NSFW</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
{#if saved}
|
{#if badges.saved}
|
||||||
<Badge label="Saved" color="yellow-subtle">
|
<Badge label="Saved" color="yellow-subtle">
|
||||||
<Icon src={Bookmark} mini size="12" />
|
<Icon src={Bookmark} mini size="12" />
|
||||||
<span class="max-md:hidden">Saved</span>
|
<span class="max-md:hidden">Saved</span>
|
||||||
</Badge>
|
</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
{#if locked}
|
{#if badges.locked}
|
||||||
<Badge label="Locked" color="yellow-subtle">
|
<Badge label="Locked" color="yellow-subtle">
|
||||||
<Icon src={LockClosed} mini size="14" />
|
<Icon src={LockClosed} mini size="14" />
|
||||||
<span class="max-md:hidden">Locked</span>
|
<span class="max-md:hidden">Locked</span>
|
||||||
</Badge>
|
</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
{#if removed}
|
{#if badges.removed}
|
||||||
<Badge label="Removed" color="red-subtle">
|
<Badge label="Removed" color="red-subtle">
|
||||||
<Icon src={Trash} mini size="14" />
|
<Icon src={Trash} mini size="14" />
|
||||||
<span class="max-md:hidden">Removed</span>
|
<span class="max-md:hidden">Removed</span>
|
||||||
</Badge>
|
</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
{#if deleted}
|
{#if badges.deleted}
|
||||||
<Badge label="Deleted" color="red-subtle">
|
<Badge label="Deleted" color="red-subtle">
|
||||||
<Icon src={Trash} mini size="14" />
|
<Icon src={Trash} mini size="14" />
|
||||||
<span class="max-md:hidden">Deleted</span>
|
<span class="max-md:hidden">Deleted</span>
|
||||||
</Badge>
|
</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
{#if featured}
|
{#if badges.featured}
|
||||||
<Badge label="Featured" color="green-subtle">
|
<Badge label="Featured" color="green-subtle">
|
||||||
<Icon src={Megaphone} mini size="14" />
|
<Icon src={Megaphone} mini size="14" />
|
||||||
<span class="max-md:hidden">Featured</span>
|
<span class="max-md:hidden">Featured</span>
|
||||||
|
|||||||
@@ -45,5 +45,6 @@
|
|||||||
{#if user.bot_account}
|
{#if user.bot_account}
|
||||||
<div class="text-blue-500 font-bold" title="Bot">BOT</div>
|
<div class="text-blue-500 font-bold" title="Bot">BOT</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
<slot name="badges" />
|
||||||
{/if}
|
{/if}
|
||||||
</a>
|
</a>
|
||||||
@@ -168,14 +168,19 @@
|
|||||||
community={post.post_view.community}
|
community={post.post_view.community}
|
||||||
user={post.post_view.creator}
|
user={post.post_view.creator}
|
||||||
bind:subscribed={post.community_view.subscribed}
|
bind:subscribed={post.community_view.subscribed}
|
||||||
deleted={post.post_view.post.deleted}
|
badges={{
|
||||||
removed={post.post_view.post.removed}
|
deleted: post.post_view.post.deleted,
|
||||||
locked={post.post_view.post.locked}
|
removed: post.post_view.post.removed,
|
||||||
featured={post.post_view.post.featured_community ||
|
locked: post.post_view.post.locked,
|
||||||
post.post_view.post.featured_local}
|
featured:
|
||||||
nsfw={post.post_view.post.nsfw}
|
post.post_view.post.featured_community ||
|
||||||
|
post.post_view.post.featured_local,
|
||||||
|
nsfw: post.post_view.post.nsfw,
|
||||||
|
saved: post.post_view.saved,
|
||||||
|
admin: post.post_view.creator_is_admin,
|
||||||
|
moderator: post.post_view.creator_is_moderator,
|
||||||
|
}}
|
||||||
published={publishedToDate(post.post_view.post.published)}
|
published={publishedToDate(post.post_view.post.published)}
|
||||||
saved={post.post_view.saved}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Button on:click={() => history.back()} size="square-md">
|
<Button on:click={() => history.back()} size="square-md">
|
||||||
|
|||||||
Reference in new issue
Block a user