Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Sync overlay transition with sidebar transition in mobile view #1264

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions components/Backdrop/Backdrop.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
import { FC } from 'react'
import { FC, useEffect } from 'react'
import { createPortal } from 'react-dom'
import { useTransition } from 'react-transition-state'

export const Backdrop: FC<{
onClick: (() => void) | undefined
className?: string | undefined
}> = (props) => {
const { onClick, className } = props
const [{ status }, toggle] = useTransition({
timeout: 500,
preEnter: true,
})

useEffect(() => {
toggle(true)
}, [toggle])

return createPortal(
<div
className={`fixed inset-0 z-50 h-full w-full cursor-pointer bg-black/80 ${className}`}
className={`fixed inset-0 z-50 h-full w-full cursor-pointer bg-black/80
${className}
${status === 'preEnter' || status === 'entering' ? '' : 'opacity-0'}
${status === 'entered' ? 'opacity-100' : ''}
`}
onClick={onClick}
></div>,
document.getElementById('backdrop-root')!
Expand Down
5 changes: 4 additions & 1 deletion components/SideNavbar/SideNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export const SideNavbar: FC<{}> = () => {

return (
<>
<Backdrop onClick={closeNav} className="lg:hidden" />
<Backdrop
onClick={closeNav}
className="lg:hidden transition duration-300 delay-200"
/>
{createPortal(
<div
className={`fixed top-0 left-0 z-[100] h-full w-[75%] transition-all lg:hidden
Expand Down