design: improve post page
This commit is contained in:
1 parent
160622e760
commit
9bde0e5686
4 files changed
+63
-35
No files matched your search
@@ -17,7 +17,7 @@
|
|||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import { afterNavigate } from '$app/navigation'
|
import { afterNavigate } from '$app/navigation'
|
||||||
import { backOut } from 'svelte/easing'
|
import { backOut, expoOut } from 'svelte/easing'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
// 0.18.2 -> 0.18.3 broke this
|
// 0.18.2 -> 0.18.3 broke this
|
||||||
// so i'm adding this check
|
// so i'm adding this check
|
||||||
const treeParent = tree.find(
|
const treeParent = tree.find(
|
||||||
(c) => c.comment_view.comment.id == parent.comment_view.comment.id,
|
(c) => c.comment_view.comment.id == parent.comment_view.comment.id
|
||||||
)
|
)
|
||||||
|
|
||||||
if (treeParent) {
|
if (treeParent) {
|
||||||
@@ -107,7 +107,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ul
|
<ul
|
||||||
in:fly={{ opacity: 0, y: -4, duration: 400, easing: backOut }}
|
in:fly={{ duration: 500, easing: expoOut, y: -12 }}
|
||||||
class={isParent
|
class={isParent
|
||||||
? 'divide-y dark:divide-zinc-900 divide-slate-100'
|
? 'divide-y dark:divide-zinc-900 divide-slate-100'
|
||||||
: 'pl-3.5 border-l border-slate-200 dark:border-zinc-800 my-1'}
|
: 'pl-3.5 border-l border-slate-200 dark:border-zinc-800 my-1'}
|
||||||
@@ -140,7 +140,7 @@
|
|||||||
fetchChildren(node).then(() => (node.loading = false))
|
fetchChildren(node).then(() => (node.loading = false))
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon src={ChevronDoubleDown} mini size="16" slot="prefix" />
|
<Icon src={ChevronDoubleDown} micro size="16" slot="prefix" />
|
||||||
{$t('comment.more', {
|
{$t('comment.more', {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
comments: node.comment_view.counts.child_count,
|
comments: node.comment_view.counts.child_count,
|
||||||
|
|||||||
@@ -170,7 +170,7 @@
|
|||||||
</Label>
|
</Label>
|
||||||
{/if}
|
{/if}
|
||||||
<div
|
<div
|
||||||
class="flex flex-col border border-slate-200 border-b-slate-300 dark:border-t-zinc-700 dark:border-zinc-800
|
class="flex flex-col border border-slate-200 border-b-slate-300 dark:border-t-zinc-700/70 dark:border-zinc-800
|
||||||
focus-within:border-primary-900 focus-within:dark:border-primary-100 focus-within:ring ring-slate-300
|
focus-within:border-primary-900 focus-within:dark:border-primary-100 focus-within:ring ring-slate-300
|
||||||
dark:ring-zinc-700 rounded-xl
|
dark:ring-zinc-700 rounded-xl
|
||||||
overflow-hidden transition-colors {$$props.class}"
|
overflow-hidden transition-colors {$$props.class}"
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
urlObj.searchParams.append('format', 'webp')
|
urlObj.searchParams.append('format', 'webp')
|
||||||
urlObj.searchParams.append(
|
urlObj.searchParams.append(
|
||||||
'thumbnail',
|
'thumbnail',
|
||||||
findClosestNumber(sizes, (res || width) * 1.5).toString(),
|
findClosestNumber(sizes, (res || width) * 1.5).toString()
|
||||||
)
|
)
|
||||||
|
|
||||||
return urlObj.toString()
|
return urlObj.toString()
|
||||||
@@ -35,11 +35,11 @@
|
|||||||
|
|
||||||
{#if optimizedURL}
|
{#if optimizedURL}
|
||||||
<img
|
<img
|
||||||
|
loading="lazy"
|
||||||
src={optimizedURL}
|
src={optimizedURL}
|
||||||
{alt}
|
{alt}
|
||||||
{width}
|
{width}
|
||||||
{title}
|
{title}
|
||||||
loading="lazy"
|
|
||||||
class="aspect-square object-cover overflow-hidden {$$props.class} flex-shrink-0"
|
class="aspect-square object-cover overflow-hidden {$$props.class} flex-shrink-0"
|
||||||
style="width: {width}px; height: {width}px;"
|
style="width: {width}px; height: {width}px;"
|
||||||
class:rounded-full={circle}
|
class:rounded-full={circle}
|
||||||
|
|||||||
@@ -22,7 +22,14 @@
|
|||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import PostLink from '$lib/components/lemmy/post/link/PostLink.svelte'
|
import PostLink from '$lib/components/lemmy/post/link/PostLink.svelte'
|
||||||
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
||||||
import { Material, Select, Spinner, removeToast, toast } from 'mono-svelte'
|
import {
|
||||||
|
Material,
|
||||||
|
Select,
|
||||||
|
Spinner,
|
||||||
|
buttonColor,
|
||||||
|
removeToast,
|
||||||
|
toast,
|
||||||
|
} from 'mono-svelte'
|
||||||
import type { CommentSortType } from 'lemmy-js-client'
|
import type { CommentSortType } from 'lemmy-js-client'
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import { instance } from '$lib/instance.js'
|
import { instance } from '$lib/instance.js'
|
||||||
@@ -315,30 +322,13 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<section class="mt-4 flex flex-col gap-2 w-full">
|
<section class="mt-4 flex flex-col gap-2 w-full">
|
||||||
<header class="flex flex-row justify-between flex-wrap gap-2">
|
<header>
|
||||||
<div class="text-base">
|
<div class="text-base">
|
||||||
<span class="font-bold">
|
<span class="font-bold">
|
||||||
<FormattedNumber number={post.post_view.counts.comments} />
|
<FormattedNumber number={post.post_view.counts.comments} />
|
||||||
</span>
|
</span>
|
||||||
{$t('routes.post.commentCount')}
|
{$t('routes.post.commentCount')}
|
||||||
</div>
|
</div>
|
||||||
<div class="gap-2 flex items-center h-full">
|
|
||||||
<Select
|
|
||||||
size="md"
|
|
||||||
class="h-full"
|
|
||||||
bind:value={commentSort}
|
|
||||||
on:change={reloadComments}
|
|
||||||
>
|
|
||||||
<option value="Hot">{$t('filter.sort.hot')}</option>
|
|
||||||
<option value="Top">{$t('filter.sort.top.label')}</option>
|
|
||||||
<option value="New">{$t('filter.sort.new')}</option>
|
|
||||||
<option value="Old">{$t('filter.sort.old')}</option>
|
|
||||||
<option value="Controversial">{$t('filter.sort.controversial')}</option>
|
|
||||||
</Select>
|
|
||||||
<Button size="square-md" on:click={reloadComments}>
|
|
||||||
<Icon src={ArrowPath} size="16" mini slot="prefix" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</header>
|
</header>
|
||||||
{#await data.comments}
|
{#await data.comments}
|
||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
@@ -353,15 +343,36 @@
|
|||||||
{:then comments}
|
{:then comments}
|
||||||
{#if $profile?.jwt}
|
{#if $profile?.jwt}
|
||||||
{#if !commenting}
|
{#if !commenting}
|
||||||
<Button
|
<EndPlaceholder>
|
||||||
rounding="pill"
|
<Button
|
||||||
class="mx-auto"
|
rounding="pill"
|
||||||
size="lg"
|
class="mx-auto"
|
||||||
on:click={() => (commenting = true)}
|
size="lg"
|
||||||
>
|
on:click={() => (commenting = true)}
|
||||||
<Icon src={PlusCircle} size="16" micro />
|
>
|
||||||
{$t('routes.post.addComment')}
|
<Icon src={PlusCircle} size="16" micro />
|
||||||
</Button>
|
{$t('routes.post.addComment')}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<div class="gap-2 flex items-center" slot="action">
|
||||||
|
<Select
|
||||||
|
size="md"
|
||||||
|
bind:value={commentSort}
|
||||||
|
on:change={reloadComments}
|
||||||
|
>
|
||||||
|
<option value="Hot">{$t('filter.sort.hot')}</option>
|
||||||
|
<option value="Top">{$t('filter.sort.top.label')}</option>
|
||||||
|
<option value="New">{$t('filter.sort.new')}</option>
|
||||||
|
<option value="Old">{$t('filter.sort.old')}</option>
|
||||||
|
<option value="Controversial">
|
||||||
|
{$t('filter.sort.controversial')}
|
||||||
|
</option>
|
||||||
|
</Select>
|
||||||
|
<Button size="square-md" on:click={reloadComments}>
|
||||||
|
<Icon src={ArrowPath} size="16" mini slot="prefix" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</EndPlaceholder>
|
||||||
{:else}
|
{:else}
|
||||||
<CommentForm
|
<CommentForm
|
||||||
postId={post.post_view.post.id}
|
postId={post.post_view.post.id}
|
||||||
@@ -387,6 +398,23 @@
|
|||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if commenting || !$profile.jwt}
|
||||||
|
<div class="gap-2 flex items-center">
|
||||||
|
<Select size="md" bind:value={commentSort} on:change={reloadComments}>
|
||||||
|
<option value="Hot">{$t('filter.sort.hot')}</option>
|
||||||
|
<option value="Top">{$t('filter.sort.top.label')}</option>
|
||||||
|
<option value="New">{$t('filter.sort.new')}</option>
|
||||||
|
<option value="Old">{$t('filter.sort.old')}</option>
|
||||||
|
<option value="Controversial">
|
||||||
|
{$t('filter.sort.controversial')}
|
||||||
|
</option>
|
||||||
|
</Select>
|
||||||
|
<Button size="square-md" on:click={reloadComments}>
|
||||||
|
<Icon src={ArrowPath} size="16" mini slot="prefix" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
<Comments
|
<Comments
|
||||||
post={post.post_view.post}
|
post={post.post_view.post}
|
||||||
nodes={buildCommentsTree(
|
nodes={buildCommentsTree(
|
||||||
|
|||||||
Reference in new issue
Block a user