first commit

This commit is contained in:
“dongming”
2025-12-29 11:46:49 +08:00
commit 2a8369ac46
64 changed files with 5190 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
import { useState, useEffect } from 'react'
export default function ScrollToTop() {
const [isVisible, setIsVisible] = useState(false)
useEffect(() => {
const handleScroll = () => {
setIsVisible(window.scrollY > 200)
}
window.addEventListener('scroll', handleScroll)
return () => window.removeEventListener('scroll', handleScroll)
}, [])
const scrollToTop = () => {
window.scrollTo({
top: 0,
behavior: 'smooth',
})
}
return (
<button
onClick={scrollToTop}
className={`fixed bottom-4 right-4 w-10 h-10 bg-secondary hover:bg-secondary/80 text-white rounded shadow-lg flex items-center justify-center transition-all duration-300 z-50 ${
isVisible ? 'opacity-100 translate-y-0' : 'opacity-0 translate-y-4 pointer-events-none'
}`}
aria-label="Back to top"
>
<span className="fa fa-angle-up" />
</button>
)
}