i forgot whatever i've been doing, i think i added an inbox
This commit is contained in:
1 parent
ef037349f0
commit
04704749b7
24 files changed
+307
-86
No files matched your search
@@ -0,0 +1,120 @@
|
||||
<script lang="ts">
|
||||
import type {
|
||||
CommentView,
|
||||
GetPostResponse,
|
||||
PostView,
|
||||
Comment,
|
||||
} from 'lemmy-js-client'
|
||||
import {
|
||||
ArrowDown,
|
||||
ArrowUp,
|
||||
ChatBubbleLeft,
|
||||
ChatBubbleOvalLeft,
|
||||
ChatBubbleOvalLeftEllipsis,
|
||||
ChevronDown,
|
||||
ChevronUp,
|
||||
Icon,
|
||||
} from 'svelte-hero-icons'
|
||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||
import CommunityLink from '$lib/components/community/CommunityLink.svelte'
|
||||
import { isImage } from '$lib/ui/image.js'
|
||||
import { authData, getClient } from '$lib/lemmy.js'
|
||||
import PostVote from '$lib/components/lemmy/PostVote.svelte'
|
||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||
|
||||
let postRes: PostView
|
||||
export { postRes as post }
|
||||
|
||||
let vote = postRes.my_vote
|
||||
|
||||
async function upvote() {
|
||||
if (!$authData) return
|
||||
|
||||
const upvoted = postRes.my_vote == 1
|
||||
|
||||
await getClient()
|
||||
.likePost({
|
||||
score: upvoted ? 0 : 1,
|
||||
auth: $authData.token,
|
||||
post_id: postRes.post.id,
|
||||
})
|
||||
.catch((_) => undefined)
|
||||
}
|
||||
|
||||
async function downvote() {
|
||||
if (!$authData) return
|
||||
|
||||
const upvoted = postRes.my_vote == -1
|
||||
|
||||
await getClient()
|
||||
.likePost({
|
||||
score: upvoted ? 0 : -1,
|
||||
auth: $authData.token,
|
||||
post_id: postRes.post.id,
|
||||
})
|
||||
.catch((_) => undefined)
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="bg-white dark:bg-zinc-900 border dark:border-zinc-800 border-slate-200
|
||||
rounded-md flex flex-col overflow-hidden max-w-xl w-full"
|
||||
>
|
||||
<div class="flex flex-col gap-2 bg-white dark:bg-zinc-900 p-4 rounded-md">
|
||||
<span class="flex flex-row gap-2 text-sm opacity-80 items-center">
|
||||
<CommunityLink avatar community={postRes.community} />
|
||||
<div class="ml-auto" />
|
||||
<span class="opacity-50">{postRes.creator.name}</span>
|
||||
<span class="opacity-50">
|
||||
<RelativeDate date={new Date(postRes.post.published)} />
|
||||
</span>
|
||||
</span>
|
||||
<a href="/post/{postRes.post.id}" class="font-bold text-lg">
|
||||
{postRes.post.name}
|
||||
</a>
|
||||
{#if postRes.post.url}
|
||||
<a
|
||||
href={postRes.post.url}
|
||||
class="text-sky-400 max-w-[24ch] overflow-hidden
|
||||
whitespace-nowrap text-ellipsis text-xs hover:underline"
|
||||
>
|
||||
{postRes.post.url}
|
||||
</a>
|
||||
{/if}
|
||||
{#if isImage(postRes.post.url)}
|
||||
<a href="/post/{postRes.post.id}" class="inline self-start">
|
||||
<img
|
||||
src={postRes.post.url}
|
||||
alt={postRes.post.name}
|
||||
class="rounded-md max-h-64 max-w-full"
|
||||
loading="lazy"
|
||||
/>
|
||||
</a>
|
||||
{/if}
|
||||
{#if postRes.post.body}
|
||||
<p class="text-sm max-h-24 line-clamp-3">
|
||||
{postRes.post.body}
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="flex flex-row gap-2 pb-4 px-4">
|
||||
<PostVote
|
||||
post={postRes.post}
|
||||
vote={postRes.my_vote}
|
||||
score={postRes.counts.score}
|
||||
/>
|
||||
|
||||
<a
|
||||
class="flex flex-row items-center gap-1 p-1.5 px-3 rounded-md
|
||||
bg-slate-100 dark:bg-zinc-900 hover:bg-slate-200
|
||||
dark:hover:bg-zinc-700 transition-colors border border-slate-200
|
||||
dark:border-zinc-800"
|
||||
href="/post/{postRes.post.id}"
|
||||
>
|
||||
<Icon src={ChatBubbleOvalLeft} mini width={16} height={16} />
|
||||
<span class="text-sm">
|
||||
<FormattedNumber number={postRes.counts.comments} />
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
Reference in new issue
Block a user