refactor(SW-337): fixes for lightbox

This commit is contained in:
Chuma McPhoy
2024-09-04 10:22:21 +02:00
parent 050b17039f
commit 16370f58b6
4 changed files with 44 additions and 19 deletions

View File

@@ -1,8 +1,8 @@
"use client" "use client"
import { AnimatePresence, motion } from "framer-motion" import { AnimatePresence, motion } from "framer-motion"
import { ChevronRightIcon } from "@/components/Icons"
import ArrowRightIcon from "@/components/Icons/ArrowRight" import ArrowRightIcon from "@/components/Icons/ArrowRight"
import CloseIcon from "@/components/Icons/Close"
import Image from "@/components/Image" import Image from "@/components/Image"
import Button from "@/components/TempDesignSystem/Button" import Button from "@/components/TempDesignSystem/Button"
import Body from "@/components/TempDesignSystem/Text/Body" import Body from "@/components/TempDesignSystem/Text/Body"
@@ -28,12 +28,7 @@ export default function FullView({
className={styles.fullViewCloseButton} className={styles.fullViewCloseButton}
onClick={onClose} onClick={onClose}
> >
<ChevronRightIcon <CloseIcon color="white" width={32} height={32} />
color="white"
width={32}
height={32}
className={styles.leftTransformIcon}
/>
</Button> </Button>
<div className={styles.fullViewHeader}> <div className={styles.fullViewHeader}>
<span className={styles.imagePosition}> <span className={styles.imagePosition}>

View File

@@ -123,7 +123,12 @@ export default function Gallery({
{/* Mobile Gallery */} {/* Mobile Gallery */}
<div className={styles.mobileGallery}> <div className={styles.mobileGallery}>
<Button intent="text" size="small" onClick={onClose}> <Button
intent="text"
size="small"
className={styles.mobileGalleryCloseButton}
onClick={onClose}
>
<ChevronRightIcon <ChevronRightIcon
color="black" color="black"
width={32} width={32}
@@ -137,7 +142,10 @@ export default function Gallery({
<motion.div <motion.div
key={image.url} key={image.url}
className={`${styles.thumbnailContainer} ${index % 3 === 0 ? styles.fullWidthImage : ""}`} className={`${styles.thumbnailContainer} ${index % 3 === 0 ? styles.fullWidthImage : ""}`}
onClick={() => onImageClick()} onClick={() => {
onSelectImage(image)
onImageClick()
}}
initial={{ opacity: 0, y: 20 }} initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }} animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.3, delay: index * 0.05 }} transition={{ duration: 0.3, delay: index * 0.05 }}

View File

@@ -3,7 +3,6 @@
} }
.mobileGallery { .mobileGallery {
margin-top: var(--current-mobile-site-header-height);
height: 100%; height: 100%;
position: relative; position: relative;
display: flex; display: flex;
@@ -11,6 +10,11 @@
gap: var(--Spacing-x2); gap: var(--Spacing-x2);
} }
.mobileGalleryCloseButton {
justify-content: flex-start;
width: fit-content;
}
.mobileGalleryContent { .mobileGalleryContent {
display: block; display: block;
} }
@@ -18,7 +22,7 @@
.fullViewCloseButton { .fullViewCloseButton {
position: absolute; position: absolute;
top: var(--Spacing-x-one-and-half); top: var(--Spacing-x-one-and-half);
left: var(--Spacing-x-half); right: var(--Spacing-x-half);
z-index: 1; z-index: 1;
} }
@@ -112,7 +116,6 @@
} }
.fullViewContainer { .fullViewContainer {
margin-top: var(--current-mobile-site-header-height);
background-color: var(--UI-Text-High-contrast); background-color: var(--UI-Text-High-contrast);
height: 100%; height: 100%;
padding: var(--Spacing-x2); padding: var(--Spacing-x2);
@@ -121,12 +124,12 @@
display: grid; display: grid;
grid-template-rows: auto 1fr auto; grid-template-rows: auto 1fr auto;
place-content: center; place-content: center;
gap: var(--Spacing-x5);
} }
.fullViewHeader { .fullViewHeader {
display: flex; display: flex;
justify-content: center; justify-content: center;
margin-bottom: var(--Spacing-x5);
width: 100%; width: 100%;
} }
@@ -173,9 +176,22 @@
@media (min-width: 1367px) { @media (min-width: 1367px) {
.content { .content {
border-radius: var(--Corner-radius-Large); border-radius: var(--Corner-radius-Large);
position: fixed;
top: 50%;
left: 50%;
overflow: hidden;
}
.galleryContent {
width: 1090px; width: 1090px;
height: 725px; height: 725px;
overflow: hidden; }
.fullViewContent {
width: 100vw;
height: 100vh;
max-width: 1512px;
max-height: 982px;
} }
.galleryContainer { .galleryContainer {
@@ -216,6 +232,8 @@
.fullViewCloseButton { .fullViewCloseButton {
position: fixed; position: fixed;
top: var(--Spacing-x-one-and-half);
right: var(--Spacing-x-half);
} }
.fullWidthImage { .fullWidthImage {
@@ -233,14 +251,16 @@
grid-template-rows: auto 1fr auto; grid-template-rows: auto 1fr auto;
grid-template-columns: 1fr; grid-template-columns: 1fr;
justify-items: center; justify-items: center;
width: 100%;
height: 100%;
} }
.fullViewImageContainer { .fullViewImageContainer {
position: relative; position: relative;
max-width: 1054px; width: 90%;
width: 80%; max-width: 1454px;
height: 85%; height: 100%;
margin-bottom: var(--Spacing-x5); max-height: 700px;
} }
.navigationButton { .navigationButton {

View File

@@ -73,7 +73,9 @@ export default function Lightbox({ images, children }: LightboxProps) {
</Dialog.Overlay> </Dialog.Overlay>
<Dialog.Content asChild> <Dialog.Content asChild>
<motion.div <motion.div
className={styles.content} className={`${styles.content} ${
isFullView ? styles.fullViewContent : styles.galleryContent
}`}
initial={{ opacity: 0, scale: 0.95 }} initial={{ opacity: 0, scale: 0.95 }}
animate={{ opacity: 1, scale: 1, x: "-50%", y: "-50%" }} animate={{ opacity: 1, scale: 1, x: "-50%", y: "-50%" }}
exit={{ opacity: 0, scale: 0.95 }} exit={{ opacity: 0, scale: 0.95 }}