| 1 |
import { useRef } from '@wordpress/element' |
| 2 |
import { Dialog } from '@headlessui/react' |
| 3 |
import FooterNotice from '@library/components/notices/FooterNotice' |
| 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 containerRef = useRef(null) |
| 10 |
const open = useGlobalStore((state) => state.open) |
| 11 |
const setOpen = useGlobalStore((state) => state.setOpen) |
| 12 |
const modal = useModal(open) |
| 13 |
const ready = useGlobalStore((state) => state.ready) |
| 14 |
|
| 15 |
return ( |
| 16 |
<Dialog |
| 17 |
as="div" |
| 18 |
className="extendify" |
| 19 |
initialFocus={containerRef} |
| 20 |
open={open} |
| 21 |
onClose={() => setOpen(false)}> |
| 22 |
<div className="fixed inset-0 bg-black bg-opacity-40 transition-opacity" /> |
| 23 |
<div className="fixed inset-0 z-high m-auto h-screen w-screen overflow-y-auto sm:h-auto sm:w-auto"> |
| 24 |
<div className="flex min-h-screen items-end justify-center px-4 pt-4 pb-20 text-center sm:block sm:p-0"> |
| 25 |
<div |
| 26 |
ref={containerRef} |
| 27 |
tabIndex="0" |
| 28 |
onClick={(e) => |
| 29 |
e.target === e.currentTarget && setOpen(false) |
| 30 |
} |
| 31 |
className="fixed inset-0 transform p-2 transition-all lg:absolute lg:overflow-hidden lg:p-16"> |
| 32 |
<Layout /> |
| 33 |
{ready ? ( |
| 34 |
<> |
| 35 |
<FooterNotice /> |
| 36 |
{modal} |
| 37 |
</> |
| 38 |
) : null} |
| 39 |
</div> |
| 40 |
</div> |
| 41 |
</div> |
| 42 |
</Dialog> |
| 43 |
) |
| 44 |
} |
| 45 |
|