/** @jsxImportSource @emotion/react */ import { Interpolation, Theme } from '@emotion/react'; import { useEffect, useRef, useState } from 'react'; import { colors } from 'src/libs/themes'; import BlurLayer from './pice/BlurLayer'; import { useModalStatic } from './pice/useModalStatic'; interface DialogProps { open: boolean; title: string; description: string; tabName: string; onResult: () => void; onClose: () => void; } const Dialog: React.FC = ({ open, title, description, tabName, onResult, onClose }) => { const tabs: { name: string; buttonColor?: string; txtColor?: string; onClick?: () => void; disabled?: boolean; }[] = [ { name: '취소', txtColor: '#888', buttonColor: '#e2e2e2', onClick: onClose }, { name: tabName, txtColor: '#fff', buttonColor: colors.keyColor, onClick: onResult, }, ]; const ref = useRef(null); const [delayedOpen, setDelayedOpen] = useState(false); const handleCancel = () => { setDelayedOpen(false); const timeout = setTimeout(() => onClose(), 100); return () => clearTimeout(timeout); }; useEffect(() => { if (open) { const timeout = setTimeout(() => setDelayedOpen(true), 50); return () => clearTimeout(timeout); } else { setDelayedOpen(false); } }, [open]); useModalStatic({ ref, open: delayedOpen, onCancel: handleCancel, clickOutSideClose: true, windowScreenScroll: false, }); return ( <> {open && ( <>
{title}

{description}

{tabs?.length !== 0 && !!tabs && (
{tabs?.map((item: any, i: number) => ( ))}
)}
)} ); }; export default Dialog; // // const flexT: Interpolation = { position: 'relative', display: 'flex', flexDirection: 'column', alignItems: 'center', width: '100%', height: '100%', transition: '0.2s ease-in-out', };