Skip to content

Commit

Permalink
fix: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
disaerna committed Jan 9, 2025
1 parent 872c3f1 commit ca6fbf6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export const menuBtn = style({
borderRadius: 8,
padding: `${theme.spacing['p2']}px ${theme.spacing[2]}px`,
transition: 'box-shadow .25s, color .25s, background-color .25s',
':focus-visible': {
boxShadow: `0 0 0 3px ${theme.color.blue400}`,
},
})

export const listItem = style({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, {
ReactNode,
createContext,
ReactElement,
useRef,
} from 'react'
import cn from 'classnames'
import AnimateHeight from 'react-animate-height'
Expand Down Expand Up @@ -434,26 +435,31 @@ const MobileButton = ({
mobileNavigationButtonOpenLabel,
}: MobileButtonProps) => {
const [isShaking, setIsShaking] = useState(false)
const time = 60000 // 1 minute
const time = 15000 // 15 seconds
const idleTimerRef = useRef<NodeJS.Timeout | null>(null)

useEffect(() => {
const handleIdle = () => {
setIsShaking(true)
setTimeout(() => setIsShaking(false), 1000) // Stop shaking after 1 second
}

const idleTimer = setTimeout(handleIdle, time)

const resetTimer = () => {
clearTimeout(idleTimer)
setTimeout(handleIdle, time)
if (idleTimerRef.current) {
clearTimeout(idleTimerRef.current)
}
idleTimerRef.current = setTimeout(handleIdle, time)
}

resetTimer() // Initialize the timer

window.addEventListener('mousemove', resetTimer)
window.addEventListener('keydown', resetTimer)

return () => {
clearTimeout(idleTimer)
if (idleTimerRef.current) {
clearTimeout(idleTimerRef.current)
}
window.removeEventListener('mousemove', resetTimer)
window.removeEventListener('keydown', resetTimer)
}
Expand Down

0 comments on commit ca6fbf6

Please sign in to comment.