handle bookmark delete loading state

This commit is contained in:
2025-05-07 16:57:09 +01:00
parent e87a6586b6
commit 9f00c9bb29
7 changed files with 107 additions and 31 deletions

View File

@@ -0,0 +1,24 @@
import { useState, useEffect, useRef } from "react"
// courtesy of https://github.com/sindresorhus/cli-spinners
const FRAMES = ["-", "\\", "|", "/"]
function LoadingSpinner() {
const [frame, setFrame] = useState(0)
const timer = useRef<ReturnType<typeof setInterval>>(null)
useEffect(() => {
timer.current = setInterval(() => {
setFrame((frame) => (frame === 3 ? 0 : frame + 1))
}, 100)
return () => {
if (timer.current) {
clearInterval(timer.current)
}
}
}, [])
return <span className="whitespace-pre">{FRAMES[frame]}</span>
}
export { LoadingSpinner }