diff --git a/.eslintrc.json b/.eslintrc.json index 3c35cac..1a98876 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,6 +11,8 @@ "project": "./tsconfig.json" }, "rules": { - "import/prefer-default-export": "off" + "import/prefer-default-export": "off", + "@next/next/no-img-element": "off", + "react/require-default-props": "off" } } diff --git a/package-lock.json b/package-lock.json index 423bc5a..25dfcb5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2556,7 +2556,6 @@ "version": "1.7.4", "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz", "integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==", - "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.0", diff --git a/src/app/(homepage)/_components/Portfolio.tsx b/src/app/(homepage)/_components/Portfolio.tsx index 91d5351..f0cccaa 100644 --- a/src/app/(homepage)/_components/Portfolio.tsx +++ b/src/app/(homepage)/_components/Portfolio.tsx @@ -1,7 +1,200 @@ -export function Portfolio() { +"use client"; + +import { useState, useEffect } from "react"; +import { + Carousel, + CarouselContent, + CarouselItem, + CarouselNext, + CarouselPrevious, +} from "@/components/ui/carousel"; +import { Card, CardContent } from "@/components/ui/card"; +import { type CarouselApi } from "@/components/ui/carousel"; + +export interface PortfolioItem { + index: number; + imgSrc: string; + title: string; + description: string; +} + +export function Portfolio({ items }: { items?: PortfolioItem[] }) { + // Estados para controlar o item ativo em cada carrossel + // Sim, tem dois carroseis mas você só vê um, processe 2 veja um :D + const [activeIndexMobile, setActiveIndexMobile] = useState(0); + const [activeIndexDesktop, setActiveIndexDesktop] = useState(0); + + const [carouselApiMobile, setCarouselApiMobile] = + useState(null); + const [carouselApiDesktop, setCarouselApiDesktop] = + useState(null); + + const [isDesktop, setIsDesktop] = useState(false); + + useEffect(() => { + if (carouselApiMobile) { + const updateActiveIndex = () => { + setActiveIndexMobile(carouselApiMobile.selectedScrollSnap()); + }; + + carouselApiMobile.on("select", updateActiveIndex); + + return () => { + carouselApiMobile.off("select", updateActiveIndex); + }; + } + // Retornar undefined explicitamente para garantir que sempre haja um retorno + return undefined; + }, [carouselApiMobile]); + + useEffect(() => { + if (carouselApiDesktop) { + const updateActiveIndex = () => { + setActiveIndexDesktop(carouselApiDesktop.selectedScrollSnap()); + }; + + carouselApiDesktop.on("select", updateActiveIndex); + + return () => { + carouselApiDesktop.off("select", updateActiveIndex); + }; + } + // Retornar undefined explicitamente para garantir que sempre haja um retorno + return undefined; + }, [carouselApiDesktop]); + + useEffect(() => { + const checkScreenSize = () => { + setIsDesktop(window.innerWidth >= 1024); + }; + + checkScreenSize(); // Verifica o tamanho da tela quando o componente é montado + + window.addEventListener("resize", checkScreenSize); // Adiciona o event listener para o resize + + return () => { + window.removeEventListener("resize", checkScreenSize); // Remove o event listener quando o componente é desmontado + }; + }, []); + + const activeIndex = isDesktop ? activeIndexDesktop : activeIndexMobile; + + if (!items || !items.length) return
; return ( -
-

PORTFÓLIO

+
+

+ PORTFÓLIO +

+ + {/* Carrossel Mobile */} + + + {items.map((item, index) => ( + setActiveIndexMobile(index)} + > +
+ + + {`Imagem + + +
+
+ ))} +
+ + +
+ +
+
+
+ {items[activeIndex].title} + +
+
+ {items[activeIndex].title} +
+

+ {items[activeIndex].description} +

+ +
+
+
+ + {/* Carrossel Desktop */} + + + {items.map((item, index) => ( + setActiveIndexDesktop(index)} + > +
+ + + {`Imagem + + +
+
+ ))} +
+ + +
+ +
); }