Skip to content

Commit

Permalink
🚸 Prevent scrolling when hamburger menu is open (#1631)
Browse files Browse the repository at this point in the history
  • Loading branch information
mingjunlu authored Nov 13, 2023
1 parent 221c054 commit eddd14b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/website/src/components/Layout/Hamburger/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ const Hamburger = () => {
return () => Router.events.off('routeChangeStart', onRouteChangeStart)
}, [])

useEffect(() => {
if (isOpen) {
document.body.classList.add('overflow-hidden')
} else {
document.body.classList.remove('overflow-hidden')
}
}, [isOpen])

return (
<div className={styles.hamburger}>
<button
Expand Down
4 changes: 4 additions & 0 deletions packages/website/src/utils/theme/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ pre {
padding: 1em;
}

.overflow-hidden {
overflow: hidden;
}

.overflow-x-adjust {
overflow-x: auto;
}
Expand Down

1 comment on commit eddd14b

@vercel
Copy link

@vercel vercel bot commented on eddd14b Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

gitmoji – ./

www.gitmoji.dev
gitmoji.dev
gitmoji-git-master-carloscuesta.vercel.app
gitmoji-carloscuesta.vercel.app

Please sign in to comment.