import React from 'react' import Close from '../../resources/icons/close.svg' import './MiniDialog.css' interface IProps { children: React.ReactNode[] | React.ReactNode title?: string closeable?: boolean closeFn: () => void } export default class MiniDialog extends React.Component { constructor(props: IProps) { super(props) } componentDidMount() { document.addEventListener('mousedown', (evt) => { const tgt = evt.target as HTMLElement const isInside = tgt.closest('.MiniDialog') !== null if (!isInside) { this.props.closeFn() } }) } componentWillUnmount() { document.removeEventListener('mousedown', this.props.closeFn) } render() { return (
{this.props.closeable !== undefined && this.props.closeable ? (
{this.props?.title}
) : null}
{this.props.children}
) } }