design: improve responsiveness for images

This commit is contained in:
James Xylight committed 2025-08-05 13:49:47 -07:00
1 parent 7c6a09f742
commit a023452f78
4 files changed
+47 -42

No files matched your search

BIN
View File
Binary file not shown.
+1 -1
View File
@@ -17,7 +17,7 @@
"@tailwindcss/postcss": "^4.1.8",
"@types/nprogress": "^0.2.0",
"@types/ua-parser-js": "^0.7.39",
"@xylightdev/svelte-hero-icons": "^2.2.4",
"@xylightdev/svelte-hero-icons": "^2.2.7",
"eslint": "^9.28.0",
"eslint-plugin-svelte": "^3.11.0",
"jsdom": "^22.1.0",
@@ -24,7 +24,11 @@
<svelte:element
this={settings.expandImages ? 'button' : 'a'}
href={postLink(post)}
class="container mx-auto z-10 rounded-xl max-h-[60vh] relative overflow-hidden bg-slate-100 dark:bg-zinc-900"
class={[
'container/a z-10 rounded-2xl cursor-pointer relative overflow-hidden',
'bg-slate-100 dark:bg-zinc-900 transition-colors p-2',
'border border-slate-200 dark:border-zinc-800 hover:border-slate-300 hover:dark:border-zinc-700',
]}
data-sveltekit-preload-data="off"
aria-label={post.name}
onclick={() => showImage(bestImageURL(post, false, -1, null))}
@@ -32,14 +36,15 @@
tabindex="0"
>
<!-- svelte-ignore a11y_missing_attribute -->
<img
loading="lazy"
fetchpriority="auto"
src={bestImageURL(post, false, 64)}
class="-z-10 absolute top-0 left-0 w-full h-full object-cover blur-lg
scale-[1.2] opacity-50"
/>
<picture class="max-h-[inherit]">
<div class="inset-2 absolute -z-10 rounded-xl overflow-hidden">
<img
loading="lazy"
fetchpriority="auto"
src={bestImageURL(post, false, 64)}
class=" object-cover w-full h-full opacity-50 blur-lg"
/>
</div>
<picture class="max-h-[60vh]">
{#each ['webp'] as format}
<source
srcset="{bestImageURL(
@@ -66,7 +71,7 @@
src={bestImageURL(post, false, -1, null)}
loading="lazy"
class={[
'max-h-[inherit] max-w-full h-auto z-30 transition-opacity duration-500 object-contain mx-auto',
'max-w-full rounded-xl z-30 transition-opacity max-h-[60vh] duration-500 object-contain mx-auto',
imageLoaded === false ? 'opacity-0' : 'opacity-100',
blur && 'blur-3xl',
]}
@@ -46,7 +46,7 @@
@component
Thumbnails for compact and list view posts.
-->
<div class="{size} relative group/media {clazz ?? ''}" {style}>
<div class={[size, 'relative group/media', clazz]} {style}>
{#if post.alt_text}
<Button
rounding="pill"
@@ -64,11 +64,18 @@
}}
role="button"
tabindex="0"
class="cursor-pointer"
class="cursor-pointer h-full"
>
{#if post.thumbnail_url || isImage(post.url)}
{@const thumbnail = post.thumbnail_url != undefined && !isImage(post.url)}
<div class="relative overflow-hidden rounded-xl">
<div
class={[
'relative overflow-hidden rounded-2xl max-h-full',
'p-1 h-full',
'border border-slate-200 dark:border-zinc-800 hover:border-slate-300 dark:hover:border-zinc-700',
]}
>
{#if post.thumbnail_url || isImage(post.url)}
{@const thumbnail =
post.thumbnail_url != undefined && !isImage(post.url)}
<picture>
<!--I would add AVIF, but lemmy.world's AVIF is broken as of currently-->
{#each ['webp'] as format}
@@ -97,7 +104,7 @@
src={bestImageURL(post, thumbnail, -1, null)}
loading="lazy"
class={[
'object-cover relative overflow-hidden bg-slate-100 dark:bg-zinc-800 rounded-xl transition-colors',
'object-cover relative overflow-hidden rounded-xl h-full bg-slate-200 dark:bg-zinc-900',
size,
]}
alt={post.alt_text ?? ' '}
@@ -119,39 +126,32 @@
</div>
{/if}
</picture>
</div>
{#if blur}
{:else}
<div
class="absolute w-full h-full grid place-items-center inset-0 z-30"
class={[
'bg-slate-100 dark:bg-zinc-900 w-full h-full rounded-xl grid place-items-center',
'text-slate-600 dark:text-zinc-400',
]}
>
<Icon
src={ExclamationTriangle}
src={type == 'embed'
? Link
: type == 'iframe'
? VideoCamera
: DocumentText}
solid
size="32"
class="z-50 opacity-30"
/>
</div>
{/if}
{:else}
<div
class={[
'object-cover overflow-hidden bg-slate-50 dark:bg-zinc-900 rounded-xl',
'border border-slate-200 dark:border-zinc-800',
'transition-colors text-slate-400 dark:text-zinc-600 grid',
'place-items-center',
size,
]}
>
<Icon
src={type == 'embed'
? Link
: type == 'iframe'
? VideoCamera
: DocumentText}
solid
size="32"
/>
</div>
</div>
{#if blur}
<Icon
src={ExclamationTriangle}
solid
size="32"
class="absolute w-8 h-8 mx-auto my-auto z-30 inset-0 opacity-30"
/>
{/if}
</svelte:element>
</div>