mirror of
https://github.com/jorgev259/soc_site-astro.git
synced 2025-06-29 07:57:41 +00:00
Implement register form
This commit is contained in:
parent
adeb3fd3bf
commit
cdcd71cf2a
17 changed files with 526 additions and 99 deletions
33
src/components/Modal.tsx
Normal file
33
src/components/Modal.tsx
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { useEffect, type KeyboardEvent, type PropsWithChildren } from 'react'
|
||||
import type { SetState } from 'types'
|
||||
|
||||
export default function Modal(props: PropsWithChildren<{ setOpen: SetState<boolean> }>) {
|
||||
const { children, setOpen } = props
|
||||
|
||||
useEffect(() => {
|
||||
const handleEsc = (ev: KeyboardEvent) => {
|
||||
if (ev.code === 'Escape') setOpen(false)
|
||||
}
|
||||
|
||||
window.addEventListener('keydown', handleEsc)
|
||||
return () => {
|
||||
window.removeEventListener('keydown', handleEsc)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div
|
||||
className='fixed size-full flex bg-black bg-opacity-50 left-0 top-0 z-50 justify-center items-center'
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
<div
|
||||
className='bg-white rounded-lg overflow-hidden shadow-xl transform transition-all m-8'
|
||||
role='dialog'
|
||||
aria-modal='true'
|
||||
onClick={(ev) => ev.stopPropagation()}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue