|
1 | 1 | "use client"; |
2 | | -import { motion } from "framer-motion"; |
| 2 | +import { useState } from "react"; |
| 3 | +import { motion, AnimatePresence } from "framer-motion"; |
| 4 | +import { FiPlus } from "react-icons/fi"; |
3 | 5 | import { experience } from "@/data/portfolio"; |
4 | 6 | import { getIcon } from "./icons"; |
5 | | -import Tilt from "./Tilt"; |
| 7 | + |
| 8 | +function Entry({ e, i, open, onToggle }) { |
| 9 | + const Icon = getIcon(e.icon); |
| 10 | + return ( |
| 11 | + <div className="relative pl-10 sm:pl-14"> |
| 12 | + {/* timeline dot */} |
| 13 | + <span className="absolute left-0 sm:left-2 top-2 w-4 h-4 rounded-full bg-gradient-to-br from-accent to-accent2 ring-4 ring-bg" /> |
| 14 | + |
| 15 | + <motion.div |
| 16 | + initial={{ opacity: 0, y: 20 }} |
| 17 | + whileInView={{ opacity: 1, y: 0 }} |
| 18 | + viewport={{ once: true, margin: "-60px" }} |
| 19 | + transition={{ duration: 0.5, delay: i * 0.08 }} |
| 20 | + > |
| 21 | + <button |
| 22 | + data-hover |
| 23 | + onClick={onToggle} |
| 24 | + aria-expanded={open} |
| 25 | + className="w-full text-left glass rounded-2xl p-6 hover:border-accent/60 transition-colors" |
| 26 | + > |
| 27 | + <div className="flex items-start gap-4"> |
| 28 | + <span className="w-11 h-11 shrink-0 rounded-xl bg-gradient-to-br from-accent to-accent2 flex items-center justify-center text-bg"> |
| 29 | + <Icon size={20} /> |
| 30 | + </span> |
| 31 | + |
| 32 | + <div className="flex-1 min-w-0"> |
| 33 | + <div className="flex items-baseline gap-2 flex-wrap"> |
| 34 | + <h3 className="text-lg font-bold">{e.role}</h3> |
| 35 | + <span className="text-accent2 text-sm">· {e.org}</span> |
| 36 | + <span className="ml-auto text-xs font-mono text-accent shrink-0"> |
| 37 | + {e.period} |
| 38 | + </span> |
| 39 | + </div> |
| 40 | + <p className="text-muted text-sm mt-1">{e.summary}</p> |
| 41 | + |
| 42 | + <AnimatePresence initial={false}> |
| 43 | + {open && ( |
| 44 | + <motion.div |
| 45 | + initial={{ height: 0, opacity: 0 }} |
| 46 | + animate={{ height: "auto", opacity: 1 }} |
| 47 | + exit={{ height: 0, opacity: 0 }} |
| 48 | + transition={{ duration: 0.35, ease: "easeInOut" }} |
| 49 | + className="overflow-hidden" |
| 50 | + > |
| 51 | + <ul className="mt-4 space-y-2"> |
| 52 | + {e.details?.map((d, j) => ( |
| 53 | + <li key={j} className="text-muted text-sm flex gap-2"> |
| 54 | + <span className="text-accent mt-0.5">▹</span> |
| 55 | + {d} |
| 56 | + </li> |
| 57 | + ))} |
| 58 | + </ul> |
| 59 | + {e.tags?.length > 0 && ( |
| 60 | + <div className="mt-4 flex flex-wrap gap-2"> |
| 61 | + {e.tags.map((t) => ( |
| 62 | + <span |
| 63 | + key={t} |
| 64 | + className="text-xs px-2.5 py-1 rounded-md border border-line text-muted" |
| 65 | + > |
| 66 | + {t} |
| 67 | + </span> |
| 68 | + ))} |
| 69 | + </div> |
| 70 | + )} |
| 71 | + </motion.div> |
| 72 | + )} |
| 73 | + </AnimatePresence> |
| 74 | + |
| 75 | + <span className="mt-3 inline-flex items-center gap-1.5 text-xs font-medium text-accent"> |
| 76 | + <motion.span animate={{ rotate: open ? 45 : 0 }}> |
| 77 | + <FiPlus size={14} /> |
| 78 | + </motion.span> |
| 79 | + {open ? "Show less" : "Show details"} |
| 80 | + </span> |
| 81 | + </div> |
| 82 | + </div> |
| 83 | + </button> |
| 84 | + </motion.div> |
| 85 | + </div> |
| 86 | + ); |
| 87 | +} |
6 | 88 |
|
7 | 89 | export default function Experience() { |
| 90 | + // First entry open by default; click to toggle each. |
| 91 | + const [openIndex, setOpenIndex] = useState(0); |
| 92 | + |
8 | 93 | return ( |
9 | 94 | <section id="experience" className="py-24 border-t border-line"> |
10 | 95 | <div className="container"> |
11 | 96 | <h2 className="text-3xl sm:text-4xl font-bold mb-3">Experience</h2> |
12 | | - <p className="text-muted mb-12">Concise, informative — the essentials.</p> |
| 97 | + <p className="text-muted mb-12"> |
| 98 | + Click any role to expand the details. |
| 99 | + </p> |
13 | 100 |
|
14 | | - {/* 3D tilt cards that reveal on scroll */} |
15 | | - <div |
16 | | - className="grid sm:grid-cols-3 gap-6" |
17 | | - style={{ perspective: "1000px" }} |
18 | | - > |
19 | | - {experience.map((e, i) => { |
20 | | - const Icon = getIcon(e.icon); |
21 | | - return ( |
22 | | - <motion.div |
| 101 | + {/* vertical timeline line */} |
| 102 | + <div className="relative"> |
| 103 | + <span className="absolute left-[7px] sm:left-[15px] top-2 bottom-2 w-px bg-line" /> |
| 104 | + <div className="space-y-6"> |
| 105 | + {experience.map((e, i) => ( |
| 106 | + <Entry |
23 | 107 | key={i} |
24 | | - initial={{ opacity: 0, y: 40, rotateX: -8 }} |
25 | | - whileInView={{ opacity: 1, y: 0, rotateX: 0 }} |
26 | | - viewport={{ once: true, margin: "-60px" }} |
27 | | - transition={{ duration: 0.6, delay: i * 0.12 }} |
28 | | - > |
29 | | - <Tilt |
30 | | - data-hover |
31 | | - className="glass rounded-2xl p-6 h-full hover:border-accent/60 transition-colors" |
32 | | - > |
33 | | - <div style={{ transform: "translateZ(40px)" }}> |
34 | | - <span className="w-11 h-11 rounded-xl bg-gradient-to-br from-accent to-accent2 flex items-center justify-center text-bg mb-4"> |
35 | | - <Icon size={20} /> |
36 | | - </span> |
37 | | - <div className="flex items-baseline justify-between gap-2"> |
38 | | - <h3 className="font-semibold">{e.role}</h3> |
39 | | - <span className="text-xs font-mono text-accent shrink-0"> |
40 | | - {e.period} |
41 | | - </span> |
42 | | - </div> |
43 | | - <p className="text-accent2 text-sm mt-0.5">{e.org}</p> |
44 | | - <p className="text-muted text-sm mt-3 leading-relaxed"> |
45 | | - {e.summary} |
46 | | - </p> |
47 | | - </div> |
48 | | - </Tilt> |
49 | | - </motion.div> |
50 | | - ); |
51 | | - })} |
| 108 | + e={e} |
| 109 | + i={i} |
| 110 | + open={openIndex === i} |
| 111 | + onToggle={() => setOpenIndex(openIndex === i ? -1 : i)} |
| 112 | + /> |
| 113 | + ))} |
| 114 | + </div> |
52 | 115 | </div> |
53 | 116 | </div> |
54 | 117 | </section> |
|
0 commit comments