refactor: redundant check
This commit is contained in:
1 parent
1a81c6c1a5
commit
df0a44b9c2
1 file changed
+66
-68
@@ -17,76 +17,74 @@
|
|||||||
export let type: MediaType = 'none'
|
export let type: MediaType = 'none'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if view == 'compact' || view == 'list'}
|
<div
|
||||||
<div
|
class="w-24 sm:w-32 h-24 relative group/media {$$props.class ?? ''}"
|
||||||
class="w-24 sm:w-32 h-24 relative group/media {$$props.class ?? ''}"
|
style={$$props.style ?? ''}
|
||||||
style={$$props.style ?? ''}
|
>
|
||||||
>
|
{#if post.alt_text}
|
||||||
{#if post.alt_text}
|
<Popover
|
||||||
<Popover
|
openOnHover
|
||||||
openOnHover
|
placement={$userSettings.leftAlign ? 'bottom-start' : 'bottom-end'}
|
||||||
placement={$userSettings.leftAlign ? 'bottom-start' : 'bottom-end'}
|
|
||||||
>
|
|
||||||
<Material
|
|
||||||
slot="target"
|
|
||||||
padding="none"
|
|
||||||
rounding="full"
|
|
||||||
elevation="high"
|
|
||||||
class="w-max absolute bottom-0 left-0 py-0.5 px-1.5 m-1 font-bold"
|
|
||||||
>
|
|
||||||
ALT
|
|
||||||
</Material>
|
|
||||||
<div class="max-w-sm">
|
|
||||||
{post.alt_text}
|
|
||||||
</div>
|
|
||||||
</Popover>
|
|
||||||
{/if}
|
|
||||||
<svelte:element
|
|
||||||
this={!$userSettings.expandImages || type != 'image' ? 'a' : 'button'}
|
|
||||||
href={postLink(post)}
|
|
||||||
on:click={() => {
|
|
||||||
if (type == 'image') {
|
|
||||||
showImage(bestImageURL(post, false, 2048))
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
role="button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
>
|
||||||
{#if post.thumbnail_url || isImage(post.url)}
|
<Material
|
||||||
<img
|
slot="target"
|
||||||
src={optimizeImageURL(post.thumbnail_url || post.url || '', 128)}
|
padding="none"
|
||||||
loading="lazy"
|
rounding="full"
|
||||||
class="object-cover overflow-hidden bg-slate-100 dark:bg-zinc-800 rounded-xl h-24 w-24 sm:w-32
|
elevation="high"
|
||||||
border border-slate-200 dark:border-zinc-800 group-hover/media:border-slate-400
|
class="w-max absolute bottom-0 left-0 py-0.5 px-1.5 m-1 font-bold"
|
||||||
group-hover/media:dark:border-zinc-600 transition-colors"
|
>
|
||||||
alt={post.name}
|
ALT
|
||||||
/>
|
</Material>
|
||||||
{#if type != 'image'}
|
<div class="max-w-sm">
|
||||||
<div
|
{post.alt_text}
|
||||||
class="relative w-7 h-7 bottom-8 left-1 rounded-lg text-slate-800 dark:text-zinc-200
|
</div>
|
||||||
backdrop-blur-sm bg-[#ffffff]/75 dark:bg-black/75 grid place-items-center"
|
</Popover>
|
||||||
>
|
{/if}
|
||||||
<Icon src={type == 'iframe' ? VideoCamera : Link} mini size="16" />
|
<svelte:element
|
||||||
</div>
|
this={!$userSettings.expandImages || type != 'image' ? 'a' : 'button'}
|
||||||
{/if}
|
href={postLink(post)}
|
||||||
{:else}
|
on:click={() => {
|
||||||
|
if (type == 'image') {
|
||||||
|
showImage(bestImageURL(post, false, 2048))
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
role="button"
|
||||||
|
tabindex="0"
|
||||||
|
>
|
||||||
|
{#if post.thumbnail_url || isImage(post.url)}
|
||||||
|
<img
|
||||||
|
src={optimizeImageURL(post.thumbnail_url || post.url || '', 128)}
|
||||||
|
loading="lazy"
|
||||||
|
class="object-cover overflow-hidden bg-slate-100 dark:bg-zinc-800 rounded-xl h-24 w-24 sm:w-32
|
||||||
|
border border-slate-200 dark:border-zinc-800 group-hover/media:border-slate-400
|
||||||
|
group-hover/media:dark:border-zinc-600 transition-colors"
|
||||||
|
alt={post.name}
|
||||||
|
/>
|
||||||
|
{#if type != 'image'}
|
||||||
<div
|
<div
|
||||||
class="object-cover overflow-hidden bg-slate-100 dark:bg-zinc-800 rounded-xl h-24 w-24 sm:w-32
|
class="relative w-7 h-7 bottom-8 left-1 rounded-lg text-slate-800 dark:text-zinc-200
|
||||||
border border-slate-200 dark:border-zinc-800 group-hover/media:border-slate-400
|
backdrop-blur-sm bg-[#ffffff]/75 dark:bg-black/75 grid place-items-center"
|
||||||
group-hover/media:dark:border-zinc-600 transition-colors text-slate-400 dark:text-zinc-600 grid
|
|
||||||
place-items-center"
|
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon src={type == 'iframe' ? VideoCamera : Link} mini size="16" />
|
||||||
src={type == 'embed'
|
|
||||||
? Link
|
|
||||||
: type == 'iframe'
|
|
||||||
? VideoCamera
|
|
||||||
: DocumentText}
|
|
||||||
solid
|
|
||||||
size="32"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</svelte:element>
|
{:else}
|
||||||
</div>
|
<div
|
||||||
{/if}
|
class="object-cover overflow-hidden bg-slate-100 dark:bg-zinc-800 rounded-xl h-24 w-24 sm:w-32
|
||||||
|
border border-slate-200 dark:border-zinc-800 group-hover/media:border-slate-400
|
||||||
|
group-hover/media:dark:border-zinc-600 transition-colors text-slate-400 dark:text-zinc-600 grid
|
||||||
|
place-items-center"
|
||||||
|
>
|
||||||
|
<Icon
|
||||||
|
src={type == 'embed'
|
||||||
|
? Link
|
||||||
|
: type == 'iframe'
|
||||||
|
? VideoCamera
|
||||||
|
: DocumentText}
|
||||||
|
solid
|
||||||
|
size="32"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</svelte:element>
|
||||||
|
</div>
|
||||||
Reference in new issue
Block a user