-
-
Notifications
You must be signed in to change notification settings - Fork 21
Add images to work experience #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
coderdiaz
merged 6 commits into
coderdiaz:main
from
shrvansudhakara:feat/work-experience-images
Oct 31, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b2e793b
feat: add image gallery to work experience
shrvansudhakara 979b22d
Update src/components/ui/WorkExperience.astro
shrvansudhakara 23ee8cd
fix: add error handling for container removal in lightbox
shrvansudhakara f2b019d
merge: resolve conflict in WorkExperience.astro
shrvansudhakara 3caa8b1
refactor: address code review feedback
shrvansudhakara 2f394a7
fix: remove top-level return and implement Framer Motion lightbox
shrvansudhakara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
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
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 |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| import { useState, useEffect } from 'react'; | ||
| import { motion, AnimatePresence } from 'framer-motion'; | ||
|
|
||
| interface ImageLightboxProps { | ||
| images: { src: string; alt?: string }[]; | ||
| isOpen: boolean; | ||
| initialIndex: number; | ||
| onClose: () => void; | ||
| } | ||
|
|
||
| export default function ImageLightbox({ | ||
| images, | ||
| isOpen, | ||
| initialIndex, | ||
| onClose, | ||
| }: ImageLightboxProps) { | ||
| const [currentIndex, setCurrentIndex] = useState(initialIndex); | ||
|
|
||
| useEffect(() => { | ||
| const handleKeyDown = (e: KeyboardEvent) => { | ||
| if (e.key === 'Escape') { | ||
| onClose(); | ||
| } else if (e.key === 'ArrowRight') { | ||
| goToNext(); | ||
| } else if (e.key === 'ArrowLeft') { | ||
| goToPrev(); | ||
| } | ||
| }; | ||
|
|
||
| if (isOpen) { | ||
| document.addEventListener('keydown', handleKeyDown); | ||
| document.body.style.overflow = 'hidden'; | ||
| return () => { | ||
| document.removeEventListener('keydown', handleKeyDown); | ||
| document.body.style.overflow = 'unset'; | ||
| }; | ||
| } | ||
| }, [isOpen, currentIndex]); | ||
|
|
||
| if (!isOpen) return null; | ||
|
|
||
| const goToNext = () => setCurrentIndex((currentIndex + 1) % images.length); | ||
| const goToPrev = () => | ||
| setCurrentIndex((currentIndex - 1 + images.length) % images.length); | ||
|
|
||
| const handleClose = (e: React.MouseEvent) => { | ||
| e.stopPropagation(); | ||
| onClose(); | ||
| }; | ||
|
|
||
| return ( | ||
| <AnimatePresence> | ||
| {isOpen && ( | ||
| <motion.div | ||
| initial={{ opacity: 0 }} | ||
| animate={{ opacity: 1 }} | ||
| exit={{ opacity: 0 }} | ||
| transition={{ duration: 0.2 }} | ||
| className="fixed inset-0 z-50 bg-black/95 flex items-center justify-center" | ||
| onClick={onClose} | ||
| role="dialog" | ||
| aria-modal="true" | ||
| aria-label="Image gallery" | ||
| > | ||
| <button | ||
| onClick={handleClose} | ||
| className="absolute top-4 right-4 text-white/80 hover:text-white text-3xl w-10 h-10 flex items-center justify-center rounded-full hover:bg-white/10 transition-colors z-10" | ||
| aria-label="Close gallery" | ||
| > | ||
| Γ | ||
| </button> | ||
|
|
||
| <div className="relative w-full h-full flex items-center justify-center p-4 md:p-8"> | ||
| <AnimatePresence mode="wait" custom={currentIndex}> | ||
| <motion.img | ||
| key={currentIndex} | ||
| src={images[currentIndex].src} | ||
| alt={images[currentIndex].alt || ''} | ||
| initial={{ opacity: 0, scale: 0.9 }} | ||
| animate={{ opacity: 1, scale: 1 }} | ||
| exit={{ opacity: 0, scale: 0.9 }} | ||
| transition={{ duration: 0.3, ease: 'easeOut' }} | ||
| className="max-w-full max-h-full w-auto h-auto object-contain rounded-lg" | ||
| onClick={(e) => e.stopPropagation()} | ||
| style={{ maxWidth: '90vw', maxHeight: '90vh' }} | ||
| /> | ||
| </AnimatePresence> | ||
|
|
||
| {images.length > 1 && ( | ||
| <> | ||
| <button | ||
| onClick={(e) => { | ||
| e.stopPropagation(); | ||
| goToPrev(); | ||
| }} | ||
| className="absolute left-4 text-white/80 hover:text-white text-5xl w-12 h-12 flex items-center justify-center rounded-full hover:bg-white/10 transition-colors" | ||
| aria-label="Previous image" | ||
| > | ||
| βΉ | ||
| </button> | ||
| <button | ||
| onClick={(e) => { | ||
| e.stopPropagation(); | ||
| goToNext(); | ||
| }} | ||
| className="absolute right-4 text-white/80 hover:text-white text-5xl w-12 h-12 flex items-center justify-center rounded-full hover:bg-white/10 transition-colors" | ||
| aria-label="Next image" | ||
| > | ||
| βΊ | ||
| </button> | ||
| <div className="absolute bottom-6 flex gap-2"> | ||
| {images.map((_, idx) => ( | ||
| <button | ||
| key={images[idx].src} | ||
| onClick={(e) => { | ||
| e.stopPropagation(); | ||
| setCurrentIndex(idx); | ||
| }} | ||
| className={`w-2 h-2 rounded-full transition-all ${ | ||
| idx === currentIndex | ||
| ? 'bg-white w-6' | ||
| : 'bg-white/50 hover:bg-white/70' | ||
| }`} | ||
| aria-label={`Go to image ${idx + 1}`} | ||
| /> | ||
| ))} | ||
| </div> | ||
| </> | ||
| )} | ||
| </div> | ||
| </motion.div> | ||
| )} | ||
| </AnimatePresence> | ||
| ); | ||
| } |
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.