PluginProbe
Extendify / 3.1.5
Extendify v3.1.5
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 / HelpCenter / components / modal / Modal.jsx

Modal.jsx in Extendify 3.1.5, at src/HelpCenter/components/modal/Modal.jsx

79 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { Dialog, DialogTitle } from '@headlessui/react';
2 import { MinimizedButton } from '@help-center/components/buttons/MinimizedButton';
3 import { ModalContent } from '@help-center/components/modal/ModalContent';
4 import { Topbar } from '@help-center/components/modal/TopBar';
5 import { useRouter } from '@help-center/hooks/useRouter';
6 import { useAIChatStore } from '@help-center/state/ai-chat';
7 import { useGlobalSyncStore } from '@help-center/state/globals-sync';
8 import { useKnowledgeBaseStore } from '@help-center/state/knowledge-base';
9 import { useEffect } from '@wordpress/element';
10 import { __ } from '@wordpress/i18n';
11 import { motion } from 'framer-motion';
12
13 export const Modal = () => {
14 const { visibility } = useGlobalSyncStore();
15 const { reset: resetRouterState } = useRouter();
16 const { reset: resetKnowledgeBaseState } = useKnowledgeBaseStore();
17 const { reset: resetAIChatState } = useAIChatStore();
18
19 useEffect(() => {
20 if (visibility === 'closed') {
21 resetRouterState();
22 resetKnowledgeBaseState();
23 resetAIChatState();
24 }
25 }, [resetAIChatState, resetKnowledgeBaseState, resetRouterState, visibility]);
26
27 if (visibility === 'minimized') {
28 return (
29 <div className="extendify-help-center">
30 <div className="fixed bottom-0 right-0 z-high mx-auto w-[420px] md:m-8 rtl:left-0 rtl:right-auto">
31 <MinimizedButton />
32 </div>
33 </div>
34 );
35 }
36
37 if (visibility !== 'open') return null;
38
39 return (
40 <Dialog
41 ref={async () => {
42 await Promise.resolve();
43 if (!document?.documentElement?.style) return;
44 document.documentElement.style.overflow = 'unset';
45 document.documentElement.style.paddingRight = 'unset';
46 }}
47 className="extendify-help-center"
48 data-test="help-center-modal"
49 open={visibility === 'open'}
50 static
51 onClose={() => undefined}
52 >
53 <div
54 // TODO: later measure the dashboard height using h-fit and apply that elsewhere
55 className="fixed bottom-0 right-0 z-high mx-auto h-full max-h-[589px] w-full max-w-[420px] md:m-8 md:mt-20 rtl:left-0 rtl:right-auto"
56 >
57 <motion.div
58 key="help-center-modal"
59 initial={{ y: 6, opacity: 0 }}
60 animate={{ y: 0, opacity: 1 }}
61 exit={{ y: 0, opacity: 0 }}
62 transition={{ duration: 0.2, delay: 0.1 }}
63 className="relative mx-auto h-full w-full shadow-2xl-flipped sm:flex sm:overflow-hidden md:rounded-md md:shadow-2xl"
64 >
65 <DialogTitle className="sr-only">
66 {__('Extendify Help Center', 'extendify-local')}
67 </DialogTitle>
68 <div className="relative flex h-full w-full flex-col rounded-md border border-gray-400 bg-gray-50 md:overflow-hidden">
69 <Topbar />
70 <div className="grow overflow-y-auto overscroll-contain">
71 <ModalContent />
72 </div>
73 </div>
74 </motion.div>
75 </div>
76 </Dialog>
77 );
78 };
79