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
+12 -4

No files matched your search

+11 -1
View File
@@ -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,9 +45,16 @@
</span> </span>
</span> </span>
</div> </div>
<!-- Badges -->
<div class="flex flex-row ml-auto gap-2">
{#if postRes.post.nsfw} {#if postRes.post.nsfw}
<Badge class="bg-red-600 text-white">NSFW</Badge> <Badge class="bg-red-600 text-white">NSFW</Badge>
{/if} {/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} {#if postRes.saved}
<Badge class="bg-yellow-500 text-white py-1" label="Saved"> <Badge class="bg-yellow-500 text-white py-1" label="Saved">
<Icon src={Bookmark} mini width={16} /> <Icon src={Bookmark} mini width={16} />
@@ -62,6 +70,7 @@
<Icon src={InformationCircle} mini width={16} /> <Icon src={InformationCircle} mini width={16} />
</Badge> </Badge>
{/if} {/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}