PluginProbe
Extendify / 3.2.1
Extendify v3.2.1
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 / Assist / components / Modal.jsx

Modal.jsx in Extendify 3.2.1, at src/Assist/components/Modal.jsx

52 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useGlobalStore } from '@assist/state/globals';
2 import { Dialog, DialogTitle } from '@headlessui/react';
3 import { Button } from '@wordpress/components';
4 import { useEffect, useState } from '@wordpress/element';
5 import { __ } from '@wordpress/i18n';
6 import { close, Icon } from '@wordpress/icons';
7
8 export const Modal = () => {
9 const { modals, popModal } = useGlobalStore();
10 const ModalContent = modals[0];
11 const [title, setTitle] = useState('');
12
13 useEffect(() => {
14 if (!modals[0]) setTitle('');
15 }, [modals]);
16
17 return (
18 <Dialog
19 as="div"
20 className="extendify-assist"
21 open={modals.length > 0}
22 onClose={popModal}
23 >
24 <div className="fixed top-0 z-high mx-auto h-full w-full items-center justify-center overflow-hidden p-2 md:flex md:p-6">
25 <div
26 className="fixed inset-0 bg-black/40 transition-opacity"
27 aria-hidden="true"
28 />
29 <div className="relative mx-auto flex flex-col rounded-xs bg-white shadow-2xl sm:flex sm:min-w-md sm:overflow-hidden">
30 <div className="flex items-center justify-between">
31 <DialogTitle className="m-0 px-6 text-base text-gray-900">
32 {title}
33 </DialogTitle>
34 <Button
35 className="m-4 border-0"
36 onClick={popModal}
37 icon={<Icon icon={close} size={24} />}
38 label={__('Close Modal', 'extendify-local')}
39 showTooltip={false}
40 />
41 </div>
42 <div className="relative m-0 p-6 pt-0 text-left">
43 {modals?.length > 0 && (
44 <ModalContent popModal={popModal} setModalTitle={setTitle} />
45 )}
46 </div>
47 </div>
48 </div>
49 </Dialog>
50 );
51 };
52