html: make post page more semantic
This commit is contained in:
1 parent
70a3a1610b
commit
f353e26f87
1 file changed
+86
-68
@@ -18,6 +18,7 @@
|
|||||||
Icon,
|
Icon,
|
||||||
InformationCircle,
|
InformationCircle,
|
||||||
Home,
|
Home,
|
||||||
|
PlusCircle,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
|
import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
|
||||||
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
||||||
@@ -44,6 +45,7 @@
|
|||||||
import { t } from '$lib/translations.js'
|
import { t } from '$lib/translations.js'
|
||||||
import { createWindowVirtualizer } from '@tanstack/svelte-virtual'
|
import { createWindowVirtualizer } from '@tanstack/svelte-virtual'
|
||||||
import { resumables } from '$lib/lemmy/item.js'
|
import { resumables } from '$lib/lemmy/item.js'
|
||||||
|
import { contentPadding } from '$lib/components/ui/layout/Shell.svelte'
|
||||||
|
|
||||||
export let data
|
export let data
|
||||||
|
|
||||||
@@ -156,12 +158,22 @@
|
|||||||
<meta property="twitter:card" content={post.post_view.post.thumbnail_url} />
|
<meta property="twitter:card" content={post.post_view.post.thumbnail_url} />
|
||||||
{/if}
|
{/if}
|
||||||
{#if post.post_view.post.body}
|
{#if post.post_view.post.body}
|
||||||
<meta property="og:description" content={post.post_view.post.body} />
|
<meta
|
||||||
<meta property="twitter:description" content={post.post_view.post.body} />
|
property="description"
|
||||||
|
content={post.post_view.post.body.slice(0, 500)}
|
||||||
|
/>
|
||||||
|
<meta
|
||||||
|
property="og:description"
|
||||||
|
content={post.post_view.post.body.slice(0, 500)}
|
||||||
|
/>
|
||||||
|
<meta
|
||||||
|
property="twitter:description"
|
||||||
|
content={post.post_view.post.body.slice(0, 500)}
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div class="flex flex-col gap-2">
|
<article class="flex flex-col gap-2">
|
||||||
{#if remoteView}
|
{#if remoteView}
|
||||||
<div
|
<div
|
||||||
class="sticky top-0 bg-slate-50 dark:bg-zinc-950 z-20
|
class="sticky top-0 bg-slate-50 dark:bg-zinc-950 z-20
|
||||||
@@ -199,8 +211,8 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="flex flex-row justify-between items-center gap-2 flex-wrap">
|
<header class="flex flex-col gap-2">
|
||||||
<div class="w-max">
|
<div class="flex flex-row justify-between items-center gap-2 flex-wrap">
|
||||||
<PostMeta
|
<PostMeta
|
||||||
community={post.post_view.community}
|
community={post.post_view.community}
|
||||||
user={post.post_view.creator}
|
user={post.post_view.creator}
|
||||||
@@ -219,15 +231,16 @@
|
|||||||
}}
|
}}
|
||||||
published={publishedToDate(post.post_view.post.published)}
|
published={publishedToDate(post.post_view.post.published)}
|
||||||
bind:title={post.post_view.post.name}
|
bind:title={post.post_view.post.name}
|
||||||
|
style="width: max-content;"
|
||||||
/>
|
/>
|
||||||
|
<Button on:click={() => history.back()} size="square-md">
|
||||||
|
<Icon src={ArrowLeft} mini size="16" slot="prefix" />
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<Button on:click={() => history.back()} size="square-md">
|
<h1 class="font-bold text-xl font-display leading-5">
|
||||||
<Icon src={ArrowLeft} mini size="16" slot="prefix" />
|
<Markdown source={post.post_view.post.name} inline />
|
||||||
</Button>
|
</h1>
|
||||||
</div>
|
</header>
|
||||||
<h1 class="font-bold text-xl font-display leading-5">
|
|
||||||
<Markdown source={post.post_view.post.name} inline />
|
|
||||||
</h1>
|
|
||||||
<PostMedia
|
<PostMedia
|
||||||
type={mediaType(post.post_view.post.url)}
|
type={mediaType(post.post_view.post.url)}
|
||||||
post={post.post_view.post}
|
post={post.post_view.post}
|
||||||
@@ -270,45 +283,38 @@
|
|||||||
</div>
|
</div>
|
||||||
</Expandable>
|
</Expandable>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</article>
|
||||||
{#if data.thread.showContext}
|
{#if data.thread.showContext || data.thread.singleThread}
|
||||||
<Material
|
<div
|
||||||
elevation="max"
|
class="sticky mx-auto z-50 max-w-full min-w-0 flex items-center gap-8 overflow-auto
|
||||||
padding="none"
|
bg-slate-50/50 dark:bg-zinc-900/50 backdrop-blur-xl border border-slate-100/50 dark:border-zinc-800/50
|
||||||
color="distinct"
|
p-1 rounded-full px-2"
|
||||||
class="py-2 px-4 text-sm flex flex-row justify-between items-center
|
style="top: max(1.5rem, {$contentPadding.top}px);"
|
||||||
flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
|
|
||||||
>
|
>
|
||||||
<p class="font-medium text-sm flex items-center gap-2">
|
<p class="font-medium text-sm flex items-center gap-2">
|
||||||
<Icon src={InformationCircle} mini size="20" />
|
<Icon src={InformationCircle} mini size="20" />
|
||||||
{$t('routes.post.thread.part')}
|
{data.thread.showContext
|
||||||
|
? $t('routes.post.thread.part')
|
||||||
|
: $t('routes.post.thread.single')}
|
||||||
</p>
|
</p>
|
||||||
<Button
|
<Button
|
||||||
|
color="none"
|
||||||
|
rounding="pill"
|
||||||
{loading}
|
{loading}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
href="/comment/{$page.params.instance}/{data.thread.showContext}"
|
href={data.thread.showContext
|
||||||
|
? `/comment/${$page.params.instance}/${data.thread.showContext}`
|
||||||
|
: undefined}
|
||||||
|
class="hover:bg-slate-200/30 dark:hover:bg-zinc-800/30"
|
||||||
|
on:click={data.thread.singleThread ? reloadComments : undefined}
|
||||||
>
|
>
|
||||||
{$t('routes.post.thread.context')}
|
{data.thread.showContext
|
||||||
|
? $t('routes.post.thread.context')
|
||||||
|
: $t('routes.post.thread.allComments')}
|
||||||
</Button>
|
</Button>
|
||||||
</Material>
|
</div>
|
||||||
{:else if data.thread.singleThread}
|
|
||||||
<Material
|
|
||||||
elevation="max"
|
|
||||||
padding="none"
|
|
||||||
color="distinct"
|
|
||||||
class="py-2 px-4 text-sm flex sm:flex-row justify-between items-center
|
|
||||||
sm:gap-4 sticky top-20 w-full box-border z-20 mt-4 flex-col gap-2"
|
|
||||||
>
|
|
||||||
<p class="font-medium text-sm flex items-center gap-2">
|
|
||||||
<Icon src={InformationCircle} mini size="20" />
|
|
||||||
{$t('routes.post.thread.single')}
|
|
||||||
</p>
|
|
||||||
<Button {loading} disabled={loading} on:click={reloadComments}>
|
|
||||||
{$t('routes.post.thread.allComments')}
|
|
||||||
</Button>
|
|
||||||
</Material>
|
|
||||||
{/if}
|
{/if}
|
||||||
<div class="mt-4 flex flex-col gap-2 w-full">
|
<section class="mt-4 flex flex-col gap-2 w-full">
|
||||||
<div class="flex flex-row justify-between flex-wrap gap-2">
|
<div class="flex flex-row justify-between flex-wrap gap-2">
|
||||||
<div class="text-base">
|
<div class="text-base">
|
||||||
<span class="font-bold">
|
<span class="font-bold">
|
||||||
@@ -316,10 +322,10 @@ flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
|
|||||||
</span>
|
</span>
|
||||||
{$t('routes.post.commentCount')}
|
{$t('routes.post.commentCount')}
|
||||||
</div>
|
</div>
|
||||||
<div class="gap-2 flex items-center h-8">
|
<div class="gap-2 flex items-center h-full">
|
||||||
<Select
|
<Select
|
||||||
size="sm"
|
size="md"
|
||||||
class="!h-full"
|
class="h-full"
|
||||||
bind:value={commentSort}
|
bind:value={commentSort}
|
||||||
on:change={reloadComments}
|
on:change={reloadComments}
|
||||||
>
|
>
|
||||||
@@ -335,7 +341,7 @@ flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{#await data.comments}
|
{#await data.comments}
|
||||||
<div class="flex flex-col gap-4">
|
<div class="space-y-4">
|
||||||
{#each new Array(10) as empty}
|
{#each new Array(10) as empty}
|
||||||
<div class="animate-pulse flex flex-col gap-2 skeleton w-full">
|
<div class="animate-pulse flex flex-col gap-2 skeleton w-full">
|
||||||
<div class="w-96 h-4" />
|
<div class="w-96 h-4" />
|
||||||
@@ -346,28 +352,40 @@ flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
|
|||||||
</div>
|
</div>
|
||||||
{:then comments}
|
{:then comments}
|
||||||
{#if $profile?.jwt}
|
{#if $profile?.jwt}
|
||||||
<CommentForm
|
{#if !commenting}
|
||||||
postId={post.post_view.post.id}
|
<Button
|
||||||
on:comment={(comment) =>
|
rounding="pill"
|
||||||
(comments.comments = [
|
class="mx-auto"
|
||||||
comment.detail.comment_view,
|
size="lg"
|
||||||
...comments.comments,
|
on:click={() => (commenting = true)}
|
||||||
])}
|
>
|
||||||
locked={(post.post_view.post.locked &&
|
<Icon src={PlusCircle} size="16" micro />
|
||||||
!(
|
{$t('routes.post.addComment')}
|
||||||
$profile?.user?.local_user_view.local_user.admin ||
|
</Button>
|
||||||
$profile?.user?.moderates
|
{:else}
|
||||||
.map((c) => c.community.id)
|
<CommentForm
|
||||||
.includes(data.post.community_view.community.id)
|
postId={post.post_view.post.id}
|
||||||
)) ||
|
on:comment={(comment) =>
|
||||||
$page.params.instance.toLowerCase() != $instance.toLowerCase()}
|
(comments.comments = [
|
||||||
banned={data.post.community_view.banned_from_community}
|
comment.detail.comment_view,
|
||||||
on:focus={() => (commenting = true)}
|
...comments.comments,
|
||||||
tools={commenting}
|
])}
|
||||||
preview={commenting}
|
locked={(post.post_view.post.locked &&
|
||||||
placeholder={commenting ? undefined : $t('routes.post.addComment')}
|
!(
|
||||||
rows={commenting ? 7 : 1}
|
$profile?.user?.local_user_view.local_user.admin ||
|
||||||
/>
|
$profile?.user?.moderates
|
||||||
|
.map((c) => c.community.id)
|
||||||
|
.includes(data.post.community_view.community.id)
|
||||||
|
)) ||
|
||||||
|
$page.params.instance.toLowerCase() != $instance.toLowerCase()}
|
||||||
|
banned={data.post.community_view.banned_from_community}
|
||||||
|
on:focus={() => (commenting = true)}
|
||||||
|
tools={commenting}
|
||||||
|
preview={commenting}
|
||||||
|
placeholder={commenting ? undefined : $t('routes.post.addComment')}
|
||||||
|
rows={commenting ? 7 : 1}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
<Comments
|
<Comments
|
||||||
post={post.post_view.post}
|
post={post.post_view.post}
|
||||||
@@ -400,7 +418,7 @@ flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
|
|||||||
</Button>
|
</Button>
|
||||||
</EndPlaceholder>
|
</EndPlaceholder>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</section>
|
||||||
|
|
||||||
<style lang="postcss">
|
<style lang="postcss">
|
||||||
.skeleton * {
|
.skeleton * {
|
||||||
|
|||||||
Reference in new issue
Block a user