"use client"; import { useEffect, useRef } from "react"; // A thin bar along the top of the window that fills as you read export function ReadingProgress() { const bar = useRef(null); useEffect(() => { const update = () => { const max = document.documentElement.scrollHeight - window.innerHeight; if (bar.current) bar.current.style.transform = `scaleX(${max > 0 ? Math.min(window.scrollY / max, 1) : 0})`; }; update(); window.addEventListener("scroll", update, { passive: true }); window.addEventListener("resize", update); return () => { window.removeEventListener("scroll", update); window.removeEventListener("resize", update); }; }, []); return (
); }