From 9d48198f95745fe6641b948742cd9cbe00a4e097 Mon Sep 17 00:00:00 2001 From: Xyphyn Date: Wed, 11 Oct 2023 17:47:23 -0700 Subject: [PATCH] misc: split post media into separate component --- package.json | 2 +- src/lib/components/lemmy/post/Post.svelte | 125 +----------------- .../lemmy/post/media/PostMedia.svelte | 97 ++++++++++++++ .../lemmy/post/media/PostMediaCompact.svelte | 34 +++++ src/lib/components/ui/ExpandableImage.svelte | 4 +- 5 files changed, 141 insertions(+), 121 deletions(-) create mode 100644 src/lib/components/lemmy/post/media/PostMedia.svelte create mode 100644 src/lib/components/lemmy/post/media/PostMediaCompact.svelte diff --git a/package.json b/package.json index a1c9c481..7899bd93 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "photon-lemmy", - "version": "1.19.1", + "version": "1.19.2", "private": true, "scripts": { "dev": "vite dev", diff --git a/src/lib/components/lemmy/post/Post.svelte b/src/lib/components/lemmy/post/Post.svelte index b52e48ff..a22224c2 100644 --- a/src/lib/components/lemmy/post/Post.svelte +++ b/src/lib/components/lemmy/post/Post.svelte @@ -13,6 +13,8 @@ import Empty from '$lib/components/helper/Empty.svelte' import { publishedToDate } from '$lib/components/util/date.js' import { Icon, VideoCamera } from 'svelte-hero-icons' + import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte' + import PostMediaCompact from '$lib/components/lemmy/post/media/PostMediaCompact.svelte' export let post: PostView export let actions: boolean = true @@ -23,24 +25,16 @@ - - - {#if view == 'list' || view == 'cozy'} -
- {/if}
- - - - - - (loaded = true)} - /> - - - - - - (loaded = true)} - /> - - - - {/if} - {:else if isVideo(post.post.url) && (view == 'cozy' || view == 'card')} - -
- - Video -

Go to the post to view this video.

-
- {:else if post.post.url} - - {/if} + {#if post.post.body && !post.post.nsfw && view != 'compact'}
- {#if !$userSettings.expandImages || (post.post.thumbnail_url && !isImage(post.post.url))} - - - - - {:else} - - - - - {/if} -
+ {#if view == 'list' || view == 'compact'} + {/if}
{#if actions} diff --git a/src/lib/components/lemmy/post/media/PostMedia.svelte b/src/lib/components/lemmy/post/media/PostMedia.svelte new file mode 100644 index 00000000..eb320bdd --- /dev/null +++ b/src/lib/components/lemmy/post/media/PostMedia.svelte @@ -0,0 +1,97 @@ + + +{#if isImage(post.url)} + {#if view == 'card' || view == 'cozy'} + + + + + + + + + + + + + + + + + + {/if} +{:else if isVideo(post.url) && (view == 'cozy' || view == 'card')} + +
+ + Video +

Go to the post to view this video.

+
+{:else if post.url} + +{/if} diff --git a/src/lib/components/lemmy/post/media/PostMediaCompact.svelte b/src/lib/components/lemmy/post/media/PostMediaCompact.svelte new file mode 100644 index 00000000..e06af17c --- /dev/null +++ b/src/lib/components/lemmy/post/media/PostMediaCompact.svelte @@ -0,0 +1,34 @@ + + +{#if (view == 'list' || view == 'compact') && !post.embed_title && (post.thumbnail_url || isImage(post.url))} +
+ {#if !$userSettings.expandImages || (post.thumbnail_url && !isImage(post.url))} + + + + + {:else} + + + + + {/if} +
+{/if} diff --git a/src/lib/components/ui/ExpandableImage.svelte b/src/lib/components/ui/ExpandableImage.svelte index eb4ebd7b..1659977a 100644 --- a/src/lib/components/ui/ExpandableImage.svelte +++ b/src/lib/components/ui/ExpandableImage.svelte @@ -24,14 +24,14 @@
(open = false)} >