|
1 | | -import { Image } from "./Image"; |
2 | | - |
3 | | -interface ProjectsProps { |
4 | | - data: { |
5 | | - title: string; |
6 | | - largeImage: string; |
7 | | - smallImage: string; |
8 | | - }[]; |
| 1 | +// import { AnimatePresence, motion } from "framer-motion"; |
| 2 | +// import { Image } from "./Image"; |
| 3 | +import { useState } from "react"; |
| 4 | +import { motion, AnimatePresence } from "framer-motion"; |
| 5 | +import "../App.css"; |
| 6 | +// interface ProjectsProps { |
| 7 | +// data: { |
| 8 | +// title: string; |
| 9 | +// largeImage: string; |
| 10 | +// smallImage: string; |
| 11 | +// }[]; |
| 12 | +// } |
| 13 | + |
| 14 | +interface Project { |
| 15 | + id: number; |
| 16 | + title: string; |
| 17 | + staticImg: string; |
| 18 | + animatedImg: string; |
| 19 | + tags: string[]; |
| 20 | + link: string; |
9 | 21 | } |
10 | 22 |
|
11 | | -const Projects = (props: ProjectsProps) => { |
| 23 | +const projects: Project[] = [ |
| 24 | + { |
| 25 | + id: 1, |
| 26 | + title: "Random Enemy Generator", |
| 27 | + staticImg: "/imgs/enemyGenerator.png", |
| 28 | + animatedImg: "/imgs/animated1.gif", |
| 29 | + tags: ["HTML5", "CSS3", "JavaScript"], |
| 30 | + link: "https://jebarpg.github.io/enemyGenerator", |
| 31 | + }, |
| 32 | + // { |
| 33 | + // id: 2, |
| 34 | + // title: "Node API Service", |
| 35 | + // staticImg: "/images/static2.jpg", |
| 36 | + // animatedImg: "/images/animated2.gif", |
| 37 | + // tags: ["Node.js"], |
| 38 | + // }, |
| 39 | + // { |
| 40 | + // id: 3, |
| 41 | + // title: "Phaser Game", |
| 42 | + // staticImg: "/images/static3.jpg", |
| 43 | + // animatedImg: "/images/animated3.gif", |
| 44 | + // tags: ["JavaScript"], |
| 45 | + // }, |
| 46 | + // { |
| 47 | + // id: 4, |
| 48 | + // title: "Fullstack App", |
| 49 | + // staticImg: "/images/static4.jpg", |
| 50 | + // animatedImg: "/images/animated4.gif", |
| 51 | + // tags: ["Node.js"], |
| 52 | + // }, |
| 53 | + |
| 54 | + // { |
| 55 | + // id: 5, |
| 56 | + // title: "Fullstack App", |
| 57 | + // staticImg: "/imgs/project1.jpg", |
| 58 | + // animatedImg: "/imgs/animated1.gif", |
| 59 | + // tags: ["Node.js"], |
| 60 | + // }, |
| 61 | +]; |
| 62 | + |
| 63 | +// Extract all unique tags from projects |
| 64 | +const allTags = Array.from( |
| 65 | + new Set(projects.flatMap((project) => project.tags)) |
| 66 | +).sort(); |
| 67 | + |
| 68 | +const Projects = () => { |
| 69 | + const [activeTag, setActiveTag] = useState<string>("All"); |
| 70 | + |
| 71 | + const filteredProjects = |
| 72 | + activeTag === "All" |
| 73 | + ? projects |
| 74 | + : projects.filter((p) => p.tags.includes(activeTag)); |
| 75 | + |
12 | 76 | return ( |
13 | 77 | <div id="projects" className="text-center"> |
14 | | - <div className="container"> |
15 | | - <div className="section-title"> |
16 | | - <div style={{ padding: "40px" }}></div> |
17 | | - <h2>Projects</h2> |
18 | | - <p>Here are some of the projects I have worked on.</p> |
| 78 | + <div className="gallery-container"> |
| 79 | + <div style={{ padding: "25px" }}></div> |
| 80 | + <h1 className="gallery-title">My Projects</h1> |
| 81 | + |
| 82 | + <div className="filter-bar"> |
| 83 | + <button |
| 84 | + className={activeTag === "All" ? "active" : ""} |
| 85 | + onClick={() => setActiveTag("All")} |
| 86 | + > |
| 87 | + All |
| 88 | + </button> |
| 89 | + {allTags.map((tag) => ( |
| 90 | + <button |
| 91 | + key={tag} |
| 92 | + className={activeTag === tag ? "active" : ""} |
| 93 | + onClick={() => setActiveTag(tag)} |
| 94 | + > |
| 95 | + {tag} |
| 96 | + </button> |
| 97 | + ))} |
19 | 98 | </div> |
20 | | - <div className="row"> |
21 | | - <div className="portfolio-items"> |
22 | | - {props.data |
23 | | - ? props.data.map((d, i) => ( |
24 | | - <div |
25 | | - key={`${d.title}-${i}`} |
26 | | - className="col-sm-6 col-md-4 col-lg-4" |
27 | | - > |
28 | | - <Image |
29 | | - title={d.title} |
30 | | - largeImage={d.largeImage} |
31 | | - smallImage={d.smallImage} |
32 | | - /> |
33 | | - </div> |
34 | | - )) |
35 | | - : "Loading..."} |
36 | | - </div> |
| 99 | + |
| 100 | + <div className="gallery-grid"> |
| 101 | + <AnimatePresence> |
| 102 | + {filteredProjects.map((project) => ( |
| 103 | + <motion.div |
| 104 | + key={project.id} |
| 105 | + layout |
| 106 | + initial={{ opacity: 0, scale: 0.95 }} |
| 107 | + animate={{ opacity: 1, scale: 1 }} |
| 108 | + exit={{ opacity: 0, scale: 0.95 }} |
| 109 | + transition={{ duration: 0.3 }} |
| 110 | + className="gallery-item" |
| 111 | + > |
| 112 | + <img |
| 113 | + className="static" |
| 114 | + src={project.staticImg} |
| 115 | + alt={project.title} |
| 116 | + loading="lazy" |
| 117 | + /> |
| 118 | + <a |
| 119 | + href={project.link} |
| 120 | + target="_blank" |
| 121 | + rel="noopener noreferrer" |
| 122 | + > |
| 123 | + <img |
| 124 | + className="animated" |
| 125 | + src={project.animatedImg} |
| 126 | + alt={`${project.title} animation`} |
| 127 | + loading="lazy" |
| 128 | + /> |
| 129 | + </a> |
| 130 | + <div className="tags"> |
| 131 | + {project.tags.map((tag, index) => ( |
| 132 | + <span key={index}>{tag}</span> |
| 133 | + ))} |
| 134 | + </div> |
| 135 | + </motion.div> |
| 136 | + ))} |
| 137 | + </AnimatePresence> |
37 | 138 | </div> |
38 | 139 | </div> |
39 | 140 | </div> |
|
0 commit comments