This commit is contained in:
eric
2026-05-20 18:29:19 -05:00
parent 9f4bf1b28c
commit 6809f833f8
31 changed files with 5963 additions and 78 deletions

View File

@@ -0,0 +1,37 @@
"use client";
import { useEffect, useState } from "react";
export function ReadingProgress() {
const [progress, setProgress] = useState(0);
useEffect(() => {
function onScroll() {
const doc = document.documentElement;
const scrollTop = doc.scrollTop;
const scrollHeight = doc.scrollHeight - doc.clientHeight;
const pct = scrollHeight > 0 ? (scrollTop / scrollHeight) * 100 : 0;
setProgress(Math.min(100, Math.max(0, pct)));
}
onScroll();
window.addEventListener("scroll", onScroll, { passive: true });
return () => window.removeEventListener("scroll", onScroll);
}, []);
return (
<div
className="reading-progress"
role="progressbar"
aria-valuenow={Math.round(progress)}
aria-valuemin={0}
aria-valuemax={100}
aria-label="Reading progress"
>
<div
className="reading-progress__bar"
style={{ width: `${progress}%` }}
/>
</div>
);
}