/** * ConfirmDialog 컴포넌트 * 삭제 등 위험한 작업의 확인을 위한 공통 다이얼로그 * * Props: * - isOpen: 다이얼로그 표시 여부 * - onClose: 닫기 콜백 * - onConfirm: 확인 콜백 * - title: 제목 (예: "앨범 삭제") * - message: 메시지 내용 (ReactNode 가능) * - confirmText: 확인 버튼 텍스트 (기본: "삭제") * - cancelText: 취소 버튼 텍스트 (기본: "취소") * - loading: 로딩 상태 * - loadingText: 로딩 중 텍스트 (기본: "삭제 중...") * - variant: 버튼 색상 (기본: "danger", "primary" 가능) */ import { createPortal } from 'react-dom'; import { motion, AnimatePresence } from 'framer-motion'; import { AlertTriangle, Trash2 } from 'lucide-react'; function ConfirmDialog({ isOpen, onClose, onConfirm, title, message, confirmText = '삭제', cancelText = '취소', loading = false, loadingText = '삭제 중...', variant = 'danger', icon: Icon = AlertTriangle, }) { // 버튼 색상 설정 const buttonColors = { danger: 'bg-red-500 hover:bg-red-600', primary: 'bg-primary hover:bg-primary-dark', }; const iconBgColors = { danger: 'bg-red-100', primary: 'bg-primary/10', }; const iconColors = { danger: 'text-red-500', primary: 'text-primary', }; return createPortal( {isOpen && ( !loading && onClose()} > e.stopPropagation()} > {/* 헤더 */}

{title}

{/* 메시지 */}
{message}
{/* 버튼 */}
)}
, document.body ); } export default ConfirmDialog;