added animation for home page

This commit is contained in:
dong.nguyen committed 2026-10-06 19:29:13 +07:00
1 parent 531c70e13a
commit 1800fa7ceb
15 files changed
+1289 -249

No files matched your search

+89 -46
View File
@@ -1,60 +1,103 @@
import { Badge } from '@/components/ui/Badge'
import { projects } from '@/data/projects'
import { motion } from "motion/react"
import { Badge } from "@/components/ui/Badge"
import { projects } from "@/data/projects"
import { InView } from "@/components/ui/InView"
const categoryLabels: Record<string, string> = {
'software-engineering': 'Software Engineering',
logistics: 'Logistics',
'ai-ml': 'AI / ML',
'computer-vision': 'Computer Vision',
architecture: 'Architecture',
experiment: 'Experiment',
"software-engineering": "Software Engineering",
logistics: "Logistics",
"ai-ml": "AI / ML",
"computer-vision": "Computer Vision",
architecture: "Architecture",
experiment: "Experiment",
}
export function Projects() {
const featured = projects.filter((p) => p.featured).slice(0, 4)
return (
<section className="section container-wide" aria-labelledby="projects-heading">
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', marginBottom: '48px' }}>
<h2 id="projects-heading">Featured Projects</h2>
<a href="/projects" style={{ fontSize: '14px', fontWeight: 500, color: 'var(--accent)' }}>
View All →
</a>
</div>
<div className="projects-grid">
{featured.map((project) => (
<a
key={project.id}
href={`/projects/${project.id}`}
className="project-card"
<InView>
<motion.section
className="section container-wide"
aria-labelledby="projects-heading"
initial="hidden"
whileInView="visible"
viewport={{ once: true, amount: 0.1 }}
variants={{
hidden: { opacity: 0 },
visible: {
opacity: 1,
transition: { staggerChildren: 0.1 },
},
}}
>
<motion.div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "baseline",
marginBottom: "48px",
}}
variants={{
hidden: { opacity: 0, y: 30 },
visible: { opacity: 1, y: 0, transition: { duration: 0.5 } },
}}
>
<h2 id="projects-heading">Featured Projects</h2>
<motion.a
href="/projects"
style={{ fontSize: "14px", fontWeight: 500, color: "var(--accent)" }}
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
>
<div className="project-card-header">
<h3>{project.title}</h3>
<Badge variant="outline">
{categoryLabels[project.category] || project.category}
</Badge>
</div>
<p className="project-card-summary">{project.summary}</p>
<div className="project-card-techs">
{project.technologies.slice(0, 4).map((tech) => (
<span key={tech} className="tag">
{tech}
</span>
))}
</div>
{project.metrics && project.metrics.length > 0 && (
<div className="project-card-metrics">
{project.metrics.map((m) => (
<span key={m} className="achievement-metric">
{m}
View All →
</motion.a>
</motion.div>
<div className="projects-grid">
{featured.map((project, i) => (
<motion.a
key={project.id}
href={`/projects/${project.id}`}
className="project-card"
variants={{
hidden: { opacity: 0, y: 30 },
visible: {
opacity: 1,
y: 0,
transition: { duration: 0.5, delay: i * 0.1 },
},
}}
whileHover={{ scale: 1.02, y: -4 }}
whileTap={{ scale: 0.98 }}
>
<div className="project-card-header">
<h3>{project.title}</h3>
<Badge variant="outline">
{categoryLabels[project.category] || project.category}
</Badge>
</div>
<p className="project-card-summary">{project.summary}</p>
<div className="project-card-techs">
{project.technologies.slice(0, 4).map((tech) => (
<span key={tech} className="tag">
{tech}
</span>
))}
</div>
)}
<span className="project-card-cta">View Details →</span>
</a>
))}
</div>
</section>
{project.metrics && project.metrics.length > 0 && (
<div className="project-card-metrics">
{project.metrics.map((m) => (
<span key={m} className="achievement-metric">
{m}
</span>
))}
</div>
)}
<span className="project-card-cta">View Details →</span>
</motion.a>
))}
</div>
</motion.section>
</InView>
)
}