From 9833a775c4f1e5bb8e4ee4aad58800cbdd6db584 Mon Sep 17 00:00:00 2001 From: Xyphyn Date: Thu, 31 Aug 2023 18:38:41 -0700 Subject: [PATCH] feat: change compact post style --- src/lib/components/lemmy/post/Post.svelte | 205 ++++++++++-------- src/lib/components/lemmy/post/PostFeed.svelte | 63 +++--- src/lib/components/markdown/markdown.ts | 2 +- 3 files changed, 145 insertions(+), 125 deletions(-) diff --git a/src/lib/components/lemmy/post/Post.svelte b/src/lib/components/lemmy/post/Post.svelte index 21133481..f12d5058 100644 --- a/src/lib/components/lemmy/post/Post.svelte +++ b/src/lib/components/lemmy/post/Post.svelte @@ -14,35 +14,108 @@ export let post: PostView export let actions: boolean = true export let hideCommunity = false + export let compact: boolean = false let loaded = false - -
-
- - - {post.post.name} - + +
+
+ + {#if !$userSettings.showCompactPosts} + {#if post.post.url && !post.post.thumbnail_url} + + {post.post.url} + + {/if} + {#if isImage(post.post.url)} + + + + + + + (loaded = true)} + /> + + + {:else if post.post.thumbnail_url && post.post.url} + + {/if} + {/if} + {#if post.post.body && !post.post.nsfw} +
+ + {#if post.post.body.length > (compact ? 300 : 600)} +
+ {/if} +
+ {/if}
{#if $userSettings.showCompactPosts && (post.post.thumbnail_url || isImage(post.post.url))}
@@ -66,77 +139,17 @@
{/if}
- {#if !$userSettings.showCompactPosts} - {#if post.post.url && !post.post.thumbnail_url} - - {post.post.url} - - {/if} - {#if isImage(post.post.url)} - - - - - - - (loaded = true)} - /> - - - {:else if post.post.thumbnail_url && post.post.url} - - {/if} - {#if post.post.body && !post.post.nsfw} -
- 350 - ? `${post.post.body.slice(0, 350)}...` - : post.post.body} - /> -
- {/if} - {/if} {#if actions} - { - toast({ - content: 'The post was edited successfully.', - type: 'success', - }) - }} - /> +
+ { + toast({ + content: 'The post was edited successfully.', + type: 'success', + }) + }} + /> +
{/if} diff --git a/src/lib/components/lemmy/post/PostFeed.svelte b/src/lib/components/lemmy/post/PostFeed.svelte index 30fa938b..2d15b624 100644 --- a/src/lib/components/lemmy/post/PostFeed.svelte +++ b/src/lib/components/lemmy/post/PostFeed.svelte @@ -10,32 +10,39 @@ export let posts: PostView[] -{#if posts.length == 0} -
- - - -
-{:else} - {#each posts as post, index (post.post.id)} - {#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)} -
+ {#if posts.length == 0} +
+ - -
- {/if} - {/each} -{/if} + + +
+ {:else} + {#each posts as post, index (post.post.id)} + {#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)} +
+ +
+ {/if} + {/each} + {/if} +
diff --git a/src/lib/components/markdown/markdown.ts b/src/lib/components/markdown/markdown.ts index f359151f..512a04ae 100644 --- a/src/lib/components/markdown/markdown.ts +++ b/src/lib/components/markdown/markdown.ts @@ -30,7 +30,7 @@ export const md = new MarkdownIt({ .use(markdown_it_sup) export const mdInline: MarkdownIt = new MarkdownIt('zero') - .enable(['emphasis', 'backticks', 'strikethrough', 'link']) + .enable(['emphasis', 'backticks', 'strikethrough', 'link', 'list', 'heading']) .use(markdown_it_container, 'spoiler', { validate: (params: string) => { return params.trim().match(/^spoiler+(.*)/)