design: improve responsiveness for images
This commit is contained in:
4 files changed
+34
-29
No files matched your search
+1
-1
@@ -17,7 +17,7 @@
|
|||||||
"@tailwindcss/postcss": "^4.1.8",
|
"@tailwindcss/postcss": "^4.1.8",
|
||||||
"@types/nprogress": "^0.2.0",
|
"@types/nprogress": "^0.2.0",
|
||||||
"@types/ua-parser-js": "^0.7.39",
|
"@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": "^9.28.0",
|
||||||
"eslint-plugin-svelte": "^3.11.0",
|
"eslint-plugin-svelte": "^3.11.0",
|
||||||
"jsdom": "^22.1.0",
|
"jsdom": "^22.1.0",
|
||||||
|
|||||||
@@ -24,7 +24,11 @@
|
|||||||
<svelte:element
|
<svelte:element
|
||||||
this={settings.expandImages ? 'button' : 'a'}
|
this={settings.expandImages ? 'button' : 'a'}
|
||||||
href={postLink(post)}
|
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"
|
data-sveltekit-preload-data="off"
|
||||||
aria-label={post.name}
|
aria-label={post.name}
|
||||||
onclick={() => showImage(bestImageURL(post, false, -1, null))}
|
onclick={() => showImage(bestImageURL(post, false, -1, null))}
|
||||||
@@ -32,14 +36,15 @@
|
|||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
<!-- svelte-ignore a11y_missing_attribute -->
|
<!-- svelte-ignore a11y_missing_attribute -->
|
||||||
|
<div class="inset-2 absolute -z-10 rounded-xl overflow-hidden">
|
||||||
<img
|
<img
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
fetchpriority="auto"
|
fetchpriority="auto"
|
||||||
src={bestImageURL(post, false, 64)}
|
src={bestImageURL(post, false, 64)}
|
||||||
class="-z-10 absolute top-0 left-0 w-full h-full object-cover blur-lg
|
class=" object-cover w-full h-full opacity-50 blur-lg"
|
||||||
scale-[1.2] opacity-50"
|
|
||||||
/>
|
/>
|
||||||
<picture class="max-h-[inherit]">
|
</div>
|
||||||
|
<picture class="max-h-[60vh]">
|
||||||
{#each ['webp'] as format}
|
{#each ['webp'] as format}
|
||||||
<source
|
<source
|
||||||
srcset="{bestImageURL(
|
srcset="{bestImageURL(
|
||||||
@@ -66,7 +71,7 @@
|
|||||||
src={bestImageURL(post, false, -1, null)}
|
src={bestImageURL(post, false, -1, null)}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
class={[
|
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',
|
imageLoaded === false ? 'opacity-0' : 'opacity-100',
|
||||||
blur && 'blur-3xl',
|
blur && 'blur-3xl',
|
||||||
]}
|
]}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
@component
|
@component
|
||||||
Thumbnails for compact and list view posts.
|
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}
|
{#if post.alt_text}
|
||||||
<Button
|
<Button
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
@@ -64,11 +64,18 @@
|
|||||||
}}
|
}}
|
||||||
role="button"
|
role="button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer h-full"
|
||||||
|
>
|
||||||
|
<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)}
|
{#if post.thumbnail_url || isImage(post.url)}
|
||||||
{@const thumbnail = post.thumbnail_url != undefined && !isImage(post.url)}
|
{@const thumbnail =
|
||||||
<div class="relative overflow-hidden rounded-xl">
|
post.thumbnail_url != undefined && !isImage(post.url)}
|
||||||
<picture>
|
<picture>
|
||||||
<!--I would add AVIF, but lemmy.world's AVIF is broken as of currently-->
|
<!--I would add AVIF, but lemmy.world's AVIF is broken as of currently-->
|
||||||
{#each ['webp'] as format}
|
{#each ['webp'] as format}
|
||||||
@@ -97,7 +104,7 @@
|
|||||||
src={bestImageURL(post, thumbnail, -1, null)}
|
src={bestImageURL(post, thumbnail, -1, null)}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
class={[
|
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,
|
size,
|
||||||
]}
|
]}
|
||||||
alt={post.alt_text ?? ' '}
|
alt={post.alt_text ?? ' '}
|
||||||
@@ -119,27 +126,11 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</picture>
|
</picture>
|
||||||
</div>
|
|
||||||
{#if blur}
|
|
||||||
<div
|
|
||||||
class="absolute w-full h-full grid place-items-center inset-0 z-30"
|
|
||||||
>
|
|
||||||
<Icon
|
|
||||||
src={ExclamationTriangle}
|
|
||||||
solid
|
|
||||||
size="32"
|
|
||||||
class="z-50 opacity-30"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
{:else}
|
{:else}
|
||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
'object-cover overflow-hidden bg-slate-50 dark:bg-zinc-900 rounded-xl',
|
'bg-slate-100 dark:bg-zinc-900 w-full h-full rounded-xl grid place-items-center',
|
||||||
'border border-slate-200 dark:border-zinc-800',
|
'text-slate-600 dark:text-zinc-400',
|
||||||
'transition-colors text-slate-400 dark:text-zinc-600 grid',
|
|
||||||
'place-items-center',
|
|
||||||
size,
|
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
@@ -153,5 +144,14 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
</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>
|
</svelte:element>
|
||||||
</div>
|
</div>
|
||||||
Reference in new issue
Block a user