PluginProbe
Extendify / 2.2.0
Extendify v2.2.0
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 0.7.0 All 126 releases
extendify / src / HelpCenter / components / modal / Modal.jsx

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

76 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useEffect } from '@wordpress/element';
2 import { __ } from '@wordpress/i18n';
3 import { Dialog, DialogTitle } from '@headlessui/react';
4 import { motion } from 'framer-motion';
5 import { MinimizedButton } from '@help-center/components/buttons/MinimizedButton';
6 import { ModalContent } from '@help-center/components/modal/ModalContent';
7 import { Topbar } from '@help-center/components/modal/TopBar';
8 import { useRouter } from '@help-center/hooks/useRouter';
9 import { useAIChatStore } from '@help-center/state/ai-chat';
10 import { useGlobalSyncStore } from '@help-center/state/globals-sync';
11 import { useKnowledgeBaseStore } from '@help-center/state/knowledge-base';
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 <div
53 // TODO: later measure the dashboard height using h-fit and apply that elsewhere
54 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">
55 <motion.div
56 key="help-center-modal"
57 initial={{ y: 6, opacity: 0 }}
58 animate={{ y: 0, opacity: 1 }}
59 exit={{ y: 0, opacity: 0 }}
60 transition={{ duration: 0.2, delay: 0.1 }}
61 className="relative mx-auto h-full w-full shadow-2xl-flipped sm:flex sm:overflow-hidden md:rounded-md md:shadow-2xl">
62 <DialogTitle className="sr-only">
63 {__('Extendify Help Center', 'extendify-local')}
64 </DialogTitle>
65 <div className="relative flex h-full w-full flex-col rounded-md border border-gray-400 bg-gray-50 md:overflow-hidden">
66 <Topbar />
67 <div className="flex-grow overflow-y-auto overscroll-contain">
68 <ModalContent />
69 </div>
70 </div>
71 </motion.div>
72 </div>
73 </Dialog>
74 );
75 };
76