|
1 |
| -export function DevToolsPanel() { |
2 |
| - // TODO: Remove style; It is to indicate faster in the browser. |
3 |
| - return <div className="text-black">DevToolsPanel</div> |
| 1 | +import type { OverlayDispatch, OverlayState } from '../../shared' |
| 2 | + |
| 3 | +import { Suspense, useRef } from 'react' |
| 4 | +import { Dialog, DialogContent, DialogHeader, DialogBody } from '../dialog' |
| 5 | +import { Overlay } from '../overlay/overlay' |
| 6 | +import { useFocusTrap } from '../errors/dev-tools-indicator/utils' |
| 7 | +import { useDelayedRender } from '../../hooks/use-delayed-render' |
| 8 | +import { ACTION_DEV_TOOLS_PANEL_TOGGLE } from '../../shared' |
| 9 | + |
| 10 | +export function DevToolsPanel({ |
| 11 | + state, |
| 12 | + dispatch, |
| 13 | +}: { |
| 14 | + state: OverlayState |
| 15 | + dispatch: OverlayDispatch |
| 16 | +}) { |
| 17 | + const dialogRef = useRef<HTMLDivElement>(null) |
| 18 | + |
| 19 | + // This hook lets us do an exit animation before unmounting the component |
| 20 | + const { mounted, rendered } = useDelayedRender(state.isDevToolsPanelOpen) |
| 21 | + |
| 22 | + useFocusTrap(dialogRef, null, rendered) |
| 23 | + |
| 24 | + if (!mounted) { |
| 25 | + // Workaround React quirk that triggers "Switch to client-side rendering" if |
| 26 | + // we return no Suspense boundary here. |
| 27 | + return <Suspense /> |
| 28 | + } |
| 29 | + |
| 30 | + const onClose = () => { |
| 31 | + dispatch({ type: ACTION_DEV_TOOLS_PANEL_TOGGLE }) |
| 32 | + } |
| 33 | + |
| 34 | + return ( |
| 35 | + <Overlay className="p-0 top-[10vh]"> |
| 36 | + <div |
| 37 | + className="dev-tools-panel-dialog-container antialiased flex flex-col bg-[var(--color-background-100)] bg-clip-padding border-solid border-[var(--color-gray-400)] rounded-b-[var(--next-dialog-radius)] shadow-[var(--shadow-menu)] relative overflow-hidden min-w-[800px] min-h-[500px]" |
| 38 | + ref={dialogRef} |
| 39 | + > |
| 40 | + <Dialog |
| 41 | + aria-labelledby="nextjs__container_dev_tools_panel_label" |
| 42 | + aria-describedby="nextjs__container_dev_tools_panel_desc" |
| 43 | + className="dev-tools-panel-dialog-scroll overflow-y-auto h-full" |
| 44 | + onClose={onClose} |
| 45 | + > |
| 46 | + <DialogContent> |
| 47 | + <DialogHeader></DialogHeader> |
| 48 | + <DialogBody> |
| 49 | + <div>DevToolsPanel</div> |
| 50 | + </DialogBody> |
| 51 | + </DialogContent> |
| 52 | + </Dialog> |
| 53 | + </div> |
| 54 | + </Overlay> |
| 55 | + ) |
4 | 56 | }
|
0 commit comments