Landmarks.tsx 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import React, {useState} from 'react';
  2. import Pagination from "@/components/common/Pagination";
  3. import {getPaginatedList} from "@/utils/pagination";
  4. import {ProjectModal} from "@/components/ProjectModal";
  5. import projectList from "@/data/project";
  6. import type {MajorProject} from "@/data/project";
  7. const ITEMS_PER_PAGE = 12;
  8. const Landmarks = () => {
  9. const [isOpen, setIsOpen] = useState(false);
  10. const [currentPage, setCurrentPage] = useState<number>(1);
  11. const [selectedItem, setSelectedItem] = useState<MajorProject | null>(null); // 클릭된 카드
  12. const paginatedList = getPaginatedList<MajorProject>(projectList, currentPage, ITEMS_PER_PAGE);
  13. return (
  14. <div>
  15. <div className="relative max-w-7xl mx-auto grid grid-cols-3 gap-x-8 gap-y-10 mt-10">
  16. {paginatedList.map((project, index) => (
  17. <div
  18. key={index}
  19. className="relative shadow-lg group cursor-pointer"
  20. onClick={() => {
  21. setSelectedItem(project);
  22. setIsOpen(true);
  23. }}
  24. >
  25. <div className="absolute inset-0 bg-gradient-to-b from-transparent to-black/60"/>
  26. <img
  27. src={project.imageUrl}
  28. alt={project.title}
  29. className="w-full aspect-[4/3] object-cover"
  30. />
  31. <div className="">
  32. <h3
  33. className='absolute z-10 left-6 top-[77%] group-hover:top-[30%] transition-all duration-500 ease-in-out text-lg text-white font-semibold'>
  34. {project.title}
  35. </h3>
  36. <div className="absolute z-10 left-6 top-[85%] text-xs text-white leading-7">MORE +</div>
  37. </div>
  38. <div
  39. className="absolute inset-0 bg-gradient-to-t from-black/80 opacity-0 group-hover:opacity-100 transition-opacity duration-300 ease-in-out flex flex-col justify-center">
  40. {project.description && (
  41. <div
  42. className="absolute left-6 right-6 top-[60%] group-hover:top-[40%] transition-all duration-500 ease-in-out">
  43. <p className="text-sm text-white leading-8 whitespace-pre-line">
  44. 발주처 : {project.client}
  45. </p>
  46. <p className="text-sm text-white leading-8 whitespace-pre-line">
  47. {project.description}
  48. </p>
  49. <p className="text-sm text-white leading-8 whitespace-pre-line">
  50. 계약금액 : {project.contractAmount}
  51. </p>
  52. </div>
  53. )}
  54. </div>
  55. </div>
  56. ))}
  57. </div>
  58. <Pagination
  59. currentPage={currentPage}
  60. totalItems={projectList.length}
  61. itemsPerPage={ITEMS_PER_PAGE}
  62. onPageChange={setCurrentPage}
  63. />
  64. <ProjectModal
  65. isOpen={isOpen}
  66. onClose={() => setIsOpen(false)}
  67. item={selectedItem}
  68. />
  69. </div>
  70. );
  71. };
  72. export default Landmarks;