feat: Add upvote %
This commit is contained in:
1 parent
71ca33d9fc
commit
54b1cef68f
3 files changed
+27
-5
No files matched your search
@@ -61,6 +61,14 @@
|
|||||||
<UserLink user={postRes.creator} />
|
<UserLink user={postRes.creator} />
|
||||||
<span>•</span>
|
<span>•</span>
|
||||||
<RelativeDate date={new Date(postRes.post.published)} />
|
<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>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="ml-auto" />
|
<div class="ml-auto" />
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<div
|
<div
|
||||||
class="sticky top-20 border bg-white shadow-md border-slate-100
|
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
|
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)]
|
flex-col gap-4 p-8 max-w-[20rem] min-w-[20rem] rounded-md h-max max-h-[calc(100vh-6rem)]
|
||||||
overflow-auto w-full"
|
overflow-auto"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
@@ -101,7 +101,9 @@
|
|||||||
<title>{data.post.post_view.post.name}</title>
|
<title>{data.post.post_view.post.name}</title>
|
||||||
</svelte:head>
|
</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">
|
<span class="flex flex-row gap-2 text-sm opacity-80 items-center">
|
||||||
<Avatar
|
<Avatar
|
||||||
url={postData.community.icon}
|
url={postData.community.icon}
|
||||||
@@ -114,6 +116,15 @@
|
|||||||
<UserLink user={postData.creator} />
|
<UserLink user={postData.creator} />
|
||||||
<span>•</span>
|
<span>•</span>
|
||||||
<RelativeDate date={new Date(postData.post.published)} />
|
<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>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
@@ -154,8 +165,8 @@
|
|||||||
vote={data.post.post_view.my_vote}
|
vote={data.post.post_view.my_vote}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-4 flex flex-col gap-2">
|
<div class="mt-4 flex flex-col gap-2">
|
||||||
<div class="font-bold text-lg">
|
<div class="font-bold text-lg">
|
||||||
Comments <span class="text-sm font-normal ml-2 opacity-80">
|
Comments <span class="text-sm font-normal ml-2 opacity-80">
|
||||||
{postData.counts.comments}
|
{postData.counts.comments}
|
||||||
@@ -200,4 +211,7 @@
|
|||||||
Failed to load comments.
|
Failed to load comments.
|
||||||
</div>
|
</div>
|
||||||
{/await}
|
{/await}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<CommunityCard community_view={data.post.community_view} />
|
||||||
</div>
|
</div>
|
||||||
Reference in new issue
Block a user