PluginProbe
Extendify / 3.1.0
Extendify v3.1.0
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / Agent / components / layouts / MobileLayout.jsx

MobileLayout.jsx in Extendify 3.1.0, at src/Agent/components/layouts/MobileLayout.jsx

74 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { usePortal } from '@agent/hooks/usePortal';
2 import { useGlobalStore } from '@agent/state/global';
3 import { createPortal, useEffect } from '@wordpress/element';
4 import { __ } from '@wordpress/i18n';
5 import { chevronDown, Icon } from '@wordpress/icons';
6 import { AnimatePresence, motion } from 'framer-motion';
7
8 export const MobileLayout = ({ children }) => {
9 const mountNode = usePortal('extendify-agent-mount');
10 const { minimized, setMinimized } = useGlobalStore();
11
12 const minimize = () => setMinimized(true);
13
14 useEffect(() => {
15 if (!mountNode || minimized) return;
16 document.body.style.overflow = 'hidden';
17 return () => {
18 document.body.style.overflow = '';
19 };
20 }, [mountNode, minimized]);
21
22 if (!mountNode) return null;
23
24 return createPortal(
25 <div
26 className={`fixed inset-0 z-max-1 items-center justify-center ${
27 minimized ? 'hidden' : 'flex'
28 }`}
29 aria-hidden={minimized ? 'true' : 'false'}
30 >
31 <div className="pointer-events-none absolute inset-0 bg-black/70" />
32 <AnimatePresence>
33 <motion.div
34 key="agent-popout-modal"
35 id="extendify-agent-popout-modal"
36 initial={{ opacity: 0 }}
37 animate={{ opacity: 1 }}
38 exit={{ y: 0, opacity: 0 }}
39 transition={{ duration: 0.4, delay: 0.1 }}
40 className="fixed bottom-[2vh] z-high flex h-full max-h-[80vh] w-full max-w-[90vw] flex-col rounded-lg border border-solid border-gray-600 bg-white shadow-2xl-flipped rtl:left-0 rtl:right-auto"
41 >
42 <div className="group flex shrink-0 items-center justify-between overflow-hidden rounded-t-[calc(0.5rem-1px)] bg-banner-main text-banner-text">
43 <div className="flex h-full grow items-center justify-between gap-1 p-0 py-3">
44 <div className="flex h-5 px-4 max-w-36 overflow-hidden">
45 <img
46 className="max-h-full max-w-full object-contain"
47 src={window.extSharedData.partnerLogo}
48 alt={window.extSharedData.partnerName}
49 />
50 </div>
51 </div>
52 <button
53 type="button"
54 className="relative z-10 flex h-full items-center rounded-none border-0 bg-banner-main py-3 pe-4 ps-2 text-banner-text outline-hidden ring-design-main focus:shadow-none focus:outline-hidden focus-visible:outline-design-main"
55 onClick={minimize}
56 >
57 <Icon
58 className="pointer-events-none fill-current leading-none"
59 icon={chevronDown}
60 size={24}
61 />
62 <span className="sr-only">
63 {__('Minimize window', 'extendify-local')}
64 </span>
65 </button>
66 </div>
67 {children}
68 </motion.div>
69 </AnimatePresence>
70 </div>,
71 mountNode,
72 );
73 };
74