| 1 |
import { CanvasPane, DOT_GRID } from '@agent/components/Canvas'; |
| 2 |
import { usePortal } from '@agent/hooks/usePortal'; |
| 3 |
import { createPortal } from '@wordpress/element'; |
| 4 |
import { motion } from 'framer-motion'; |
| 5 |
|
| 6 |
const CHAT_WIDTH = 384; |
| 7 |
const MODAL_SIZE = { |
| 8 |
width: 1024, |
| 9 |
height: 720, |
| 10 |
maxWidth: 'calc(100vw - 8rem)', |
| 11 |
maxHeight: 'calc(100vh - 8rem)', |
| 12 |
}; |
| 13 |
|
| 14 |
// The canvas owns the scrim and the close control, so this only clears the scrim. |
| 15 |
export const CanvasModalLayout = ({ children }) => { |
| 16 |
const mountNode = usePortal('extendify-agent-canvas-modal-mount'); |
| 17 |
|
| 18 |
if (!mountNode) return null; |
| 19 |
|
| 20 |
return createPortal( |
| 21 |
<div className="pointer-events-none fixed inset-0 z-[100001] overflow-auto"> |
| 22 |
<div className="pointer-events-auto flex min-h-full items-center justify-center px-4 py-8"> |
| 23 |
<motion.div |
| 24 |
initial={{ opacity: 0 }} |
| 25 |
animate={{ opacity: 1 }} |
| 26 |
transition={{ duration: 0.3, ease: 'easeInOut' }} |
| 27 |
className="relative flex overflow-hidden rounded-2xl bg-gray-50 p-2 shadow-lg" |
| 28 |
style={{ ...DOT_GRID, ...MODAL_SIZE }} |
| 29 |
> |
| 30 |
<div |
| 31 |
className="relative z-10 flex h-full shrink-0 flex-col overflow-hidden rounded-2xl bg-white shadow-lg" |
| 32 |
style={{ width: CHAT_WIDTH }} |
| 33 |
> |
| 34 |
<div className="flex shrink-0 items-center bg-banner-main px-4 py-2.5 text-banner-text"> |
| 35 |
<div className="flex h-5 max-w-36 overflow-hidden"> |
| 36 |
<img |
| 37 |
className="max-h-full max-w-full object-contain" |
| 38 |
src={window.extSharedData.partnerLogo} |
| 39 |
alt={window.extSharedData.partnerName} |
| 40 |
/> |
| 41 |
</div> |
| 42 |
</div> |
| 43 |
{children} |
| 44 |
</div> |
| 45 |
<CanvasPane seat="modal" /> |
| 46 |
</motion.div> |
| 47 |
</div> |
| 48 |
</div>, |
| 49 |
mountNode, |
| 50 |
); |
| 51 |
}; |
| 52 |
|