Skip to content

Commit

Permalink
fix: Actually centre images
Browse files Browse the repository at this point in the history
  • Loading branch information
kiosion committed Nov 19, 2023
1 parent ed136e9 commit 5876659
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions svelte-app/src/components/images/image.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
placeholderSrc =
placeholder || buildImageUrl({ ref: _ref, crop, width: 30, blur: 40 }),
style = `max-width: ${imgDimensions.width}px; max-height: ${imgDimensions.height}px; aspect-ratio: ${imgDimensions.width} / ${imgDimensions.height};`,
placeholderStyle = `${style} position: absolute; top: 0; left: 0; opacity: 50%;`,
[send, receive] = crossfade({
duration: (d: number) => Math.sqrt(d * 200),
fallback(node, params) {
Expand Down Expand Up @@ -87,10 +86,11 @@
>
{#if showImageModal}
<img
class="placeholder"
src={placeholderSrc}
alt={_key}
draggable="false"
style={placeholderStyle}
{style}
out:fade={{ duration: BASE_ANIMATION_DURATION }}
/>
{:else}
Expand All @@ -113,14 +113,13 @@
alt={_key}
draggable="false"
aria-hidden="true"
style={placeholderStyle}
{style}
/>
</div>

<ImageModal bind:dialog bind:show={showImageModal}>
<img
src={fullSrc}
draggable="false"
alt={_key}
{style}
in:receive={{ key: _key, duration: BASE_ANIMATION_DURATION }}
Expand All @@ -131,27 +130,39 @@
<style lang="scss">
@import '@styles/mixins';
.placeholder,
.backdrop {
position: absolute;
top: 0;
}
.placeholder {
left: 0;
opacity: 50%;
}
div:not(.loading) {
@apply relative w-full;
.backdrop {
@apply transition-opacity;
@apply -translate-x-1/2 transition-opacity;
z-index: -1;
filter: blur(20px);
opacity: 0.2 !important;
opacity: 0.2;
left: 50%;
}
&:hover,
&:focus-visible {
.backdrop {
opacity: 0.3 !important;
opacity: 30%;
}
}
}
button {
@apply relative block max-h-fit w-full rounded-sm;
@apply relative mx-auto block max-h-fit w-full rounded-sm;
@include focus-state(sm);
}
Expand Down

0 comments on commit 5876659

Please sign in to comment.