mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-05 23:16:52 +00:00
feature:
样式调整; 顶部菜单调整
This commit is contained in:
28
components/FloatDarkModeButton.js
Normal file
28
components/FloatDarkModeButton.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import DarkModeButton from './DarkModeButton'
|
||||
|
||||
let windowTop = 0
|
||||
export default function FloatDarkModeButton () {
|
||||
const [show, switchShow] = useState(false)
|
||||
const scrollListener = () => {
|
||||
const scrollY = window.pageYOffset
|
||||
const shouldShow = scrollY > 100 && scrollY < windowTop
|
||||
windowTop = scrollY
|
||||
if (shouldShow !== show) {
|
||||
switchShow(shouldShow)
|
||||
}
|
||||
}
|
||||
useEffect(() => {
|
||||
document.addEventListener('scroll', scrollListener)
|
||||
return () => document.removeEventListener('scroll', scrollListener)
|
||||
})
|
||||
|
||||
return (
|
||||
<div
|
||||
className={(show ? 'animate__fadeInRight ' : 'hidden lg:block') + ' animate__animated animate__faster shadow-card fixed right-5 bottom-36 py-1.5 px-2.5 rounded-full' +
|
||||
' text-black shadow-card dark:border-gray-500 glassmorphism dark:bg-gray-700 dark:text-gray-200'}
|
||||
>
|
||||
<DarkModeButton />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user