design: improve compact/list posts

This commit is contained in:
Xylight committed 2024-05-30 17:46:58 -07:00
1 parent 386f738e6a
commit 2edfdf8421
2 files changed
+33 -29

No files matched your search

+15 -9
View File
@@ -85,15 +85,21 @@
>
<slot name="badges" slot="badges" />
</PostMeta>
<div
style="grid-area:embed"
class={view == 'list' || view == 'compact' ? '' : 'contents'}
>
<PostMedia bind:post={post.post} {view} {type} />
</div>
{#if view == 'list' || view == 'compact'}
<PostMediaCompact {view} bind:post={post.post} style="grid-area: media;" />
{/if}
{#key post.post.url}
<div
style="grid-area:embed;"
class={view == 'list' || view == 'compact' ? '' : 'contents'}
>
<PostMedia bind:post={post.post} {view} {type} />
</div>
{#if view == 'list' || view == 'compact'}
<PostMediaCompact
{view}
bind:post={post.post}
style="grid-area: media;"
/>
{/if}
{/key}
{#if post.post.body && !post.post.nsfw && view != 'compact' && !hideBody}
<PostBody body={post.post.body} {view} style="grid-area: body" />
{/if}
@@ -10,25 +10,23 @@
</script>
{#if (view == 'list' || view == 'compact') && !post.embed_title && (post.thumbnail_url || isImage(post.url))}
<div class="flex-shrink-0 w-24 h-24" style={$$props.style ?? ''}>
{#if !$userSettings.expandImages || (post.thumbnail_url && !isImage(post.url))}
<a href={postLink(post)}>
<!-- svelte-ignore a11y-missing-attribute -->
<img
src={bestImageURL(post, true)}
loading="lazy"
class="object-cover bg-slate-100 dark:bg-zinc-800 rounded-lg h-24 w-24 border border-slate-200 dark:border-zinc-700"
/>
</a>
{:else}
<button on:click={() => showImage(bestImageURL(post, false, 2048))}>
<!-- svelte-ignore a11y-missing-attribute -->
<img
src={bestImageURL(post, true)}
loading="lazy"
class="object-cover bg-slate-100 rounded-lg h-24 w-24 border border-slate-200 dark:border-zinc-700"
/>
</button>
{/if}
<div class="w-32 h-24" style={$$props.style ?? ''}>
<svelte:element
this={!$userSettings.expandImages ||
(post.thumbnail_url && !isImage(post.url))
? 'a'
: 'button'}
href={postLink(post)}
on:click={() => showImage(bestImageURL(post, false, 2048))}
role="button"
tabindex="0"
>
<img
src={bestImageURL(post, true)}
loading="lazy"
class="object-cover overflow-hidden bg-slate-100 dark:bg-zinc-800 rounded-xl h-24 w-32 border border-slate-200 dark:border-zinc-800"
alt={post.name}
/>
</svelte:element>
</div>
{/if}