feat: change compact post style

This commit is contained in:
Xyphyn committed 2023-08-31 18:38:41 -07:00
1 parent 4ba2235c01
commit 9833a775c4
3 files changed
+57 -37

No files matched your search

+45 -32
View File
@@ -14,13 +14,20 @@
export let post: PostView export let post: PostView
export let actions: boolean = true export let actions: boolean = true
export let hideCommunity = false export let hideCommunity = false
export let compact: boolean = false
let loaded = false let loaded = false
</script> </script>
<Card class="bg-white flex flex-col w-full p-5 gap-2.5" id={post.post.id}> <Card
<div class="flex flex-row w-full gap-2.5"> class="flex flex-col w-full gap-2.5 {compact
<div class="flex flex-col gap-1.5 grow"> ? '!bg-transparent !border-0 py-5'
: 'p-5'}"
id={post.post.id}
>
<div class="flex flex-row gap-2 w-full">
<div class="flex flex-col gap-2 w-full">
<div class="flex flex-col w-full gap-2">
<PostMeta <PostMeta
community={hideCommunity ? undefined : post.community} community={hideCommunity ? undefined : post.community}
user={post.creator} user={post.creator}
@@ -44,28 +51,6 @@
{post.post.name} {post.post.name}
</a> </a>
</div> </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 !$userSettings.showCompactPosts}
{#if post.post.url && !post.post.thumbnail_url} {#if post.post.url && !post.post.thumbnail_url}
<a <a
@@ -114,21 +99,48 @@
nsfw={post.post.nsfw} nsfw={post.post.nsfw}
/> />
{/if} {/if}
{/if}
{#if post.post.body && !post.post.nsfw} {#if post.post.body && !post.post.nsfw}
<div <div
class="text-sm bg-slate-100 dark:bg-zinc-800 class="text-sm relative overflow-hidden {compact
border border-slate-200 dark:border-zinc-700 rounded-md p-2" ? `text-zinc-500 max-h-24`
: 'text-slate-600 max-h-48'}"
> >
<Markdown <Markdown inline source={post.post.body.slice(0, 400)} />
inline {#if post.post.body.length > (compact ? 300 : 600)}
source={post.post.body.length > 350 <div
? `${post.post.body.slice(0, 350)}...` class="absolute bottom-0 w-full h-16 bg-gradient-to-b {compact
: post.post.body} ? 'dark:from-zinc-950/0 dark:to-zinc-950 from-slate-50/0 to-slate-50'
: 'dark:from-zinc-900/0 dark:to-zinc-900 from-white/0 to-white'} "
/> />
{/if}
</div> </div>
{/if} {/if}
</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} {/if}
</a>
</div>
{/if}
</div>
{#if actions} {#if actions}
<div class="w-full z-30" class:mt-2={compact}>
<PostActions <PostActions
bind:post bind:post
on:edit={(e) => { on:edit={(e) => {
@@ -138,5 +150,6 @@
}) })
}} }}
/> />
</div>
{/if} {/if}
</Card> </Card>
+11 -4
View File
@@ -10,7 +10,13 @@
export let posts: PostView[] export let posts: PostView[]
</script> </script>
{#if posts.length == 0} <div
class="flex flex-col {!$userSettings.showCompactPosts
? 'gap-3 md:gap-4'
: ''} divide-slate-200 dark:divide-zinc-800"
class:divide-y={$userSettings.showCompactPosts}
>
{#if posts.length == 0}
<div class="h-full grid place-items-center"> <div class="h-full grid place-items-center">
<Placeholder <Placeholder
icon={ArchiveBox} icon={ArchiveBox}
@@ -23,7 +29,7 @@
</Button> </Button>
</Placeholder> </Placeholder>
</div> </div>
{:else} {:else}
{#each posts as post, index (post.post.id)} {#each posts as post, index (post.post.id)}
{#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)} {#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)}
<div <div
@@ -34,8 +40,9 @@
delay: index < 4 ? index * 100 : 0, delay: index < 4 ? index * 100 : 0,
}} }}
> >
<Post {post} /> <Post compact={$userSettings.showCompactPosts} {post} />
</div> </div>
{/if} {/if}
{/each} {/each}
{/if} {/if}
</div>
+1 -1
View File
@@ -30,7 +30,7 @@ export const md = new MarkdownIt({
.use(markdown_it_sup) .use(markdown_it_sup)
export const mdInline: MarkdownIt = new MarkdownIt('zero') export const mdInline: MarkdownIt = new MarkdownIt('zero')
.enable(['emphasis', 'backticks', 'strikethrough', 'link']) .enable(['emphasis', 'backticks', 'strikethrough', 'link', 'list', 'heading'])
.use(markdown_it_container, 'spoiler', { .use(markdown_it_container, 'spoiler', {
validate: (params: string) => { validate: (params: string) => {
return params.trim().match(/^spoiler+(.*)/) return params.trim().match(/^spoiler+(.*)/)