Skip to content

Commit 94c4be5

Browse files
ux: animate buried count — ticks up last 20 on load
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 62a332b commit 94c4be5

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

src/app/page.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const MONO = `var(--font-courier), 'Courier New', monospace`
1717
export default function Page() {
1818
const { url, setUrl, certificate, error, loading, analyze, reset } = useRepoAnalysis()
1919
const [buried, setBuried] = useState<number | null>(null)
20+
const [displayedBuried, setDisplayedBuried] = useState<number | null>(null)
2021
const [statsLoading, setStatsLoading] = useState(true)
2122
const restoredRef = useRef(false)
2223

@@ -28,6 +29,20 @@ export default function Page() {
2829
.finally(() => setStatsLoading(false))
2930
}, [])
3031

32+
useEffect(() => {
33+
if (buried === null) return
34+
const start = Math.max(0, buried - 20)
35+
setDisplayedBuried(start)
36+
let current = start
37+
const tick = () => {
38+
current += 1
39+
setDisplayedBuried(current)
40+
if (current < buried) setTimeout(tick, 55)
41+
}
42+
if (start < buried) setTimeout(tick, 120)
43+
else setDisplayedBuried(buried)
44+
}, [buried])
45+
3146
useEffect(() => {
3247
if (restoredRef.current) return
3348
restoredRef.current = true
@@ -69,9 +84,9 @@ export default function Page() {
6984
counting graves...
7085
</p>
7186
)}
72-
{!statsLoading && buried !== null && buried >= 1 && (
87+
{!statsLoading && displayedBuried !== null && displayedBuried >= 1 && (
7388
<p style={{ fontFamily: FONT, fontSize: '14px', fontWeight: 600, color: '#4f4f4f', opacity: 0.92, textAlign: 'center', margin: '8px 0 0 0', letterSpacing: '0.02em' }}>
74-
{buried.toLocaleString()} repos buried
89+
{displayedBuried.toLocaleString()} repos buried
7590
</p>
7691
)}
7792

0 commit comments

Comments
 (0)