mirror of
https://github.com/mudabbir-ahmad/Portfolio_V1.git
synced 2026-12-06 19:53:09 +00:00
- New design language: self-hosted fonts, numbered sections, hero card, nav pill with scroll-spy - Two-pane project pop-up with WebP screenshots; gold ring on the final-year project - Content moved to src/data JSON and updated from the new CV - Staggered card entrances and stat count-up; simpler dot cursor - Capture script converts manual screenshots to WebP Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
46 lines
1.4 KiB
React
46 lines
1.4 KiB
React
import { useEffect, useRef, useState } from "react";
|
|
import { animate, useInView, useReducedMotion } from "motion/react";
|
|
import { stats } from "../content.js";
|
|
|
|
// Counts the leading number up from zero the first time it scrolls into view.
|
|
// Anything after the digits ("+", "k+") is kept as a suffix.
|
|
function CountUp({ value }) {
|
|
const reduced = useReducedMotion();
|
|
const ref = useRef(null);
|
|
const inView = useInView(ref, { once: true, margin: "-40px" });
|
|
const match = /^(\d+)(.*)$/.exec(value);
|
|
const target = match ? Number(match[1]) : null;
|
|
const [n, setN] = useState(reduced || target === null ? target : 0);
|
|
|
|
useEffect(() => {
|
|
if (reduced || target === null || !inView) return;
|
|
const controls = animate(0, target, {
|
|
duration: 1.1,
|
|
ease: [0.22, 1, 0.36, 1],
|
|
onUpdate: (v) => setN(Math.round(v)),
|
|
});
|
|
return () => controls.stop();
|
|
}, [inView, reduced, target]);
|
|
|
|
return (
|
|
<span className="stat-value" ref={ref}>
|
|
{target === null ? value : `${n}${match[2]}`}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
export default function Stats() {
|
|
return (
|
|
<section className="stats" aria-label="Portfolio statistics">
|
|
<div className="container stats-grid">
|
|
{stats.map((s) => (
|
|
<div key={s.label} className="stat">
|
|
<CountUp value={s.value} />
|
|
<span className="stat-label">{s.label}</span>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|