PluginProbe
Extendify / 1.6.1
Extendify v1.6.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 0.7.0 All 126 releases
extendify / src / Library / pages / MainWindow.js

MainWindow.js in Extendify 1.6.1, at src/Library/pages/MainWindow.js

49 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useSelect, dispatch } from '@wordpress/data'
2 import { useRef, useLayoutEffect } from '@wordpress/element'
3 import { Dialog } from '@headlessui/react'
4 import { useModal } from '@library/hooks/useModal'
5 import { useGlobalStore } from '@library/state/GlobalState'
6 import { Layout } from './layout/Layout'
7
8 export default function MainWindow() {
9 const { open, setOpen, ready } = useGlobalStore()
10 const containerRef = useRef(null)
11 const modal = useModal(open)
12 const welcomeScreenOpen = useSelect((select) =>
13 select('core/edit-post')?.isFeatureActive('welcomeGuide'),
14 )
15
16 useLayoutEffect(() => {
17 if (!open) return
18 // Disable the welcome guide if open
19 if (welcomeScreenOpen) {
20 dispatch('core/edit-post').toggleFeature('welcomeGuide')
21 }
22 }, [open, welcomeScreenOpen])
23
24 return (
25 <Dialog
26 as="div"
27 className="extendify"
28 initialFocus={containerRef}
29 open={open}
30 onClose={() => undefined}>
31 <div className="fixed inset-0 bg-black bg-opacity-40 transition-opacity" />
32 <div className="fixed inset-0 z-high m-auto h-screen w-screen overflow-y-auto sm:h-auto sm:w-auto">
33 <div className="flex min-h-screen items-end justify-center px-4 pt-4 pb-20 text-center sm:block sm:p-0">
34 <div
35 ref={containerRef}
36 tabIndex="0"
37 onClick={(e) =>
38 e.target === e.currentTarget && setOpen(false)
39 }
40 className="fixed inset-0 transform p-2 transition-all lg:absolute lg:overflow-hidden lg:p-16">
41 <Layout />
42 {ready ? modal : null}
43 </div>
44 </div>
45 </div>
46 </Dialog>
47 )
48 }
49