|
| 1 | +import { useState } from 'react'; |
| 2 | +import { motion } from 'framer-motion'; |
| 3 | +import { ExternalLink, CheckCircle2 } from 'lucide-react'; |
| 4 | +import { projects } from '../data/projectsData'; |
| 5 | +// import { useProgress } from '../contexts/ProgressContext'; |
| 6 | +import { cn } from '../lib/utils'; |
| 7 | +import { Difficulty } from '../types'; |
| 8 | + |
| 9 | +const difficultyColors: Record<Difficulty, string> = { |
| 10 | + Easy: 'bg-green-500/20 text-green-500 border-green-500/30', |
| 11 | + Medium: 'bg-blue-500/20 text-blue-500 border-blue-500/30', |
| 12 | + Hard: 'bg-purple-500/20 text-purple-500 border-purple-500/30', |
| 13 | +}; |
| 14 | + |
| 15 | +export function Projects() { |
| 16 | + const [filter, setFilter] = useState<Difficulty | 'All'>('All'); |
| 17 | + // const { progress, toggleProject } = useProgress(); |
| 18 | + |
| 19 | + const filteredProjects = filter === 'All' |
| 20 | + ? projects |
| 21 | + : projects.filter((p) => p.difficulty === filter); |
| 22 | + |
| 23 | + // const completedCount = projects.filter((p) => |
| 24 | + // progress.completedProjects.includes(p.id) |
| 25 | + // ).length; |
| 26 | + |
| 27 | + return ( |
| 28 | + <div className="min-h-screen py-16"> |
| 29 | + <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> |
| 30 | + <motion.div |
| 31 | + initial={{ opacity: 0, y: 20 }} |
| 32 | + animate={{ opacity: 1, y: 0 }} |
| 33 | + transition={{ duration: 0.6 }} |
| 34 | + className="text-center mb-12" |
| 35 | + > |
| 36 | + <h1 className="text-5xl md:text-6xl font-bold mb-4"> |
| 37 | + Project <span className="text-gradient">Hub</span> |
| 38 | + </h1> |
| 39 | + <p className="text-xl text-[var(--text-secondary)] max-w-3xl mx-auto mb-8"> |
| 40 | + Practice your skills with real-world projects. Each project is designed to |
| 41 | + reinforce what you've learned. |
| 42 | + </p> |
| 43 | + |
| 44 | + <div className="inline-flex items-center gap-3 px-6 py-3 bg-[var(--bg-surface)] rounded-lg border border-white/10"> |
| 45 | + <CheckCircle2 className="w-5 h-5 text-[var(--accent)]" /> |
| 46 | + <span className="font-medium"> |
| 47 | + {/* {completedCount} of {projects.length} Projects Completed */} |
| 48 | + </span> |
| 49 | + </div> |
| 50 | + </motion.div> |
| 51 | + |
| 52 | + <motion.div |
| 53 | + initial={{ opacity: 0, y: 20 }} |
| 54 | + animate={{ opacity: 1, y: 0 }} |
| 55 | + transition={{ duration: 0.6, delay: 0.1 }} |
| 56 | + className="flex flex-wrap justify-center gap-3 mb-12" |
| 57 | + > |
| 58 | + {(['All', 'Easy', 'Medium', 'Hard'] as const).map((level) => ( |
| 59 | + <button |
| 60 | + key={level} |
| 61 | + onClick={() => setFilter(level)} |
| 62 | + className={cn( |
| 63 | + 'px-6 py-3 rounded-lg font-medium transition-all', |
| 64 | + filter === level |
| 65 | + ? 'bg-[var(--accent)] text-black' |
| 66 | + : 'bg-[var(--bg-surface)] border border-white/10 hover:border-white/20' |
| 67 | + )} |
| 68 | + > |
| 69 | + {level} |
| 70 | + </button> |
| 71 | + ))} |
| 72 | + </motion.div> |
| 73 | + |
| 74 | + <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"> |
| 75 | + {filteredProjects.map((project, index) => { |
| 76 | + // const isCompleted = progress.completedProjects.includes(project.id); |
| 77 | + |
| 78 | + return ( |
| 79 | + <motion.div |
| 80 | + key={project.id} |
| 81 | + initial={{ opacity: 0, y: 20 }} |
| 82 | + animate={{ opacity: 1, y: 0 }} |
| 83 | + transition={{ duration: 0.4, delay: index * 0.05 }} |
| 84 | + whileHover={{ y: -8 }} |
| 85 | + // className={cn( |
| 86 | + // 'group relative p-6 rounded-2xl border transition-all', |
| 87 | + // isCompleted |
| 88 | + // // ? 'bg-[var(--accent)]/5 border-[var(--accent)]/30' |
| 89 | + // : 'bg-[var(--bg-surface)] border-white/10 hover:border-white/20' |
| 90 | + // )} |
| 91 | + className='group relative p-6 rounded-2xl border transition-all' |
| 92 | + |
| 93 | + > |
| 94 | + <div className="flex items-start justify-between mb-4"> |
| 95 | + <span |
| 96 | + className={cn( |
| 97 | + 'px-3 py-1 rounded-full text-xs font-semibold border', |
| 98 | + difficultyColors[project.difficulty] |
| 99 | + )} |
| 100 | + > |
| 101 | + {project.difficulty} |
| 102 | + </span> |
| 103 | + |
| 104 | + <button |
| 105 | + onClick={() => toggleProject(project.id)} |
| 106 | + className="transition-transform hover:scale-110" |
| 107 | + // aria-label={`Mark ${project.title} as ${isCompleted ? 'incomplete' : 'complete'}`} |
| 108 | + aria-label={`Mark ${project.title} as 'Comming Soon...'`} |
| 109 | + > |
| 110 | + <CheckCircle2 |
| 111 | + // className={cn( |
| 112 | + // 'w-6 h-6 transition-colors', |
| 113 | + // isCompleted |
| 114 | + // // ? 'text-[var(--accent)] fill-[var(--accent)]' |
| 115 | + // : 'text-[var(--text-secondary)]' |
| 116 | + // )} |
| 117 | + className='w-6 h-6 transition-colors' |
| 118 | + /> |
| 119 | + </button> |
| 120 | + </div> |
| 121 | + |
| 122 | + <h3 className="text-xl font-bold mb-2 group-hover:text-[var(--accent)] transition-colors"> |
| 123 | + {project.title} |
| 124 | + </h3> |
| 125 | + |
| 126 | + <p className="text-[var(--text-secondary)] text-sm mb-4 leading-relaxed"> |
| 127 | + {project.description} |
| 128 | + </p> |
| 129 | + |
| 130 | + <div className="flex flex-wrap gap-2 mb-4"> |
| 131 | + {project.tags.map((tag) => ( |
| 132 | + <span |
| 133 | + key={tag} |
| 134 | + className="px-2 py-1 rounded bg-white/5 text-xs text-[var(--text-secondary)]" |
| 135 | + > |
| 136 | + {tag} |
| 137 | + </span> |
| 138 | + ))} |
| 139 | + </div> |
| 140 | + |
| 141 | + <a |
| 142 | + href={project.repoUrl} |
| 143 | + target="_blank" |
| 144 | + rel="noopener noreferrer" |
| 145 | + className="inline-flex items-center gap-2 text-[var(--accent)] font-medium hover:gap-3 transition-all" |
| 146 | + > |
| 147 | + View Repository |
| 148 | + <ExternalLink className="w-4 h-4" /> |
| 149 | + </a> |
| 150 | + </motion.div> |
| 151 | + ); |
| 152 | + })} |
| 153 | + </div> |
| 154 | + |
| 155 | + {filteredProjects.length === 0 && ( |
| 156 | + <motion.div |
| 157 | + initial={{ opacity: 0 }} |
| 158 | + animate={{ opacity: 1 }} |
| 159 | + className="text-center py-20" |
| 160 | + > |
| 161 | + <p className="text-[var(--text-secondary)] text-lg"> |
| 162 | + No projects found for this difficulty level. |
| 163 | + </p> |
| 164 | + </motion.div> |
| 165 | + )} |
| 166 | + </div> |
| 167 | + </div> |
| 168 | + ); |
| 169 | +} |
0 commit comments