optimize: denest postmeta
This commit is contained in:
1 parent
8b82a782f5
commit
53318d2e5b
3 files changed
+28
-29
No files matched your search
@@ -12,6 +12,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
|
{...$$restProps}
|
||||||
class="items-center flex flex-row gap-2 hover:underline flex-shrink-0"
|
class="items-center flex flex-row gap-2 hover:underline flex-shrink-0"
|
||||||
href="/c/{community.name}@{new URL(community.actor_id).hostname}"
|
href="/c/{community.name}@{new URL(community.actor_id).hostname}"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -63,8 +63,6 @@
|
|||||||
community={hideCommunity ? undefined : post.community}
|
community={hideCommunity ? undefined : post.community}
|
||||||
user={post.creator}
|
user={post.creator}
|
||||||
published={publishedToDate(post.post.published)}
|
published={publishedToDate(post.post.published)}
|
||||||
upvotes={post.counts.upvotes}
|
|
||||||
downvotes={post.counts.downvotes}
|
|
||||||
deleted={post.post.deleted}
|
deleted={post.post.deleted}
|
||||||
removed={post.post.removed}
|
removed={post.post.removed}
|
||||||
locked={post.post.locked}
|
locked={post.post.locked}
|
||||||
|
|||||||
@@ -26,10 +26,6 @@
|
|||||||
export let title: string | undefined = undefined
|
export let title: string | undefined = undefined
|
||||||
export let id: number | undefined = undefined
|
export let id: number | undefined = undefined
|
||||||
|
|
||||||
// Score
|
|
||||||
export let upvotes: number | undefined = undefined
|
|
||||||
export let downvotes: number | undefined = undefined
|
|
||||||
|
|
||||||
// Badges
|
// Badges
|
||||||
export let nsfw: boolean = false
|
export let nsfw: boolean = false
|
||||||
export let saved: boolean = false
|
export let saved: boolean = false
|
||||||
@@ -39,8 +35,9 @@
|
|||||||
export let locked: boolean = false
|
export let locked: boolean = false
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col gap-1 w-full">
|
<div
|
||||||
<span class="flex flex-row gap-2 text-sm items-center">
|
class="grid w-full meta {community ? 'grid-rows-2' : 'grid-rows-1'} text-xs"
|
||||||
|
>
|
||||||
{#if community}
|
{#if community}
|
||||||
<Subscribe let:subscribe let:subscribing>
|
<Subscribe let:subscribe let:subscribing>
|
||||||
<button
|
<button
|
||||||
@@ -50,16 +47,21 @@
|
|||||||
subscribed =
|
subscribed =
|
||||||
subscribed == 'NotSubscribed' ? 'Subscribed' : 'NotSubscribed'
|
subscribed == 'NotSubscribed' ? 'Subscribed' : 'NotSubscribed'
|
||||||
}}
|
}}
|
||||||
class="relative cursor-pointer"
|
class="relative cursor-pointer row-span-2 pr-2"
|
||||||
>
|
>
|
||||||
<Avatar url={community.icon} width={28} alt={community.name} />
|
<Avatar
|
||||||
|
url={community.icon}
|
||||||
|
width={28}
|
||||||
|
alt={community.name}
|
||||||
|
style="grid-area: avatar; height: 100%;"
|
||||||
|
/>
|
||||||
{#if subscribed != undefined && $profile?.jwt}
|
{#if subscribed != undefined && $profile?.jwt}
|
||||||
<div
|
<div
|
||||||
class="absolute w-3.5 h-3.5 {subscribed == 'NotSubscribed'
|
class="absolute w-3.5 h-3.5 {subscribed == 'NotSubscribed'
|
||||||
? 'bg-primary-900 dark:bg-primary-100 text-white dark:text-black'
|
? 'bg-primary-900 dark:bg-primary-100 text-white dark:text-black'
|
||||||
: 'bg-primary-100 dark:bg-primary-900 text-black dark:text-white'} rounded-full ring-2 box-border
|
: 'bg-primary-100 dark:bg-primary-900 text-black dark:text-white'} rounded-full ring-2 box-border
|
||||||
ring-slate-50 dark:ring-zinc-950
|
ring-slate-50 dark:ring-zinc-950
|
||||||
-bottom-1.5 -right-1.5 grid place-items-center transition-all"
|
-bottom-1 right-1 grid place-items-center transition-all"
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
src={subscribed == 'NotSubscribed' ? Plus : Check}
|
src={subscribed == 'NotSubscribed' ? Plus : Check}
|
||||||
@@ -71,36 +73,24 @@
|
|||||||
</button>
|
</button>
|
||||||
</Subscribe>
|
</Subscribe>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="flex flex-col text-xs">
|
|
||||||
{#if community}
|
{#if community}
|
||||||
<CommunityLink {community} />
|
<CommunityLink {community} style="grid-area: community;" />
|
||||||
{/if}
|
{/if}
|
||||||
<span
|
<span
|
||||||
class="text-slate-600 dark:text-zinc-400 flex flex-row gap-1 flex-wrap items-center"
|
class="text-slate-600 dark:text-zinc-400 flex flex-row gap-2 flex-wrap items-center row-span-2"
|
||||||
|
style="grid-area: stats;"
|
||||||
>
|
>
|
||||||
{#if user}
|
{#if user}
|
||||||
<div
|
|
||||||
class="mr-0.5 flex items-center"
|
|
||||||
class:text-slate-900={!community}
|
|
||||||
class:dark:text-zinc-100={!community}
|
|
||||||
>
|
|
||||||
<UserLink avatarSize={20} {user} avatar={!community} />
|
<UserLink avatarSize={20} {user} avatar={!community} />
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
{#if published}
|
{#if published}
|
||||||
<RelativeDate date={published} />
|
<RelativeDate date={published} />
|
||||||
{/if}
|
{/if}
|
||||||
{#if upvotes != undefined && downvotes != undefined}
|
|
||||||
<span>•</span>
|
|
||||||
<span>
|
|
||||||
{Math.floor((upvotes / (upvotes + downvotes || 1)) * 100)}%
|
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="flex flex-row ml-auto gap-2 flex-shrink overflow-auto [&>*]:flex-shrink-0"
|
class="flex flex-row items-center place-self-end overflow-auto [&>*]:flex-shrink-0"
|
||||||
|
style="grid-area: badges;"
|
||||||
>
|
>
|
||||||
{#if nsfw}
|
{#if nsfw}
|
||||||
<Badge color="red-subtle">NSFW</Badge>
|
<Badge color="red-subtle">NSFW</Badge>
|
||||||
@@ -137,10 +127,20 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<slot name="badges" />
|
<slot name="badges" />
|
||||||
</div>
|
</div>
|
||||||
</span>
|
|
||||||
{#if title && id}
|
{#if title && id}
|
||||||
<a href="/post/{getInstance()}/{id}" class="font-medium">
|
<a href="/post/{getInstance()}/{id}" class="font-medium">
|
||||||
{title}
|
{title}
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.meta {
|
||||||
|
display: grid;
|
||||||
|
grid-template-areas:
|
||||||
|
'avatar community badges'
|
||||||
|
'avatar stats badges';
|
||||||
|
gap: 0;
|
||||||
|
grid-template-columns: max-content;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in new issue
Block a user