Move ProjectCard to Projects as one entity, Add projectModal feature
This commit is contained in:
parent
c7056841a2
commit
858b659b52
8 changed files with 279 additions and 1 deletions
|
|
@ -0,0 +1,30 @@
|
|||
import React, { useState, useCallback } from "react";
|
||||
import ProjectCard from "./projectCard/ProjectCard";
|
||||
import ProjectModal from "./projectModal/ProjectModal";
|
||||
import styles from "./Projects.module.css";
|
||||
|
||||
function Projects({ title, data }) {
|
||||
const [selectedProject, setSelectedProject] = useState(null);
|
||||
|
||||
const openModal = (project) => {
|
||||
setSelectedProject(project);
|
||||
};
|
||||
|
||||
const closeModal = useCallback(() => {
|
||||
setSelectedProject(null);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<section className={styles.projects}>
|
||||
<h2 className={styles.sectionTitle}>{title}</h2>
|
||||
<div className={styles.projectGrid}>
|
||||
{data.map((project) => (
|
||||
<ProjectCard key={project.id} project={project} onClick={openModal} />
|
||||
))}
|
||||
</div>
|
||||
{selectedProject && <ProjectModal project={selectedProject} onClose={closeModal} />}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export default Projects;
|
||||
Loading…
Add table
Add a link
Reference in a new issue