2026-02-09 23:19:18 +00:00
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
|
import { useLocation } from 'react-router-dom';
|
|
|
|
|
import { motion, AnimatePresence } from 'framer-motion';
|
|
|
|
|
|
|
|
|
|
export function NavigationProgress() {
|
|
|
|
|
const location = useLocation();
|
|
|
|
|
const [isNavigating, setIsNavigating] = useState(false);
|
|
|
|
|
const [progress, setProgress] = useState(0);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setIsNavigating(true);
|
|
|
|
|
setProgress(0);
|
|
|
|
|
|
|
|
|
|
// Simulate progress
|
|
|
|
|
const timer1 = setTimeout(() => setProgress(30), 50);
|
|
|
|
|
const timer2 = setTimeout(() => setProgress(60), 150);
|
|
|
|
|
const timer3 = setTimeout(() => setProgress(80), 300);
|
|
|
|
|
const timer4 = setTimeout(() => {
|
|
|
|
|
setProgress(100);
|
|
|
|
|
setTimeout(() => setIsNavigating(false), 200);
|
|
|
|
|
}, 500);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
clearTimeout(timer1);
|
|
|
|
|
clearTimeout(timer2);
|
|
|
|
|
clearTimeout(timer3);
|
|
|
|
|
clearTimeout(timer4);
|
|
|
|
|
};
|
|
|
|
|
}, [location.pathname]);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<AnimatePresence>
|
|
|
|
|
{isNavigating && (
|
|
|
|
|
<motion.div
|
2026-02-12 00:54:47 +00:00
|
|
|
className="fixed top-0 left-0 right-0 z-[400] h-0.5"
|
2026-02-09 23:19:18 +00:00
|
|
|
initial={{ opacity: 0 }}
|
|
|
|
|
animate={{ opacity: 1 }}
|
|
|
|
|
exit={{ opacity: 0 }}
|
|
|
|
|
transition={{ duration: 0.15 }}
|
|
|
|
|
>
|
|
|
|
|
<motion.div
|
2026-02-12 01:09:29 +00:00
|
|
|
className="h-full bg-primary shadow-sm"
|
2026-02-09 23:19:18 +00:00
|
|
|
initial={{ width: '0%' }}
|
|
|
|
|
animate={{ width: `${progress}%` }}
|
|
|
|
|
transition={{ duration: 0.3, ease: 'easeOut' }}
|
|
|
|
|
/>
|
|
|
|
|
</motion.div>
|
|
|
|
|
)}
|
|
|
|
|
</AnimatePresence>
|
|
|
|
|
);
|
|
|
|
|
}
|