misc: make posts clickable as blocks

This commit is contained in:
Xylight committed 2024-06-08 18:41:03 -07:00
1 parent 30a205cdef
commit 162262d974
6 files changed
+24 -14

No files matched your search

BIN
View File
Binary file not shown.
-7
View File
@@ -44,13 +44,6 @@
"vitest": "^1.0.0",
"workbox-window": "^7.0.0"
},
"dependencies": {
"@dicebear/core": "^6.0.4",
"@dicebear/initials": "^6.0.4",
"@sveltejs/adapter-auto": "^3.2.1",
"markdown-it": "^13.0.1",
"mono-svelte": "latest"
},
"overrides": {
"@rollup/plugin-node-resolve": "^15.2.3",
"@sveltejs/kit": "^2.0.0"
+17 -1
View File
@@ -44,13 +44,22 @@
$userSettings.posts.deduplicateEmbed &&
post.post.embed_description == post.post.body &&
view != 'compact'
function onClick(e: any) {
const event = e as MouseEvent
const parent = document.getElementById(post.post.id.toString())
if (event.target == parent) {
goto(postLink(post.post))
}
}
</script>
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<Material
color={view != 'card' ? 'none' : 'distinct'}
class="relative max-w-full min-w-0 w-full
class="relative max-w-full min-w-0 w-full group cursor-pointer
{view != 'card' ? 'bg-transparent !border-0' : 'p-5'} {view == 'compact'
? 'py-4 list-type'
: view == 'list'
@@ -58,6 +67,9 @@
: 'py-5 flex flex-col gap-2'} {$$props.class}"
id={post.post.id.toString()}
padding="none"
on:click={(e) => {
onClick(e)
}}
>
<PostMeta
community={hideCommunity ? undefined : post.community}
@@ -120,6 +132,10 @@
</Badge>
</div>
{/if}
<div
class="absolute overflow-hidden inset-y-0.5 -inset-x-4 sm:-inset-x-5 sm:rounded-xl bg-slate-100 dark:bg-zinc-900
opacity-0 group-hover:opacity-100 transition-all -z-10 no-list-margin"
/>
</Material>
<style>
@@ -31,7 +31,8 @@
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'} {$$props.class ?? ''}"
: 'text-slate-600 dark:text-zinc-400 max-h-full'} pointer-events-none {$$props.class ??
''}"
bind:this={element}
>
<Markdown inline={!expanded} source={body} />
@@ -40,7 +41,7 @@ ${view == 'list' ? `max-h-24` : 'max-h-48'}`
on:click={() => (expanded = !expanded)}
size="square-sm"
color="tertiary"
class="text-black dark:text-white absolute z-10 isolate drop-shadow-xl {expanded
class="text-black dark:text-white absolute z-10 isolate drop-shadow-xl pointer-events-auto {expanded
? 'bottom-6'
: 'bottom-16'} left-1/2 -translate-x-1/2"
title="Expand"
@@ -164,8 +164,8 @@
{#if title && id}
<a
href="/post/{getInstance()}/{id}"
class="text-lg leading-6 w-full hover:underline hover:text-primary-900 hover:dark:text-primary-100
transition-colors
class="inline text-lg hover:underline
hover:text-primary-900 hover:dark:text-primary-100 transition-colors
{$userSettings.font == 'satoshi/nunito'
? 'font-display font-semibold'
: 'font-medium'}"
@@ -173,7 +173,7 @@
class:dark:text-zinc-400={$userSettings.markReadPosts && read}
style="grid-area: title;"
>
<Markdown source={title} inline noStyle></Markdown>
<Markdown source={title} inline noStyle class="leading-6"></Markdown>
</a>
{/if}
+1 -1
View File
@@ -110,7 +110,7 @@
/>
<slot
name="main"
class="w-full bg-slate-25 dark:bg-zinc-925 justify-self-center shadow-sm
class="w-full bg-slate-25 dark:bg-zinc-925 justify-self-center shadow-sm z-0
{contentPadding}"
style="grid-area: main"
/>