feat: show compact posts (#22)

Add a new UI setting for showing compact posts:

- Show a small thumbnail to the right of the metadata and title if a
  thumbnail is available or if the post is an image
- Do not show normal thumbnail or text bodies.
This commit is contained in:
Peter Bui authored and GitHub committed 2023-07-26 10:32:04 -07:00
1 parent d696e2ee00
commit e028113ab0
3 files changed
+36

No files matched your search

+29
View File
@@ -15,6 +15,8 @@
</script>
<Card class="bg-white flex flex-col w-full p-5 gap-2.5">
<div class="flex flex-row w-full gap-2.5">
<div class="flex flex-col gap-2.5 grow">
<PostMeta
community={post.community}
user={post.creator}
@@ -33,6 +35,32 @@
>
{post.post.name}
</a>
</div>
{#if $userSettings.showCompactPosts && (post.post.thumbnail_url || isImage(post.post.url))}
<div class="flex-none w-24 h-24">
<a
href="/post/{getInstance()}/{post.post.id}"
>
{#if post.post.thumbnail_url}
<!-- svelte-ignore a11y-missing-attribute -->
<img
src="{post.post.thumbnail_url}?thumbnail=256&format=webp"
loading="lazy"
class="object-cover bg-slate-100 rounded-md h-24 w-24 border border-slate-200 dark:border-zinc-700"
/>
{:else}
<!-- svelte-ignore a11y-missing-attribute -->
<img
src="{post.post.url}?thumbnail=256&format=webp"
loading="lazy"
class="object-cover bg-slate-100 rounded-md h-24 w-24 border border-slate-200 dark:border-zinc-700"
/>
{/if}
</a>
</div>
{/if}
</div>
{#if !$userSettings.showCompactPosts}
{#if post.post.url && !post.post.thumbnail_url}
<a
href={post.post.url}
@@ -83,6 +111,7 @@
{post.post.body}
</p>
{/if}
{/if}
<PostActions
{post}
on:edit={(e) => {
+2
View File
@@ -7,6 +7,7 @@ interface Settings {
instance?: string
revertColors: boolean
showInstance: boolean
showCompactPosts: boolean
defaultSort: {
sort: 'Hot' | 'TopAll' | 'Active' | 'New'
feed: 'All' | 'Subscribed' | 'Local'
@@ -19,6 +20,7 @@ const defaultSettings: Settings = {
markReadPosts: true,
revertColors: false,
showInstance: false,
showCompactPosts: false,
defaultSort: {
sort: 'Active',
feed: 'Local',
+5
View File
@@ -114,4 +114,9 @@
</span>
<Switch bind:enabled={$userSettings.showInstance} />
</Setting>
<Setting>
<span slot="title">Show compact posts</span>
<span slot="description">Show posts with smaller thumbnails and without text bodies.</span>
<Switch bind:enabled={$userSettings.showCompactPosts} />
</Setting>
</div>