'use client'; import { useEffect, useState } from 'react'; import { useReducedMotion } from '@/hooks/use-reduced-motion'; interface ScrollProgressProps { /** Height of the progress bar in px */ height?: number; /** Color of the progress bar (CSS variable or color) */ color?: string; /** Position: top or bottom */ position?: 'top' | 'bottom'; className?: string; } export function ScrollProgress({ height = 2, color = 'var(--color-brand)', position = 'top', className = '', }: ScrollProgressProps) { const [progress, setProgress] = useState(0); const shouldReduceMotion = useReducedMotion(); useEffect(() => { const updateProgress = () => { const scrollTop = window.scrollY; const docHeight = document.documentElement.scrollHeight - window.innerHeight; const value = docHeight > 0 ? (scrollTop / docHeight) * 100 : 0; setProgress(value); }; updateProgress(); window.addEventListener('scroll', updateProgress, { passive: true }); window.addEventListener('resize', updateProgress); return () => { window.removeEventListener('scroll', updateProgress); window.removeEventListener('resize', updateProgress); }; }, []); return (