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:
		
							
								
								
									
										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>
 | 
			
		||||
  )
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user