From b8e2e4a1e84c19442a34bb24ff1da1d06deb1928 Mon Sep 17 00:00:00 2001 From: emanuelpps Date: Sat, 9 Mar 2024 02:28:18 -0300 Subject: [PATCH] new photo selected feature on gallery --- app/works/[projectName]/page.jsx | 40 ++++++++++++++++++++++++++++++-- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/app/works/[projectName]/page.jsx b/app/works/[projectName]/page.jsx index b72bf13..14f854f 100644 --- a/app/works/[projectName]/page.jsx +++ b/app/works/[projectName]/page.jsx @@ -10,11 +10,14 @@ import "ldrs/tailChase"; import Link from "next/link"; import loader from "@/components/loader/loader"; import { AnimatePresence, motion, useInView } from "framer-motion"; +import { SlClose } from "react-icons/sl"; function ProjectName({ params }) { const [dataProjects, setDataProjects] = useState([]); const [projectPage, setProjectPage] = useState(null); const [isLoading, setLoading] = useState(true); + const [isViewing, setIsViewing] = useState(false); + const [selectedPhoto, setSelectedPhoto] = useState({}); const ref = useRef(null); const isInView = useInView(ref); @@ -34,9 +37,15 @@ function ProjectName({ params }) { setLoading(false); }; + const handleImageSelected = (photo) => { + setSelectedPhoto(photo); + console.log("photo", photo); + setIsViewing(true); + console.log("isViewing", isViewing); + }; return ( -
+
{projectPage ? ( <>
@@ -295,6 +304,10 @@ function ProjectName({ params }) { ".png" ) ? ( + image.classList.remove("opacity-0") + } + onLoadStart={loader} loader={loader} src={projectPage.infoProject[0].images[0].highlight} alt={projectPage.name} @@ -339,15 +352,38 @@ function ProjectName({ params }) { id="gallery-container" className="grid grid-cols-1 md:grid-cols-2 gap-4" > + {isViewing ? ( +
+
{ + setIsViewing(false), setSelectedPhoto(""); + }} + > +
+ +
+
+ +
+ ) : ( + "" + )} {Object.entries( projectPage.infoProject[0].images[0].gallery ).map(([key, image], index) => (
handleImageSelected(image)} loader={loader} width={500} height={100} - className="h-auto w-full object-cover rounded-lg" + className="h-auto w-full object-cover rounded-lg cursor-pointer" src={image} alt={key} /> diff --git a/package-lock.json b/package-lock.json index f86ef50..e7ec9c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "portfolio-vercel", - "version": "1.0.2", + "version": "1.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "portfolio-vercel", - "version": "1.0.2", + "version": "1.1.2", "dependencies": { "@emailjs/browser": "^3.12.1", "framer-motion": "^11.0.3", diff --git a/package.json b/package.json index 1431649..701fc73 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "portfolio-vercel", - "version": "1.0.2", + "version": "1.1.2", "private": true, "scripts": { "dev": "next dev",