feat: use background clips instead of a weird absolute whatever
This commit is contained in:
1 parent
aa6650ec76
commit
b6788c7fc1
2 files changed
+36
-21
No files matched your search
@@ -3,17 +3,39 @@
|
|||||||
export let highlight: boolean = false
|
export let highlight: boolean = false
|
||||||
export let nowrap: boolean = false
|
export let nowrap: boolean = false
|
||||||
|
|
||||||
|
const parseURL = (href: string) => {
|
||||||
|
try {
|
||||||
|
return new URL(href)
|
||||||
|
} catch (e) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$: richURL = parseURL(href)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<a {href} class="{highlight ? 'text-blue-500' : ''} hover:underline max-w-full">
|
<a {href} class="{highlight ? 'text-blue-500' : ''} hover:underline max-w-full">
|
||||||
<slot name="icon" />
|
<slot name="icon" />
|
||||||
<slot>
|
<slot>
|
||||||
<span
|
<span
|
||||||
class="flex gap-0 {nowrap
|
class="flex relative gap-0 {nowrap
|
||||||
? 'w-full whitespace-nowrap overflow-hidden text-ellipsis text-xs'
|
? 'w-full whitespace-nowrap overflow-hidden text-ellipsis text-xs'
|
||||||
: ''} {$$props.class}"
|
: ''} {$$props.class} text-transparent bg-clip-text bg-gradient-to-r
|
||||||
|
from-blue-500 via-blue-500 to-blue-500/0"
|
||||||
>
|
>
|
||||||
|
{#if richURL}
|
||||||
|
<span class="opacity-60">
|
||||||
|
{richURL.protocol}//
|
||||||
|
</span>
|
||||||
|
<span class="font-medium">
|
||||||
|
{richURL.hostname}
|
||||||
|
</span>
|
||||||
|
<span class="opacity-60">
|
||||||
|
{richURL.pathname}
|
||||||
|
</span>
|
||||||
|
{:else}
|
||||||
{href}
|
{href}
|
||||||
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
</slot>
|
</slot>
|
||||||
</a>
|
</a>
|
||||||
@@ -39,9 +39,9 @@
|
|||||||
<div
|
<div
|
||||||
class="flex {$userSettings.leftAlign
|
class="flex {$userSettings.leftAlign
|
||||||
? 'flex-row-reverse'
|
? 'flex-row-reverse'
|
||||||
: 'flex-row'} gap-4 max-w-full w-full"
|
: 'flex-row'} gap-4 max-w-full w-full min-w-0"
|
||||||
>
|
>
|
||||||
<div class="flex flex-col w-full gap-2">
|
<div class="flex flex-col w-full gap-2 flex-1 max-w-full min-w-0">
|
||||||
<div class="flex flex-col w-full gap-2">
|
<div class="flex flex-col w-full gap-2">
|
||||||
<PostMeta
|
<PostMeta
|
||||||
community={hideCommunity ? undefined : post.community}
|
community={hideCommunity ? undefined : post.community}
|
||||||
@@ -66,8 +66,8 @@
|
|||||||
<Markdown source={post.post.name} inline />
|
<Markdown source={post.post.name} inline />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{#if $userSettings.view == 'card'}
|
|
||||||
{#if isImage(post.post.url)}
|
{#if isImage(post.post.url)}
|
||||||
|
{#if view == 'card'}
|
||||||
<!--disabled preloads here since most people will hover over every image while scrolling-->
|
<!--disabled preloads here since most people will hover over every image while scrolling-->
|
||||||
<svelte:component
|
<svelte:component
|
||||||
this={$userSettings.expandImages ? ExpandableImage : Empty}
|
this={$userSettings.expandImages ? ExpandableImage : Empty}
|
||||||
@@ -106,38 +106,31 @@
|
|||||||
</picture>
|
</picture>
|
||||||
</svelte:element>
|
</svelte:element>
|
||||||
</svelte:component>
|
</svelte:component>
|
||||||
|
{/if}
|
||||||
{:else if post.post.url}
|
{:else if post.post.url}
|
||||||
<PostLink
|
<PostLink
|
||||||
url={post.post.url}
|
url={post.post.url}
|
||||||
thumbnail_url={post.post.thumbnail_url
|
thumbnail_url={view == 'card'
|
||||||
|
? 'post.post.thumbnail_url'
|
||||||
? `${post.post.thumbnail_url}?format=webp&thumbnail=512`
|
? `${post.post.thumbnail_url}?format=webp&thumbnail=512`
|
||||||
|
: undefined
|
||||||
: undefined}
|
: undefined}
|
||||||
nsfw={post.post.nsfw}
|
nsfw={post.post.nsfw}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
|
||||||
{#if post.post.body && !post.post.nsfw && (view == 'list' || view == 'card')}
|
{#if post.post.body && !post.post.nsfw && (view == 'list' || view == 'card')}
|
||||||
<div
|
<div
|
||||||
class="text-sm relative overflow-hidden {view == 'list'
|
class="text-sm relative overflow-hidden
|
||||||
? `text-zinc-600 dark:text-zinc-400 max-h-24`
|
bg-gradient-to-b text-transparent from-slate-600 via-slate-600
|
||||||
: 'text-slate-600 dark:text-zinc-400 max-h-48'} paragraph"
|
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.slice(0, 400)} />
|
<Markdown inline source={post.post.body.slice(0, 400)} />
|
||||||
{#if post.post.body.length > (view == 'list' ? 200 : 600)}
|
|
||||||
<div
|
|
||||||
class="absolute bottom-0 w-full h-16 bg-gradient-to-b {view ==
|
|
||||||
'list'
|
|
||||||
? `dark:from-zinc-950/0 dark:to-zinc-950
|
|
||||||
from-slate-25/0 to-slate-25 group-hover:from-slate-50/0 group-hover:to-slate-50
|
|
||||||
transition-all group-hover:dark:from-zinc-900/0 group-hover:dark:to-zinc-900`
|
|
||||||
: 'dark:from-zinc-900/0 dark:to-zinc-900 from-white/0 to-white'}"
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if ($userSettings.view == 'list' || $userSettings.view == 'compact') && (post.post.thumbnail_url || isImage(post.post.url))}
|
{#if ($userSettings.view == 'list' || $userSettings.view == 'compact') && (post.post.thumbnail_url || isImage(post.post.url))}
|
||||||
<div class="flex-none w-24 h-24">
|
<div class="flex-shrink-0 w-24 h-24">
|
||||||
{#if !$userSettings.expandImages || (post.post.thumbnail_url && !isImage(post.post.url))}
|
{#if !$userSettings.expandImages || (post.post.thumbnail_url && !isImage(post.post.url))}
|
||||||
<a href={postLink(post.post)}>
|
<a href={postLink(post.post)}>
|
||||||
<!-- svelte-ignore a11y-missing-attribute -->
|
<!-- svelte-ignore a11y-missing-attribute -->
|
||||||
|
|||||||
Reference in new issue
Block a user