feat: Add upvote %

This commit is contained in:
Xyphyn committed 2023-07-06 13:28:38 -07:00
1 parent 71ca33d9fc
commit 54b1cef68f
3 files changed
+27 -5

No files matched your search

+8
View File
@@ -61,6 +61,14 @@
<UserLink user={postRes.creator} />
<span>•</span>
<RelativeDate date={new Date(postRes.post.published)} />
<span>•</span>
<span>
{Math.floor(
(postRes.counts.upvotes /
(postRes.counts.upvotes + postRes.counts.downvotes || 1)) *
100
)}%
</span>
</span>
</div>
<div class="ml-auto" />
+2 -2
View File
@@ -1,8 +1,8 @@
<div
class="sticky top-20 border bg-white shadow-md border-slate-100
dark:border-zinc-800 dark:bg-zinc-900 break-words hidden lg:flex
flex-col gap-4 p-8 max-w-sm rounded-md h-max max-h-[calc(100vh-6rem)]
overflow-auto w-full"
flex-col gap-4 p-8 max-w-[20rem] min-w-[20rem] rounded-md h-max max-h-[calc(100vh-6rem)]
overflow-auto"
>
<slot />
</div>
+17 -3
View File
@@ -101,7 +101,9 @@
<title>{data.post.post_view.post.name}</title>
</svelte:head>
<div class="flex flex-col gap-2">
<div class="flex flex-row gap-4">
<div>
<div class="flex flex-col gap-2">
<span class="flex flex-row gap-2 text-sm opacity-80 items-center">
<Avatar
url={postData.community.icon}
@@ -114,6 +116,15 @@
<UserLink user={postData.creator} />
<span>•</span>
<RelativeDate date={new Date(postData.post.published)} />
<span>•</span>
<span>
{Math.floor(
(data.post.post_view.counts.upvotes /
(data.post.post_view.counts.upvotes +
data.post.post_view.counts.downvotes || 1)) *
100
)}%
</span>
</span>
</div>
</span>
@@ -154,8 +165,8 @@
vote={data.post.post_view.my_vote}
/>
</div>
</div>
<div class="mt-4 flex flex-col gap-2">
</div>
<div class="mt-4 flex flex-col gap-2">
<div class="font-bold text-lg">
Comments <span class="text-sm font-normal ml-2 opacity-80">
{postData.counts.comments}
@@ -200,4 +211,7 @@
Failed to load comments.
</div>
{/await}
</div>
</div>
<CommunityCard community_view={data.post.community_view} />
</div>