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 / Assist / components / Modal.jsx

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

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