perf: un-tailwind PostImage.svelte and improve render performance
This commit is contained in:
5 files changed
+91
-46
No files matched your search
@@ -115,7 +115,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column-reverse;
|
flex-direction: column-reverse;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
gap: calc(var(--spacing) * 4);
|
gap: calc(var(--spacing) * 2);
|
||||||
position: relative;
|
position: relative;
|
||||||
@variant sm {
|
@variant sm {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
@@ -160,22 +160,21 @@
|
|||||||
.post-link-image {
|
.post-link-image {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
margin-bottom: auto;
|
margin-bottom: auto;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
@variant sm {
|
@variant sm {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@variant max-md {
|
|
||||||
mask-image: linear-gradient(to bottom, black, transparent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@variant sm {
|
@variant sm {
|
||||||
width: 33%;
|
width: 33%;
|
||||||
max-width: calc(var(--spacing) * 90);
|
max-width: calc(var(--spacing) * 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
@variant md {
|
&::after {
|
||||||
mask-image: linear-gradient(to left, black, black, transparent);
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
|
|||||||
@@ -23,11 +23,7 @@
|
|||||||
<svelte:element
|
<svelte:element
|
||||||
this={settings.expandImages ? 'button' : 'a'}
|
this={settings.expandImages ? 'button' : 'a'}
|
||||||
href={postLink(post)}
|
href={postLink(post)}
|
||||||
class={[
|
class={['container/a group post-image-container']}
|
||||||
'container/a z-10 rounded-2xl cursor-pointer relative overflow-hidden',
|
|
||||||
'bg-slate-100 dark:bg-zinc-900 transition-colors',
|
|
||||||
'border border-slate-200 dark:border-zinc-800 group',
|
|
||||||
]}
|
|
||||||
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))}
|
||||||
@@ -35,12 +31,12 @@
|
|||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
<!-- svelte-ignore a11y_missing_attribute -->
|
<!-- svelte-ignore a11y_missing_attribute -->
|
||||||
<div class="inset-0 absolute -z-10 rounded-xl overflow-hidden">
|
<div class="post-image-blur-container">
|
||||||
<img
|
<img
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
fetchpriority="auto"
|
fetchpriority="auto"
|
||||||
src={bestImageURL(post, false, 64)}
|
src={bestImageURL(post, false, 64)}
|
||||||
class=" object-cover w-full h-full opacity-50 blur-lg"
|
class="post-image-blur"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<picture class="max-h-[60vh]">
|
<picture class="max-h-[60vh]">
|
||||||
@@ -70,7 +66,7 @@
|
|||||||
src={blur ? '' : bestImageURL(post, false, -1, null)}
|
src={blur ? '' : bestImageURL(post, false, -1, null)}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
class={[
|
class={[
|
||||||
'max-w-full rounded-xl z-30 transition-all max-h-[60vh] duration-500 object-contain mx-auto group-hover:scale-98 group-active:scale-95',
|
'post-image',
|
||||||
'duration-200 ease-cubic',
|
'duration-200 ease-cubic',
|
||||||
imageLoaded === false ? 'opacity-0' : 'opacity-100',
|
imageLoaded === false ? 'opacity-0' : 'opacity-100',
|
||||||
blur && 'blur-3xl',
|
blur && 'blur-3xl',
|
||||||
@@ -107,3 +103,59 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</svelte:element>
|
</svelte:element>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
@reference '../../../../app.css';
|
||||||
|
|
||||||
|
.post-image-container {
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: var(--radius-2xl);
|
||||||
|
cursor: pointer;
|
||||||
|
background-color: var(--color-slate-100);
|
||||||
|
border: 1px solid var(--color-slate-200);
|
||||||
|
z-index: 10;
|
||||||
|
|
||||||
|
@variant dark {
|
||||||
|
background-color: var(--color-zinc-900);
|
||||||
|
border-color: var(--color-zinc-800);
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-image {
|
||||||
|
max-width: 100%;
|
||||||
|
z-index: 30;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
transition: filter 400ms cubic-bezier(0.075, 0.82, 0.165, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
.post-image {
|
||||||
|
transition-duration: 0;
|
||||||
|
filter: brightness(85%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
.post-image {
|
||||||
|
filter: brightness(75%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-image-blur-container {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
z-index: -10;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
.post-image-blur {
|
||||||
|
width: 2%;
|
||||||
|
height: 2%;
|
||||||
|
filter: blur(1px);
|
||||||
|
opacity: 0.3;
|
||||||
|
transform: scale(100);
|
||||||
|
transform-origin: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -175,14 +175,14 @@
|
|||||||
background-image: linear-gradient(
|
background-image: linear-gradient(
|
||||||
to bottom,
|
to bottom,
|
||||||
--alpha(var(--color-slate-50) / 0%),
|
--alpha(var(--color-slate-50) / 0%),
|
||||||
--alpha(var(--color-slate-50) / 95%)
|
var(--color-slate-50)
|
||||||
);
|
);
|
||||||
|
|
||||||
@variant dark {
|
@variant dark {
|
||||||
background-image: linear-gradient(
|
background-image: linear-gradient(
|
||||||
to bottom,
|
to bottom,
|
||||||
--alpha(var(--color-zinc-900) / 0%),
|
--alpha(var(--color-zinc-900) / 0%),
|
||||||
--alpha(var(--color-zinc-900) / 95%)
|
var(--color-zinc-900)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,6 @@
|
|||||||
|
|
||||||
translate: 0% 0%;
|
translate: 0% 0%;
|
||||||
transition: translate 0.4s cubic-bezier(0.19, 1, 0.22, 1);
|
transition: translate 0.4s cubic-bezier(0.19, 1, 0.22, 1);
|
||||||
will-change: translate;
|
|
||||||
|
|
||||||
@variant max-md {
|
@variant max-md {
|
||||||
&.auto-hidden {
|
&.auto-hidden {
|
||||||
@@ -91,33 +90,30 @@
|
|||||||
top: 0;
|
top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
:global {
|
:global(.shell-navbar) {
|
||||||
.shell-navbar {
|
pointer-events: auto;
|
||||||
pointer-events: auto;
|
border-width: 1px;
|
||||||
backdrop-filter: blur(var(--blur-xl));
|
border-color: var(--color-slate-100);
|
||||||
border-width: 1px;
|
border-top: none;
|
||||||
border-color: var(--color-slate-100);
|
background-color: var(--color-slate-50);
|
||||||
border-top: none;
|
|
||||||
background-color: var(--color-slate-50);
|
|
||||||
|
|
||||||
@variant max-md {
|
@variant max-md {
|
||||||
padding-bottom: max(
|
padding-bottom: max(
|
||||||
env(safe-area-inset-bottom),
|
env(safe-area-inset-bottom),
|
||||||
calc(var(--spacing) * 2)
|
calc(var(--spacing) * 2)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@variant md {
|
||||||
|
border-left: none;
|
||||||
|
border-right: none;
|
||||||
|
background-color: --alpha(var(--color-slate-50) / 70%);
|
||||||
|
}
|
||||||
|
|
||||||
|
@variant dark {
|
||||||
|
background-color: var(--color-zinc-950);
|
||||||
|
border-color: var(--color-zinc-900);
|
||||||
@variant md {
|
@variant md {
|
||||||
border-left: none;
|
|
||||||
border-right: none;
|
|
||||||
background-color: --alpha(var(--color-slate-50) / 70%);
|
|
||||||
}
|
|
||||||
|
|
||||||
@variant dark {
|
|
||||||
background-color: var(--color-zinc-950);
|
|
||||||
border-color: var(--color-zinc-900);
|
|
||||||
@variant md {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,10 +111,8 @@
|
|||||||
|
|
||||||
@variant dark {
|
@variant dark {
|
||||||
background: var(--color-zinc-900);
|
background: var(--color-zinc-900);
|
||||||
border-color: var(--color-zinc-950);
|
border-color: var(--color-zinc-800);
|
||||||
box-shadow:
|
border-top-color: var(--color-zinc-700);
|
||||||
0px 1.5px 0px 0px inset var(--color-zinc-700),
|
|
||||||
0px -1px 0px 0px inset var(--color-zinc-950);
|
|
||||||
|
|
||||||
@variant hover {
|
@variant hover {
|
||||||
background-color: var(--color-zinc-925);
|
background-color: var(--color-zinc-925);
|
||||||
|
|||||||
Reference in new issue
Block a user