feat: Add controversial badge to posts
This commit is contained in:
1 parent
bcc8ae2c73
commit
953c65021e
2 files changed
+30
-22
No files matched your search
@@ -11,6 +11,7 @@
|
|||||||
import Badge from '$lib/components/ui/Badge.svelte'
|
import Badge from '$lib/components/ui/Badge.svelte'
|
||||||
import {
|
import {
|
||||||
Bookmark,
|
Bookmark,
|
||||||
|
HandThumbDown,
|
||||||
Icon,
|
Icon,
|
||||||
InformationCircle,
|
InformationCircle,
|
||||||
Link,
|
Link,
|
||||||
@@ -44,24 +45,32 @@
|
|||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{#if postRes.post.nsfw}
|
<!-- Badges -->
|
||||||
<Badge class="bg-red-600 text-white">NSFW</Badge>
|
<div class="flex flex-row ml-auto gap-2">
|
||||||
{/if}
|
{#if postRes.post.nsfw}
|
||||||
{#if postRes.saved}
|
<Badge class="bg-red-600 text-white">NSFW</Badge>
|
||||||
<Badge class="bg-yellow-500 text-white py-1" label="Saved">
|
{/if}
|
||||||
<Icon src={Bookmark} mini width={16} />
|
{#if postRes.counts.score < 0 && postRes.counts.upvotes > 3 && postRes.counts.downvotes > 3}
|
||||||
</Badge>
|
<Badge class="bg-purple-400 text-white py-1" label="Controversial">
|
||||||
{/if}
|
<Icon src={HandThumbDown} mini width={16} />
|
||||||
{#if postRes.post.deleted || postRes.post.removed}
|
</Badge>
|
||||||
<Badge class="bg-red-600 text-white py-1" label="Deleted">
|
{/if}
|
||||||
<Icon src={Trash} mini width={16} />
|
{#if postRes.saved}
|
||||||
</Badge>
|
<Badge class="bg-yellow-500 text-white py-1" label="Saved">
|
||||||
{/if}
|
<Icon src={Bookmark} mini width={16} />
|
||||||
{#if postRes.post.featured_community || postRes.post.featured_local}
|
</Badge>
|
||||||
<Badge class="bg-green-500 text-white py-1" label="Pinned">
|
{/if}
|
||||||
<Icon src={InformationCircle} mini width={16} />
|
{#if postRes.post.deleted || postRes.post.removed}
|
||||||
</Badge>
|
<Badge class="bg-red-600 text-white py-1" label="Deleted">
|
||||||
{/if}
|
<Icon src={Trash} mini width={16} />
|
||||||
|
</Badge>
|
||||||
|
{/if}
|
||||||
|
{#if postRes.post.featured_community || postRes.post.featured_local}
|
||||||
|
<Badge class="bg-green-500 text-white py-1" label="Pinned">
|
||||||
|
<Icon src={InformationCircle} mini width={16} />
|
||||||
|
</Badge>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
</span>
|
</span>
|
||||||
<a
|
<a
|
||||||
href="/post/{getInstance()}/{postRes.post.id}"
|
href="/post/{getInstance()}/{postRes.post.id}"
|
||||||
@@ -118,7 +127,8 @@
|
|||||||
<span
|
<span
|
||||||
class="w-full px-4 py-2 overflow-hidden
|
class="w-full px-4 py-2 overflow-hidden
|
||||||
whitespace-nowrap text-ellipsis text-sm group-hover:underline bg-slate-100 border
|
whitespace-nowrap text-ellipsis text-sm group-hover:underline bg-slate-100 border
|
||||||
absolute bottom-0 rounded-b-md flex flex-row gap-1 items-center"
|
dark:border-zinc-700
|
||||||
|
dark:bg-zinc-800 absolute bottom-0 rounded-b-md flex flex-row gap-1 items-center"
|
||||||
>
|
>
|
||||||
<Icon src={Link} width={16} mini />
|
<Icon src={Link} width={16} mini />
|
||||||
{new URL(postRes.post.url).hostname}
|
{new URL(postRes.post.url).hostname}
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
import { Color } from '$lib/ui/colors.js'
|
import { Color } from '$lib/ui/colors.js'
|
||||||
import { fly } from 'svelte/transition'
|
import { fly } from 'svelte/transition'
|
||||||
|
|
||||||
const maxComments = 250
|
|
||||||
|
|
||||||
export let nodes: CommentNodeI[]
|
export let nodes: CommentNodeI[]
|
||||||
export let isParent: boolean
|
export let isParent: boolean
|
||||||
export let post: Post
|
export let post: Post
|
||||||
@@ -64,7 +62,7 @@
|
|||||||
? ''
|
? ''
|
||||||
: 'ml-2.5 mt-2 pl-2.5 border-l-2 border-black/10 dark:border-white/10'}
|
: 'ml-2.5 mt-2 pl-2.5 border-l-2 border-black/10 dark:border-white/10'}
|
||||||
>
|
>
|
||||||
{#each nodes.slice(0, maxComments) as node (node.comment_view.comment.id)}
|
{#each nodes as node (node.comment_view.comment.id)}
|
||||||
<Comment
|
<Comment
|
||||||
postId={post.id}
|
postId={post.id}
|
||||||
{node}
|
{node}
|
||||||
|
|||||||
Reference in new issue
Block a user