why the heck is the site card breaking
This commit is contained in:
1 parent
66eca58d01
commit
6181c5138a
10 files changed
+213
-228
No files matched your search
@@ -1,8 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
|
|
||||||
import Card from '$lib/components/ui/Card.svelte'
|
|
||||||
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||||
|
|||||||
@@ -141,13 +141,11 @@
|
|||||||
<span class="mx-4 text-xs opacity-80 text-left my-2">Post Actions</span>
|
<span class="mx-4 text-xs opacity-80 text-left my-2">Post Actions</span>
|
||||||
<MenuButton
|
<MenuButton
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
if (typeof navigator != 'undefined') {
|
navigator.clipboard.writeText(
|
||||||
navigator.clipboard.writeText(
|
`${$page.url.origin}/post/${
|
||||||
`${$page.url.origin}/post/${
|
$authData?.instance ?? DEFAULT_INSTANCE_URL
|
||||||
$authData?.instance ?? DEFAULT_INSTANCE_URL
|
}/${postRes.post.id}`
|
||||||
}/${postRes.post.id}`
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon src={Square2Stack} width={16} mini />
|
<Icon src={Square2Stack} width={16} mini />
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
|
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
||||||
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
|
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||||
|
import type { SiteView } from 'lemmy-js-client'
|
||||||
|
import {
|
||||||
|
Calendar,
|
||||||
|
ChatBubbleOvalLeftEllipsis,
|
||||||
|
Icon,
|
||||||
|
Newspaper,
|
||||||
|
PencilSquare,
|
||||||
|
UserGroup,
|
||||||
|
} from 'svelte-hero-icons'
|
||||||
|
|
||||||
|
export let site: SiteView
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<StickyCard>
|
||||||
|
<!-- {#if site.site.icon} -->
|
||||||
|
<!-- <Avatar width={64} url={site.site.icon} alt={site.site.name} /> -->
|
||||||
|
<!-- {/if} -->
|
||||||
|
<span class="flex flex-row items-center gap-1 text-sm">
|
||||||
|
<Icon src={Calendar} width={16} height={16} mini />
|
||||||
|
<RelativeDate date={new Date(site.site.published)} />
|
||||||
|
</span>
|
||||||
|
<div class="text-sm flex flex-row flex-wrap gap-3">
|
||||||
|
<span class="flex flex-row items-center gap-1">
|
||||||
|
<Icon src={UserGroup} width={16} height={16} mini />
|
||||||
|
<FormattedNumber number={site.counts.users} />
|
||||||
|
</span>
|
||||||
|
<span class="flex flex-row items-center gap-1">
|
||||||
|
<Icon src={PencilSquare} width={16} height={16} mini />
|
||||||
|
<FormattedNumber number={site.counts.posts} />
|
||||||
|
</span>
|
||||||
|
<span class="flex flex-row items-center gap-1">
|
||||||
|
<Icon src={ChatBubbleOvalLeftEllipsis} width={16} height={16} mini />
|
||||||
|
<FormattedNumber number={site.counts.comments} />
|
||||||
|
</span>
|
||||||
|
<span class="flex flex-row items-center gap-1">
|
||||||
|
<Icon src={Newspaper} width={16} height={16} mini />
|
||||||
|
<FormattedNumber number={site.counts.communities} />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h1 class="font-bold text-lg">{site.site.name}</h1>
|
||||||
|
</div>
|
||||||
|
<Markdown source={site.site.description} />
|
||||||
|
</StickyCard>
|
||||||
@@ -80,8 +80,10 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<li
|
<li
|
||||||
class="py-3 {$page.url.hash == `#${node.comment_view.comment.id}`
|
class="py-2 {$page.url.hash == `#${node.comment_view.comment.id}`
|
||||||
? 'bg-slate-200 dark:bg-zinc-800'
|
? 'bg-slate-200 dark:bg-zinc-800'
|
||||||
|
: ''} {node.depth == 0
|
||||||
|
? 'border-b border-black/10 dark:border-white/10'
|
||||||
: ''}"
|
: ''}"
|
||||||
id="#{node.comment_view.comment.id.toString()}"
|
id="#{node.comment_view.comment.id.toString()}"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -7,11 +7,13 @@
|
|||||||
export let source: string | undefined
|
export let source: string | undefined
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<SvelteMarkdown
|
<div class="break-words">
|
||||||
{source}
|
<SvelteMarkdown
|
||||||
renderers={{
|
{source}
|
||||||
link: MarkdownLink,
|
renderers={{
|
||||||
heading: MarkdownHeader,
|
link: MarkdownLink,
|
||||||
hr: MarkdownHr,
|
heading: MarkdownHeader,
|
||||||
}}
|
hr: MarkdownHr,
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
<div class="flex flex-row gap-2 items-center mr-auto">
|
<div class="flex flex-row gap-2 items-center mr-auto">
|
||||||
<a href="/" class="flex flex-row items-center gap-2">
|
<a href="/" class="flex flex-row items-center gap-2">
|
||||||
<Logo width={40} />
|
<Logo width={40} />
|
||||||
<div class="sm:flex flex-col hidden">
|
<div class="flex flex-col">
|
||||||
<span class="font-bold">Photon</span>
|
<span class="font-bold">Photon</span>
|
||||||
<span
|
<span
|
||||||
class="text-xs opacity-50
|
class="text-xs opacity-50
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div
|
<div
|
||||||
class="sticky top-20 border bg-white shadow-md border-slate-100
|
class="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-[20rem] min-w-[20rem] rounded-md h-max max-h-[calc(100vh-6rem)]
|
flex-col gap-4 p-8 max-w-[20rem] w-full flex-shrink-0 rounded-md h-max max-h-[calc(100vh-6rem)]
|
||||||
overflow-auto"
|
overflow-auto"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
|
|||||||
+33
-87
@@ -2,23 +2,10 @@
|
|||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
import Button from '$lib/components/input/Button.svelte'
|
import Button from '$lib/components/input/Button.svelte'
|
||||||
import Card from '$lib/components/ui/StickyCard.svelte'
|
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
||||||
import Link from '$lib/components/input/Link.svelte'
|
|
||||||
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
|
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
|
||||||
import {
|
|
||||||
Calendar,
|
|
||||||
ChatBubbleLeftEllipsis,
|
|
||||||
ChatBubbleOvalLeftEllipsis,
|
|
||||||
Icon,
|
|
||||||
Newspaper,
|
|
||||||
PencilSquare,
|
|
||||||
UserGroup,
|
|
||||||
} from 'svelte-hero-icons'
|
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
|
||||||
import Post from '$lib/components/lemmy/Post.svelte'
|
import Post from '$lib/components/lemmy/Post.svelte'
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
|
||||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
|
||||||
|
|
||||||
export let data
|
export let data
|
||||||
</script>
|
</script>
|
||||||
@@ -27,9 +14,9 @@
|
|||||||
<title>Xylemmy</title>
|
<title>Xylemmy</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div class="flex flex-row gap-4 justify-between">
|
<div class="flex flex-row gap-4 w-full">
|
||||||
<div class="flex flex-col gap-4 max-w-full w-full">
|
<div class="flex flex-col gap-4 max-w-full w-full">
|
||||||
<div class="flex flex-col sm:flex-row gap-4 max-w-full">
|
<div class="flex flex-col sm:flex-row gap-4 max-w-full w-full">
|
||||||
<MultiSelect
|
<MultiSelect
|
||||||
options={['Subscribed', 'Local', 'All']}
|
options={['Subscribed', 'Local', 'All']}
|
||||||
selected={$page.url.searchParams.get('type') ?? 'Local'}
|
selected={$page.url.searchParams.get('type') ?? 'Local'}
|
||||||
@@ -56,13 +43,11 @@
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex flex-col gap-4">
|
||||||
<div class="flex flex-col gap-4 w-full">
|
|
||||||
{#each data.posts.posts as post}
|
{#each data.posts.posts as post}
|
||||||
<Post {post} />
|
<Post {post} />
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
@@ -80,77 +65,38 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="hidden lg:block max-w-sm w-full">
|
{#await data.streamed.site}
|
||||||
{#await data.streamed.site}
|
<StickyCard>
|
||||||
<Card>
|
<div
|
||||||
<div
|
class="w-[64px] h-[64px] rounded-full bg-slate-200
|
||||||
class="w-[64px] h-[64px] rounded-full bg-slate-200
|
|
||||||
dark:bg-zinc-700 animate-pulse"
|
dark:bg-zinc-700 animate-pulse"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="w-32 h-3 bg-slate-200 dark:bg-zinc-700 animate-pulse
|
class="w-32 h-3 bg-slate-200 dark:bg-zinc-700 animate-pulse
|
||||||
rounded-md"
|
rounded-md"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="w-64 h-3 bg-slate-200 dark:bg-zinc-700 animate-pulse
|
class="w-64 h-3 bg-slate-200 dark:bg-zinc-700 animate-pulse
|
||||||
rounded-md"
|
rounded-md"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="w-36 mt-4 h-4 bg-slate-200 dark:bg-zinc-700 animate-pulse
|
class="w-36 mt-4 h-4 bg-slate-200 dark:bg-zinc-700 animate-pulse
|
||||||
rounded-md"
|
rounded-md"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="w-full h-4 bg-slate-200 dark:bg-zinc-700 animate-pulse
|
class="w-full h-4 bg-slate-200 dark:bg-zinc-700 animate-pulse
|
||||||
rounded-md"
|
rounded-md"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="w-24 h-4 bg-slate-200 dark:bg-zinc-700 animate-pulse
|
class="w-24 h-4 bg-slate-200 dark:bg-zinc-700 animate-pulse
|
||||||
rounded-md"
|
rounded-md"
|
||||||
/>
|
/>
|
||||||
</Card>
|
</StickyCard>
|
||||||
{:then site}
|
{:then site}
|
||||||
<Card>
|
<SiteCard site={site.site_view} />
|
||||||
{#if site.site_view.site.icon}
|
{:catch}
|
||||||
<Avatar
|
<StickyCard>
|
||||||
width={64}
|
<h1 class="font-bold text-lg">Failed to load</h1>
|
||||||
url={site.site_view.site.icon}
|
</StickyCard>
|
||||||
alt={site.site_view.site.name}
|
{/await}
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
<span class="flex flex-row items-center gap-1 text-sm capitalize">
|
|
||||||
<Icon src={Calendar} width={16} height={16} mini />
|
|
||||||
<RelativeDate date={new Date(site.site_view.site.published)} />
|
|
||||||
</span>
|
|
||||||
<div class="text-sm flex flex-row flex-wrap gap-3">
|
|
||||||
<span class="flex flex-row items-center gap-1">
|
|
||||||
<Icon src={UserGroup} width={16} height={16} mini />
|
|
||||||
<FormattedNumber number={site.site_view.counts.users} />
|
|
||||||
</span>
|
|
||||||
<span class="flex flex-row items-center gap-1">
|
|
||||||
<Icon src={PencilSquare} width={16} height={16} mini />
|
|
||||||
<FormattedNumber number={site.site_view.counts.posts} />
|
|
||||||
</span>
|
|
||||||
<span class="flex flex-row items-center gap-1">
|
|
||||||
<Icon
|
|
||||||
src={ChatBubbleOvalLeftEllipsis}
|
|
||||||
width={16}
|
|
||||||
height={16}
|
|
||||||
mini
|
|
||||||
/>
|
|
||||||
<FormattedNumber number={site.site_view.counts.comments} />
|
|
||||||
</span>
|
|
||||||
<span class="flex flex-row items-center gap-1">
|
|
||||||
<Icon src={Newspaper} width={16} height={16} mini />
|
|
||||||
<FormattedNumber number={site.site_view.counts.communities} />
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<h1 class="font-bold text-lg">{site.site_view.site.name}</h1>
|
|
||||||
<Markdown source={site.site_view.site.description ?? ''} />
|
|
||||||
</Card>
|
|
||||||
{:catch}
|
|
||||||
<Card>
|
|
||||||
<h1 class="font-bold text-lg">Failed to load</h1>
|
|
||||||
</Card>
|
|
||||||
{/await}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
@@ -6,22 +6,16 @@
|
|||||||
import Avatar from '../../../lib/components/ui/Avatar.svelte'
|
import Avatar from '../../../lib/components/ui/Avatar.svelte'
|
||||||
import Post from '../../../lib/components/lemmy/Post.svelte'
|
import Post from '../../../lib/components/lemmy/Post.svelte'
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
|
||||||
import {
|
|
||||||
Calendar,
|
|
||||||
ChatBubbleOvalLeftEllipsis,
|
|
||||||
Icon,
|
|
||||||
Newspaper,
|
|
||||||
PencilSquare,
|
|
||||||
UserGroup,
|
|
||||||
} from 'svelte-hero-icons'
|
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
|
||||||
import Card from '$lib/components/ui/StickyCard.svelte'
|
import Card from '$lib/components/ui/StickyCard.svelte'
|
||||||
import CommunityCard from '$lib/components/community/CommunityCard.svelte'
|
import CommunityCard from '$lib/components/community/CommunityCard.svelte'
|
||||||
|
|
||||||
export let data
|
export let data
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<title>{data.posts.posts[0]?.community.name}</title>
|
||||||
|
</svelte:head>
|
||||||
|
|
||||||
<div class="flex flex-row gap-4 w-full">
|
<div class="flex flex-row gap-4 w-full">
|
||||||
<div class="flex flex-col gap-4 max-w-full w-full">
|
<div class="flex flex-col gap-4 max-w-full w-full">
|
||||||
<div class="flex flex-col sm:flex-row gap-4 max-w-full w-full">
|
<div class="flex flex-col sm:flex-row gap-4 max-w-full w-full">
|
||||||
|
|||||||
@@ -101,117 +101,112 @@
|
|||||||
<title>{data.post.post_view.post.name}</title>
|
<title>{data.post.post_view.post.name}</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div class="flex flex-row gap-4">
|
<div class="flex flex-col gap-2">
|
||||||
<div>
|
<span class="flex flex-row gap-2 text-sm items-center">
|
||||||
<div class="flex flex-col gap-2">
|
<Avatar
|
||||||
<span class="flex flex-row gap-2 text-sm opacity-80 items-center">
|
url={postData.community.icon}
|
||||||
<Avatar
|
width={24}
|
||||||
url={postData.community.icon}
|
alt={postData.community.name}
|
||||||
width={24}
|
/>
|
||||||
alt={postData.community.name}
|
<div class="flex flex-col text-xs">
|
||||||
/>
|
<CommunityLink community={postData.community} />
|
||||||
<div class="flex flex-col text-xs">
|
<span class="opacity-50 flex flex-row gap-1">
|
||||||
<CommunityLink community={postData.community} />
|
<UserLink user={postData.creator} />
|
||||||
<span class="opacity-50 flex flex-row gap-1">
|
<span>•</span>
|
||||||
<UserLink user={postData.creator} />
|
<RelativeDate date={new Date(postData.post.published)} />
|
||||||
<span>•</span>
|
<span>•</span>
|
||||||
<RelativeDate date={new Date(postData.post.published)} />
|
<span>
|
||||||
<span>•</span>
|
{Math.floor(
|
||||||
<span>
|
(data.post.post_view.counts.upvotes /
|
||||||
{Math.floor(
|
(data.post.post_view.counts.upvotes +
|
||||||
(data.post.post_view.counts.upvotes /
|
data.post.post_view.counts.downvotes || 1)) *
|
||||||
(data.post.post_view.counts.upvotes +
|
100
|
||||||
data.post.post_view.counts.downvotes || 1)) *
|
)}%
|
||||||
100
|
|
||||||
)}%
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</span>
|
|
||||||
<h1 class="font-bold text-lg">{post.name}</h1>
|
|
||||||
{#if post.url}
|
|
||||||
<a
|
|
||||||
href={post.url}
|
|
||||||
class="text-sky-400 max-w-[48ch] overflow-hidden
|
|
||||||
whitespace-nowrap text-ellipsis text-xs hover:underline"
|
|
||||||
>
|
|
||||||
{post.url}
|
|
||||||
</a>
|
|
||||||
{/if}
|
|
||||||
{#if isImage(post.url)}
|
|
||||||
<img
|
|
||||||
src={post.url}
|
|
||||||
alt={post.name}
|
|
||||||
class="rounded-md max-w-screen max-h-[80vh] mx-auto"
|
|
||||||
/>
|
|
||||||
{:else if isVideo(post.url)}
|
|
||||||
<!-- svelte-ignore a11y-media-has-caption -->
|
|
||||||
<video class="rounded-md max-w-screen max-h-[80vh] mx-auto">
|
|
||||||
<source src={post.url} />
|
|
||||||
</video>
|
|
||||||
{/if}
|
|
||||||
{#if post.body}
|
|
||||||
<p
|
|
||||||
class="bg-slate-100 border border-slate-200 dark:border-zinc-800
|
|
||||||
dark:bg-zinc-900 p-2 text-sm rounded-md leading-5"
|
|
||||||
>
|
|
||||||
<Markdown source={post.body} />
|
|
||||||
</p>
|
|
||||||
{/if}
|
|
||||||
<div class="w-max">
|
|
||||||
<PostVote
|
|
||||||
post={data.post.post_view.post}
|
|
||||||
score={data.post.post_view.counts.score}
|
|
||||||
vote={data.post.post_view.my_vote}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</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}
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</span>
|
||||||
{#await data.streamed.comments}
|
|
||||||
<div class="flex flex-col gap-8">
|
|
||||||
{#each new Array(10) as comment}
|
|
||||||
<div class="flex flex-col gap-2">
|
|
||||||
<div
|
|
||||||
class="dark:bg-zinc-700 bg-slate-200 animate-pulse w-64 h-3 rounded-md"
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
class="dark:bg-zinc-700 bg-slate-200 animate-pulse w-128 h-4 rounded-md"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
{:then comments}
|
|
||||||
{#if $user}
|
|
||||||
<CommentForm
|
|
||||||
postId={post.id}
|
|
||||||
on:comment={(comment) =>
|
|
||||||
(comments.comments = [
|
|
||||||
comment.detail.comment_view,
|
|
||||||
...comments.comments,
|
|
||||||
])}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
<MultiSelect
|
|
||||||
options={['hot', 'new', 'top']}
|
|
||||||
optionNames={['Hot', 'New', 'Top']}
|
|
||||||
selected="hot"
|
|
||||||
/>
|
|
||||||
<Comments
|
|
||||||
{post}
|
|
||||||
nodes={buildCommentsTree(comments.comments, false)}
|
|
||||||
isParent={true}
|
|
||||||
/>
|
|
||||||
{:catch}
|
|
||||||
<div class="bg-red-500/10 border border-red-500 rounded-md p-4">
|
|
||||||
Failed to load comments.
|
|
||||||
</div>
|
|
||||||
{/await}
|
|
||||||
</div>
|
</div>
|
||||||
|
</span>
|
||||||
|
<h1 class="font-bold text-lg">{post.name}</h1>
|
||||||
|
{#if post.url}
|
||||||
|
<a
|
||||||
|
href={post.url}
|
||||||
|
class="text-sky-400 max-w-[48ch] overflow-hidden
|
||||||
|
whitespace-nowrap text-ellipsis text-xs hover:underline"
|
||||||
|
>
|
||||||
|
{post.url}
|
||||||
|
</a>
|
||||||
|
{/if}
|
||||||
|
{#if isImage(post.url)}
|
||||||
|
<img
|
||||||
|
src={post.url}
|
||||||
|
alt={post.name}
|
||||||
|
class="rounded-md max-w-screen max-h-[80vh] mx-auto"
|
||||||
|
/>
|
||||||
|
{:else if isVideo(post.url)}
|
||||||
|
<!-- svelte-ignore a11y-media-has-caption -->
|
||||||
|
<video class="rounded-md max-w-screen max-h-[80vh] mx-auto">
|
||||||
|
<source src={post.url} />
|
||||||
|
</video>
|
||||||
|
{/if}
|
||||||
|
{#if post.body}
|
||||||
|
<p
|
||||||
|
class="bg-slate-100 border border-slate-200 dark:border-zinc-800
|
||||||
|
dark:bg-zinc-900 p-2 text-sm rounded-md leading-5"
|
||||||
|
>
|
||||||
|
<Markdown source={post.body} />
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
<div class="w-max">
|
||||||
|
<PostVote
|
||||||
|
post={data.post.post_view.post}
|
||||||
|
score={data.post.post_view.counts.score}
|
||||||
|
vote={data.post.post_view.my_vote}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<CommunityCard community_view={data.post.community_view} />
|
</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}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{#await data.streamed.comments}
|
||||||
|
<div class="flex flex-col gap-8">
|
||||||
|
{#each new Array(10) as comment}
|
||||||
|
<div class="flex flex-col gap-2">
|
||||||
|
<div
|
||||||
|
class="dark:bg-zinc-700 bg-slate-200 animate-pulse w-64 h-3 rounded-md"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="dark:bg-zinc-700 bg-slate-200 animate-pulse w-128 h-4 rounded-md"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{:then comments}
|
||||||
|
{#if $user}
|
||||||
|
<CommentForm
|
||||||
|
postId={post.id}
|
||||||
|
on:comment={(comment) =>
|
||||||
|
(comments.comments = [
|
||||||
|
comment.detail.comment_view,
|
||||||
|
...comments.comments,
|
||||||
|
])}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
<MultiSelect
|
||||||
|
options={['hot', 'new', 'top']}
|
||||||
|
optionNames={['Hot', 'New', 'Top']}
|
||||||
|
selected="hot"
|
||||||
|
/>
|
||||||
|
<Comments
|
||||||
|
{post}
|
||||||
|
nodes={buildCommentsTree(comments.comments, false)}
|
||||||
|
isParent={true}
|
||||||
|
/>
|
||||||
|
{:catch}
|
||||||
|
<div class="bg-red-500/10 border border-red-500 rounded-md p-4">
|
||||||
|
Failed to load comments.
|
||||||
|
</div>
|
||||||
|
{/await}
|
||||||
</div>
|
</div>
|
||||||
Reference in new issue
Block a user