PluginProbe
Extendify / 0.9.2
Extendify v0.9.2
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 / Library / components / modals / SplitModal.js

SplitModal.js in Extendify 0.9.2, at src/Library/components/modals/SplitModal.js

78 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { Fragment, forwardRef, useRef } from '@wordpress/element'
2 import { __ } from '@wordpress/i18n'
3 import { Icon, close } from '@wordpress/icons'
4 import { Dialog, Transition } from '@headlessui/react'
5 import { useGlobalStore } from '@library/state/GlobalState'
6
7 export const SplitModal = forwardRef(
8 (
9 {
10 onClose,
11 isOpen,
12 invertedButtonColor,
13 children,
14 leftContainerBgColor = 'bg-white',
15 rightContainerBgColor = 'bg-gray-100',
16 },
17 initialFocus,
18 ) => {
19 const focusBackup = useRef(null)
20 const defaultClose = useGlobalStore((state) => state.removeAllModals)
21 onClose = onClose ?? defaultClose
22
23 return (
24 <Transition.Root appear show={true} as={Fragment}>
25 <Dialog
26 as="div"
27 static
28 open={isOpen}
29 className="extendify"
30 initialFocus={initialFocus ?? focusBackup}
31 onClose={onClose}>
32 <div className="fixed inset-0 z-high flex">
33 <Transition.Child
34 as={Fragment}
35 enter="ease-out duration-50 transition"
36 enterFrom="opacity-0"
37 enterTo="opacity-100">
38 <Dialog.Overlay className="fixed inset-0 bg-black bg-opacity-40 transition-opacity" />
39 </Transition.Child>
40 <Transition.Child
41 as={Fragment}
42 enter="ease-out duration-300 translate transform"
43 enterFrom="opacity-0 translate-y-4 sm:translate-y-5"
44 enterTo="opacity-100 translate-y-0">
45 <div className="m-auto">
46 <div className="relative m-8 max-w-md justify-between rounded-sm shadow-modal md:m-0 md:flex md:max-w-2xl">
47 <button
48 onClick={onClose}
49 ref={focusBackup}
50 className="absolute top-0 right-0 block cursor-pointer rounded-md bg-transparent p-4 text-gray-700 opacity-30 hover:opacity-100"
51 style={
52 invertedButtonColor && {
53 filter: 'invert(1)',
54 }
55 }>
56 <span className="sr-only">
57 {__('Close', 'extendify')}
58 </span>
59 <Icon icon={close} />
60 </button>
61 <div
62 className={`w-7/12 p-12 ${leftContainerBgColor}`}>
63 {children[0]}
64 </div>
65 <div
66 className={`hidden w-6/12 md:block ${rightContainerBgColor}`}>
67 {children[1]}
68 </div>
69 </div>
70 </div>
71 </Transition.Child>
72 </div>
73 </Dialog>
74 </Transition.Root>
75 )
76 },
77 )
78