FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: Add click-to-zoom lightbox for blog post images by franciscojavierarceo · Pull Request #6575 · feast-dev/feast · GitHub

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .astro  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
66 changes: 65 additions & 1 deletion infra/website/src/pages/blog/[slug].astro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ const socialImage = heroImage ? toAbsoluteUrl(heroImage) : undefined;
height: auto;
border-radius: 4px;
margin: 32px 0;
cursor: zoom-in;
}

/* Hero Image */
Expand Down Expand Up @@ -339,4 +340,67 @@ const socialImage = heroImage ? toAbsoluteUrl(heroImage) : undefined;
font-size: 18px;
}
}
</style>
</style>

<script>
const overlay = document.createElement('div');
overlay.className = 'lightbox-overlay';
const img = document.createElement('img');
overlay.appendChild(img);
document.body.appendChild(overlay);

function open(src: string, alt: string) {
img.src = src;
img.alt = alt;
overlay.classList.add('active');
document.body.style.overflow = 'hidden';
}

function close() {
overlay.classList.remove('active');
document.body.style.overflow = '';
}

overlay.addEventListener('click', close);

document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') close();
});

document.querySelectorAll('.blog-content img').forEach((el) => {
el.addEventListener('click', () => {
const image = el as HTMLImageElement;
open(image.src, image.alt);
});
});
</script>

<style is:global>
.lightbox-overlay {
position: fixed;
inset: 0;
z-index: 9999;
background: rgba(0, 0, 0, 0.85);
display: flex;
align-items: center;
justify-content: center;
cursor: zoom-out;
opacity: 0;
visibility: hidden;
transition: opacity 0.2s ease, visibility 0.2s ease;
}

.lightbox-overlay.active {
opacity: 1;
visibility: visible;
}

.lightbox-overlay img {
max-width: 90vw;
max-height: 90vh;
object-fit: contain;
border-radius: 4px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
</style>

Loading

Back | FazBrowse Home | New Git URL