feat: Add controversial badge to posts

This commit is contained in:
Xyphyn committed 2023-07-17 11:02:17 -07:00
1 parent bcc8ae2c73
commit 953c65021e
2 files changed
+30 -22

No files matched your search

+29 -19
View File
@@ -11,6 +11,7 @@
import Badge from '$lib/components/ui/Badge.svelte'
import {
Bookmark,
HandThumbDown,
Icon,
InformationCircle,
Link,
@@ -44,24 +45,32 @@
</span>
</span>
</div>
{#if postRes.post.nsfw}
<Badge class="bg-red-600 text-white">NSFW</Badge>
{/if}
{#if postRes.saved}
<Badge class="bg-yellow-500 text-white py-1" label="Saved">
<Icon src={Bookmark} mini width={16} />
</Badge>
{/if}
{#if postRes.post.deleted || postRes.post.removed}
<Badge class="bg-red-600 text-white py-1" label="Deleted">
<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}
<!-- Badges -->
<div class="flex flex-row ml-auto gap-2">
{#if postRes.post.nsfw}
<Badge class="bg-red-600 text-white">NSFW</Badge>
{/if}
{#if postRes.counts.score < 0 && postRes.counts.upvotes > 3 && postRes.counts.downvotes > 3}
<Badge class="bg-purple-400 text-white py-1" label="Controversial">
<Icon src={HandThumbDown} mini width={16} />
</Badge>
{/if}
{#if postRes.saved}
<Badge class="bg-yellow-500 text-white py-1" label="Saved">
<Icon src={Bookmark} mini width={16} />
</Badge>
{/if}
{#if postRes.post.deleted || postRes.post.removed}
<Badge class="bg-red-600 text-white py-1" label="Deleted">
<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>
<a
href="/post/{getInstance()}/{postRes.post.id}"
@@ -118,7 +127,8 @@
<span
class="w-full px-4 py-2 overflow-hidden
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 />
{new URL(postRes.post.url).hostname}
@@ -10,8 +10,6 @@
import { Color } from '$lib/ui/colors.js'
import { fly } from 'svelte/transition'
const maxComments = 250
export let nodes: CommentNodeI[]
export let isParent: boolean
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'}
>
{#each nodes.slice(0, maxComments) as node (node.comment_view.comment.id)}
{#each nodes as node (node.comment_view.comment.id)}
<Comment
postId={post.id}
{node}