mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
Added db selector, modal
This commit is contained in:
parent
0876761a0f
commit
3343a2a3af
10 changed files with 250 additions and 32 deletions
43
src/components/modal.js
Normal file
43
src/components/modal.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
import React, { useEffect } from 'react'
|
||||
|
||||
import styles from './modal.module.css'
|
||||
|
||||
export default function Modal(props) {
|
||||
const { closeClick } = props
|
||||
|
||||
const keyHandler = (event) => {
|
||||
if (event.key === 'Escape' && closeClick) {
|
||||
closeClick()
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
document.addEventListener('keydown', keyHandler)
|
||||
return () => {
|
||||
document.removeEventListener('keydown', keyHandler)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
cursor: closeClick ? 'pointer' : 'auto',
|
||||
}}
|
||||
onClick={() => {
|
||||
if (closeClick) {
|
||||
closeClick()
|
||||
}
|
||||
}}
|
||||
className={styles.modal}
|
||||
>
|
||||
<div
|
||||
onClick={(event) => {
|
||||
event.stopPropagation()
|
||||
}}
|
||||
className={styles.modalContent}
|
||||
>
|
||||
{props.children}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue