Initial commit: anime-minimalist personal blog
- React 18 + Vite + React Router v6 - Glass morphism cards with rounded corners - Dark/light theme toggle - Article CRUD with localStorage persistence - Search, admin panel (PIN: 2501), sakura petal canvas animation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
21
src/components/ui/ScrollProgress.jsx
Normal file
21
src/components/ui/ScrollProgress.jsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import styles from './ScrollProgress.module.css';
|
||||
|
||||
export default function ScrollProgress() {
|
||||
const [pct, setPct] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
const update = () => {
|
||||
const el = document.documentElement;
|
||||
const scrolled = el.scrollTop;
|
||||
const total = el.scrollHeight - el.clientHeight;
|
||||
setPct(total > 0 ? (scrolled / total) * 100 : 0);
|
||||
};
|
||||
window.addEventListener('scroll', update, { passive: true });
|
||||
return () => window.removeEventListener('scroll', update);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className={styles.bar} style={{ width: `${pct}%` }} aria-hidden="true" />
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user