misc: tweak post page

This commit is contained in:
Xyphyn committed 2023-08-31 19:12:07 -07:00
1 parent 72cfd7a894
commit e209a22d2c
2 files changed
+22 -10

No files matched your search

@@ -4,7 +4,7 @@
import { page } from '$app/stores' import { page } from '$app/stores'
import { onMount, setContext } from 'svelte' import { onMount, setContext } from 'svelte'
import Button from '$lib/components/input/Button.svelte' import Button from '$lib/components/input/Button.svelte'
import { ChevronDown, Icon } from 'svelte-hero-icons' import { ChevronDown, Icon, Plus, PlusCircle } from 'svelte-hero-icons'
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import type { CommentView, Post } from 'lemmy-js-client' import type { CommentView, Post } from 'lemmy-js-client'
import { fly } from 'svelte/transition' import { fly } from 'svelte/transition'
@@ -112,23 +112,29 @@
<svelte:self {post} bind:nodes={node.children} isParent={false} /> <svelte:self {post} bind:nodes={node.children} isParent={false} />
{/if} {/if}
{#if node.comment_view.counts.child_count > 0 && node.children.length == 0} {#if node.comment_view.counts.child_count > 0 && node.children.length == 0}
<div <button
class="my-2 w-max h-8 border-l-2 border-slate-200 dark:border-zinc-900 pl-2" class="w-full my-2 h-8 border-l-2 border-slate-200 dark:border-zinc-800 pl-2 text-left"
on:click={() => {
node.loading = true
fetchChildren(node).then(() => (node.loading = false))
}}
> >
<Button <Button
loading={node.loading} loading={node.loading}
disabled={node.loading} disabled={node.loading}
size="sm" size="sm"
color="tertiary" color="tertiary"
alignment="left"
loaderWidth={18}
on:click={() => { on:click={() => {
node.loading = true node.loading = true
fetchChildren(node).then(() => (node.loading = false)) fetchChildren(node).then(() => (node.loading = false))
}} }}
> >
<Icon src={ChevronDown} width={16} mini slot="icon" /> <Icon src={Plus} width={18} mini slot="icon" />
{node.comment_view.counts.child_count} more {node.comment_view.counts.child_count} more
</Button> </Button>
</div> </button>
{/if} {/if}
</Comment> </Comment>
{/each} {/each}
@@ -24,6 +24,7 @@
import Link from '$lib/components/input/Link.svelte' import Link from '$lib/components/input/Link.svelte'
import SectionTitle from '$lib/components/ui/SectionTitle.svelte' import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
import { userSettings } from '$lib/settings.js' import { userSettings } from '$lib/settings.js'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
export let data export let data
@@ -94,7 +95,7 @@
type_: 'All', type_: 'All',
post_id: post.post_view.post.id, post_id: post.post_view.post.id,
sort: commentSort, sort: commentSort,
max_depth: 3, max_depth: data.post.post_view.counts.comments > 100 ? 1 : 3,
}) })
} }
</script> </script>
@@ -170,7 +171,9 @@
/> />
{/if} {/if}
{#if post.post_view.post.body} {#if post.post_view.post.body}
<div class="text-base rounded-md leading-[22px]"> <div
class="text-sm text-slate-800 dark:text-zinc-300 rounded-md leading-[22px]"
>
<Markdown source={post.post_view.post.body} /> <Markdown source={post.post_view.post.body} />
</div> </div>
{/if} {/if}
@@ -221,16 +224,19 @@
{/if} {/if}
</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="flex flex-row justify-between">
Comments <span class="text-sm font-normal ml-2 opacity-80"> <div class="font-bold opacity-80 text-base">
{post.post_view.counts.comments} Comments <span class="text-lg font-medium ml-2">
<FormattedNumber number={post.post_view.counts.comments} />
</span> </span>
</div> </div>
<MultiSelect <MultiSelect
options={['Hot', 'Top', 'New']} options={['Hot', 'Top', 'New']}
bind:selected={commentSort} bind:selected={commentSort}
on:select={reloadComments} on:select={reloadComments}
headless
/> />
</div>
{#if data.singleThread} {#if data.singleThread}
<Card class="py-2 px-4 text-sm flex flex-row items-center flex-wrap gap-4"> <Card class="py-2 px-4 text-sm flex flex-row items-center flex-wrap gap-4">
<p>You're viewing a single thread.</p> <p>You're viewing a single thread.</p>