/** * AppPopup — TradeAlertModal(tam-) 기준 공통 팝업 셸 * 신규 팝업은 이 컴포넌트를 사용하세요. */ import '../styles/appPopup.css'; import React from 'react'; import { createPortal } from 'react-dom'; import { useDraggablePanel } from '../hooks/useDraggablePanel'; export const APP_POPUP_ACCENT = '#3f7ef5'; export const APP_POPUP_ACCENT_GLOW = 'rgba(63,126,245,0.22)'; export interface AppPopupProps { onClose: () => void; title: React.ReactNode; titleKo?: React.ReactNode; badge?: string; accentColor?: string; children: React.ReactNode; width?: number | string; maxWidth?: number | string; className?: string; shellClassName?: string; overlayClassName?: string; bodyClassName?: string; centered?: boolean; zIndex?: number; closeOnBackdrop?: boolean; backdrop?: boolean; portal?: boolean; headerExtra?: React.ReactNode; footer?: React.ReactNode; initialPosition?: { x: number; y: number }; bodyRef?: React.Ref; } export const AppPopup: React.FC = ({ onClose, title, titleKo, badge, accentColor = APP_POPUP_ACCENT, children, width = 400, maxWidth = '96vw', className, shellClassName, overlayClassName, bodyClassName = 'app-popup-body', centered = true, zIndex = 9999, closeOnBackdrop = true, backdrop = false, portal = true, headerExtra, footer, initialPosition, bodyRef, }) => { const accentGlow = accentColor === APP_POPUP_ACCENT ? APP_POPUP_ACCENT_GLOW : `${accentColor}38`; const { panelRef, dragging, onHeaderPointerDown, headerTouchStyle, panelStyle, headerCursor, } = useDraggablePanel({ centerOnMount: centered, initialPosition }); const overlayCls = [ 'app-popup-overlay', backdrop ? 'app-popup-overlay--dim' : '', overlayClassName ?? '', className ?? '', ].filter(Boolean).join(' '); const shellCls = ['app-popup-shell', shellClassName ?? ''].filter(Boolean).join(' '); const content = (
{ if (closeOnBackdrop && backdrop && e.target === e.currentTarget) onClose(); }} >
e.stopPropagation()} >
{badge ? ( {badge} ) : null} {title} {titleKo != null && titleKo !== '' ? ( ({titleKo}) ) : null}
{headerExtra}
{children}
{footer}
); if (portal && typeof document !== 'undefined' && document.body) { return createPortal(content, document.body); } return content; }; export default AppPopup;