feat: add post body closing and expanding
This commit is contained in:
1 parent
c20425b471
commit
3f06735fa7
4 files changed
+61
-17
No files matched your search
@@ -19,6 +19,7 @@
|
||||
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'
|
||||
import PostBody from './PostBody.svelte'
|
||||
|
||||
export let post: PostView
|
||||
export let actions: boolean = true
|
||||
@@ -78,14 +79,7 @@
|
||||
</div>
|
||||
<PostMedia bind:post={post.post} {view} {type} />
|
||||
{#if post.post.body && !post.post.nsfw && view != 'compact'}
|
||||
<div
|
||||
class="text-sm relative overflow-hidden
|
||||
bg-gradient-to-b text-transparent from-slate-600 via-slate-600
|
||||
dark:from-zinc-400 dark:via-zinc-400 bg-clip-text
|
||||
{view == 'list' ? `max-h-24` : 'max-h-48'}"
|
||||
>
|
||||
<Markdown inline source={post.post.body} />
|
||||
</div>
|
||||
<PostBody body={post.post.body} {view} />
|
||||
{/if}
|
||||
</div>
|
||||
{#if view == 'list' || view == 'compact'}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<script lang="ts">
|
||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||
import type { View } from '$lib/settings'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { ChevronDown, Icon } from 'svelte-hero-icons'
|
||||
|
||||
export let body: string
|
||||
export let view: View = 'cozy'
|
||||
let expanded = false
|
||||
</script>
|
||||
|
||||
<div
|
||||
style="transition: max-height 300ms cubic-bezier(0.075, 0.82, 0.165, 1)"
|
||||
class={!expanded
|
||||
? `text-sm overflow-hidden
|
||||
bg-gradient-to-b text-transparent from-slate-600 via-slate-600
|
||||
dark:from-zinc-400 dark:via-zinc-400 bg-clip-text z-0
|
||||
${view == 'list' ? `max-h-24` : 'max-h-48'}`
|
||||
: 'text-slate-600 dark:text-zinc-400 max-h-full'}
|
||||
>
|
||||
<Markdown inline={!expanded} source={body} />
|
||||
<Button
|
||||
on:click={() => (expanded = !expanded)}
|
||||
size="square-sm"
|
||||
color="tertiary"
|
||||
class="text-black dark:text-white absolute z-10 isolate shadow-xl {expanded
|
||||
? 'bottom-6'
|
||||
: 'bottom-16'} left-1/2 -translate-x-1/2"
|
||||
>
|
||||
<Icon
|
||||
src={ChevronDown}
|
||||
size="20"
|
||||
mini
|
||||
class="{expanded ? 'rotate-180' : ''} transition-transform"
|
||||
/>
|
||||
</Button>
|
||||
</div>
|
||||
@@ -14,6 +14,7 @@
|
||||
import {
|
||||
ArrowRight,
|
||||
ChartBar,
|
||||
Cog6Tooth,
|
||||
EllipsisHorizontal,
|
||||
Icon,
|
||||
XMark,
|
||||
@@ -84,14 +85,26 @@
|
||||
).hostname}
|
||||
</button>
|
||||
</div>
|
||||
<Button
|
||||
size="square-md"
|
||||
color="secondary"
|
||||
class="ml-auto"
|
||||
on:click={() => (sidebar = !sidebar)}
|
||||
>
|
||||
<Icon src={EllipsisHorizontal} size="16" mini />
|
||||
</Button>
|
||||
<div class="flex items-center gap-2 w-max ml-auto">
|
||||
<Button
|
||||
size="square-md"
|
||||
color="secondary"
|
||||
href="/c/{fullCommunityName(
|
||||
data.community.community_view.community.name,
|
||||
data.community.community_view.community.actor_id
|
||||
)}/settings"
|
||||
on:click={() => (sidebar = !sidebar)}
|
||||
>
|
||||
<Icon src={Cog6Tooth} size="16" mini />
|
||||
</Button>
|
||||
<Button
|
||||
size="square-md"
|
||||
color="secondary"
|
||||
on:click={() => (sidebar = !sidebar)}
|
||||
>
|
||||
<Icon src={EllipsisHorizontal} size="16" mini />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-row gap-4 max-w-full w-full items-end">
|
||||
<Sort selected={data.sort} />
|
||||
|
||||
Reference in new issue
Block a user