feat(SW-96): add navigation controls to gallery dialog
This commit is contained in:
@@ -46,15 +46,20 @@
|
||||
}
|
||||
|
||||
.imageCaption {
|
||||
background-color: #f0f0f0;
|
||||
background-color: var(--Base-Surface-Subtle-Normal);
|
||||
padding: var(--Spacing-x-half) var(--Spacing-x1);
|
||||
border-radius: 4px;
|
||||
border-radius: var(--Corner-radius-Small);
|
||||
}
|
||||
|
||||
.mainImageWrapper {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
margin-bottom: var(--Spacing-x2);
|
||||
}
|
||||
|
||||
.mainImageContainer {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
margin-bottom: var(--Spacing-x2);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
will-change: transform;
|
||||
overflow: hidden;
|
||||
}
|
||||
@@ -137,6 +142,7 @@
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
display: flex;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.navigationButton:hover {
|
||||
@@ -144,7 +150,7 @@
|
||||
}
|
||||
|
||||
.prevButton {
|
||||
left: 0;
|
||||
left: var(--Spacing-x2);
|
||||
}
|
||||
|
||||
.leftTransformIcon {
|
||||
@@ -152,7 +158,7 @@
|
||||
}
|
||||
|
||||
.nextButton {
|
||||
right: 0;
|
||||
right: var(--Spacing-x2);
|
||||
}
|
||||
|
||||
.portraitImage {
|
||||
|
||||
@@ -140,6 +140,16 @@ function Gallery({
|
||||
return thumbs
|
||||
}
|
||||
|
||||
const handleNext = () => {
|
||||
const nextIndex = (mainImageIndex + 1) % images.length
|
||||
onSelectImage(images[nextIndex])
|
||||
}
|
||||
|
||||
const handlePrev = () => {
|
||||
const prevIndex = (mainImageIndex - 1 + images.length) % images.length
|
||||
onSelectImage(images[prevIndex])
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={styles.galleryContainer}>
|
||||
<Button
|
||||
@@ -156,24 +166,41 @@ function Gallery({
|
||||
<Caption color="textMediumContrast">{mainImage.alt}</Caption>
|
||||
</div>
|
||||
</div>
|
||||
<AnimatePresence initial={false} mode="wait">
|
||||
<motion.div
|
||||
key={mainImage.url}
|
||||
className={styles.mainImageContainer}
|
||||
initial={{ opacity: 0, x: 300 }}
|
||||
animate={{ opacity: 1, x: 0 }}
|
||||
exit={{ opacity: 0, x: -300 }}
|
||||
transition={{ duration: 0.3 }}
|
||||
<div className={styles.mainImageWrapper}>
|
||||
<AnimatePresence initial={false} mode="wait">
|
||||
<motion.div
|
||||
key={mainImage.url}
|
||||
className={styles.mainImageContainer}
|
||||
initial={{ opacity: 0, x: 300 }}
|
||||
animate={{ opacity: 1, x: 0 }}
|
||||
exit={{ opacity: 0, x: -300 }}
|
||||
transition={{ duration: 0.3 }}
|
||||
>
|
||||
<Image
|
||||
src={mainImage.url}
|
||||
alt={mainImage.alt}
|
||||
layout="fill"
|
||||
objectFit="cover"
|
||||
onClick={onImageClick}
|
||||
/>
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
<motion.button
|
||||
className={`${styles.navigationButton} ${styles.prevButton}`}
|
||||
onClick={handlePrev}
|
||||
>
|
||||
<Image
|
||||
src={mainImage.url}
|
||||
alt={mainImage.alt}
|
||||
layout="fill"
|
||||
objectFit="cover"
|
||||
onClick={onImageClick}
|
||||
<ArrowRightIcon
|
||||
color="burgundy"
|
||||
className={styles.leftTransformIcon}
|
||||
/>
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
</motion.button>
|
||||
<motion.button
|
||||
className={`${styles.navigationButton} ${styles.nextButton}`}
|
||||
onClick={handleNext}
|
||||
>
|
||||
<ArrowRightIcon color="burgundy" />
|
||||
</motion.button>
|
||||
</div>
|
||||
<div className={styles.thumbnailGrid}>
|
||||
<AnimatePresence initial={false}>
|
||||
{getThumbImages().map((image, index) => (
|
||||
|
||||
Reference in New Issue
Block a user