PluginProbe
Extendify / 0.6.0
Extendify v0.6.0
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 / pages / MainWindow.js

MainWindow.js in Extendify 0.6.0, at src/pages/MainWindow.js

67 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { Fragment, useRef } from '@wordpress/element'
2 import { Dialog, Transition } from '@headlessui/react'
3 import FooterNotice from '@extendify/components/notices/FooterNotice'
4 import { useModal } from '@extendify/hooks/useModal'
5 import { useTestGroup } from '@extendify/hooks/useTestGroup'
6 import { useGlobalStore } from '@extendify/state/GlobalState'
7 import { Layout } from './layout/Layout'
8
9 export default function MainWindow() {
10 const containerRef = useRef(null)
11 const open = useGlobalStore((state) => state.open)
12 const setOpen = useGlobalStore((state) => state.setOpen)
13 const modal = useModal(open)
14 const ready = useGlobalStore((state) => state.ready)
15 const footerNoticePosition = useTestGroup('notice-position', ['A', 'B'])
16
17 return (
18 <Transition appear show={open} as={Fragment}>
19 <Dialog
20 as="div"
21 static
22 className="extendify"
23 initialFocus={containerRef}
24 onClose={() => setOpen(false)}>
25 <div className="fixed inset-0 z-high m-auto h-screen w-screen overflow-y-auto sm:h-auto sm:w-auto">
26 <div className="flex min-h-screen items-end justify-center px-4 pt-4 pb-20 text-center sm:block sm:p-0">
27 <Transition.Child
28 as={Fragment}
29 enter="ease-out duration-300"
30 enterFrom="opacity-0"
31 enterTo="opacity-100">
32 <Dialog.Overlay className="fixed inset-0 bg-black bg-opacity-40 transition-opacity" />
33 </Transition.Child>
34 <Transition.Child
35 as={Fragment}
36 enter="ease-out duration-300"
37 enterFrom="opacity-0 translate-y-4 sm:translate-y-5"
38 enterTo="opacity-100 translate-y-0">
39 <div
40 ref={containerRef}
41 tabIndex="0"
42 onClick={(e) =>
43 e.target === e.currentTarget &&
44 setOpen(false)
45 }
46 className="fixed inset-0 transform p-2 transition-all lg:absolute lg:overflow-hidden lg:p-16">
47 {footerNoticePosition === 'B' && (
48 <FooterNotice className="-mt-6" />
49 )}
50 <Layout />
51 {ready ? (
52 <>
53 {footerNoticePosition === 'A' && (
54 <FooterNotice />
55 )}
56 {modal}
57 </>
58 ) : null}
59 </div>
60 </Transition.Child>
61 </div>
62 </div>
63 </Dialog>
64 </Transition>
65 )
66 }
67