๐ ์ฃผ์ ๊ธฐ๋ฅ
projectData
๋ฅผ ๋ถ๋ฌ์ ์ฌ๋ผ์ด๋ ํํ๋ก ๋ณด์ฌ์ค- ์ข์ฐ ๋ฒํผ์ ์ด์ฉํด ํ๋ก์ ํธ๋ฅผ ๋๊ธธ ์ ์์
- ํด๋น ํ์ด์ง ํ๋จ์ ๊นํ๋ธ, ๋ฒจ๋ก๊ทธ ์ฐ๊ฒฐํ ํธํฐ ๊ตฌํํจ
์ฌ๋ผ์ด๋ ์ํ ๊ด๋ฆฌ ๋ฐ ๋ฒํผ ๋ก์ง
<aside> ๐ฌ
const [currentIndex, setCurrentIndex] = useState(0);
const handlePrev = () => {
setCurrentIndex((prevIndex) =>
prevIndex === 0 ? projectData.length - 1 : prevIndex - 1
);
};
const handleNext = () => {
setCurrentIndex((prevIndex) =>
prevIndex === projectData.length - 1 ? 0 : prevIndex + 1
);
};
</aside>
ํ๋ก์ ํธ ๋ฆฌ์คํธ ์ถ๋ ฅ
<aside> ๐ฌ
<div
className="flex transition-transform duration-500 ease-in-out"
style={{
transform: `translateX(-${currentIndex * 100}%)`,
width: "100%",
}}
>
{projectData.map((project) => (
<div
key={project.id}
className="w-full flex-shrink-0 px-4 flex justify-center"
>
<ProjectItem {...project} />
</div>
))}
</div>
</aside>
์ฌ๋ผ์ด๋ ํ๋จ ์ (์ธ๋์ผ์ดํฐ)
<aside> ๐ฌ
<div className="flex space-x-2 mt-8">
{projectData.map((_, index) => (
<div
key={index}
className={`w-3 h-3 rounded-full transition-all duration-300
${currentIndex === index ? "bg-[#68835E]" : "bg-[#FFEDD2] opacity-50"}`}
></div>
))}
</div>
</aside>