From 2a73e22b06974b10199d580499befa7308416e8b Mon Sep 17 00:00:00 2001 From: Xylight Date: Sat, 10 Feb 2024 12:07:24 -0800 Subject: [PATCH] feat: dont show expand button if post body length is below maximum height --- src/lib/components/lemmy/post/PostBody.svelte | 42 ++++++++++++------- src/lib/components/ui/Navbar.svelte | 2 +- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/lib/components/lemmy/post/PostBody.svelte b/src/lib/components/lemmy/post/PostBody.svelte index 4d06addb..853d8a63 100644 --- a/src/lib/components/lemmy/post/PostBody.svelte +++ b/src/lib/components/lemmy/post/PostBody.svelte @@ -6,7 +6,16 @@ export let body: string export let view: View = 'cozy' + let overflows = false let expanded = false + + function isOverflown(element: Element) { + overflows = + element.scrollHeight > element.clientHeight || + element.scrollWidth > element.clientWidth + + if (!overflows) expanded = true + }
- + {#if overflows} + + {/if}
diff --git a/src/lib/components/ui/Navbar.svelte b/src/lib/components/ui/Navbar.svelte index 5aa546d9..05c0f037 100644 --- a/src/lib/components/ui/Navbar.svelte +++ b/src/lib/components/ui/Navbar.svelte @@ -53,7 +53,7 @@