diff --git a/packages/next/src/next-devtools/dev-overlay/components/devtools-indicator/devtools-indicator.tsx b/packages/next/src/next-devtools/dev-overlay/components/devtools-indicator/devtools-indicator.tsx index ec4524dc4588d..baa5dbd774c38 100644 --- a/packages/next/src/next-devtools/dev-overlay/components/devtools-indicator/devtools-indicator.tsx +++ b/packages/next/src/next-devtools/dev-overlay/components/devtools-indicator/devtools-indicator.tsx @@ -19,7 +19,7 @@ import { } from '../../shared' import { Draggable } from '../errors/dev-tools-indicator/draggable' -const INDICATOR_PADDING = 20 +export const INDICATOR_PADDING = 20 export function DevToolsIndicator({ state, @@ -59,6 +59,7 @@ export function DevToolsIndicator({ zIndex: 2147483647, [vertical]: `${INDICATOR_PADDING}px`, [horizontal]: `${INDICATOR_PADDING}px`, + visibility: state.isDevToolsPanelOpen ? 'hidden' : 'visible', } as CSSProperties } > diff --git a/packages/next/src/next-devtools/dev-overlay/components/devtools-panel/devtools-panel.tsx b/packages/next/src/next-devtools/dev-overlay/components/devtools-panel/devtools-panel.tsx index e647c6b946bb3..fe0499a6cc670 100644 --- a/packages/next/src/next-devtools/dev-overlay/components/devtools-panel/devtools-panel.tsx +++ b/packages/next/src/next-devtools/dev-overlay/components/devtools-panel/devtools-panel.tsx @@ -2,34 +2,68 @@ import type { OverlayDispatch, OverlayState } from '../../shared' import { Dialog, DialogContent, DialogHeader, DialogBody } from '../dialog' import { Overlay } from '../overlay/overlay' -import { ACTION_DEVTOOLS_PANEL_TOGGLE } from '../../shared' +import { + ACTION_DEVTOOLS_PANEL_CLOSE, + ACTION_DEVTOOLS_POSITION, + STORAGE_KEY_POSITION, +} from '../../shared' import { css } from '../../utils/css' +import { OverlayBackdrop } from '../overlay' +import { Draggable } from '../errors/dev-tools-indicator/draggable' +import { INDICATOR_PADDING } from '../devtools-indicator/devtools-indicator' export function DevToolsPanel({ - // eslint-disable-next-line @typescript-eslint/no-unused-vars state, dispatch, }: { state: OverlayState dispatch: OverlayDispatch }) { + const [vertical, horizontal] = state.devToolsPosition.split('-', 2) + const onClose = () => { - dispatch({ type: ACTION_DEVTOOLS_PANEL_TOGGLE }) + dispatch({ type: ACTION_DEVTOOLS_PANEL_CLOSE }) } return ( - - + {/* TODO: Investigate why onClose on Dialog doesn't close when clicked outside. */} + + {}} + position={state.devToolsPosition} + setPosition={(p) => { + localStorage.setItem(STORAGE_KEY_POSITION, p) + dispatch({ + type: ACTION_DEVTOOLS_POSITION, + devToolsPosition: p, + }) + }} > - - - - - + + + + + + + ) } @@ -37,7 +71,14 @@ export function DevToolsPanel({ export const DEVTOOLS_PANEL_STYLES = css` [data-nextjs-devtools-panel-overlay] { padding: initial; - top: 10vh; + margin: auto; + /* TODO: This is for fullscreen mode. */ + /* top: 10vh; */ + } + + [data-nextjs-devtools-panel-overlay-backdrop] { + /* TODO: Blur on fullscreen mode. */ + opacity: 0; } [data-nextjs-devtools-panel-dialog] { diff --git a/packages/next/src/next-devtools/dev-overlay/components/dialog/dialog.tsx b/packages/next/src/next-devtools/dev-overlay/components/dialog/dialog.tsx index a63c2878c6b3a..13d0968a544be 100644 --- a/packages/next/src/next-devtools/dev-overlay/components/dialog/dialog.tsx +++ b/packages/next/src/next-devtools/dev-overlay/components/dialog/dialog.tsx @@ -16,6 +16,7 @@ const CSS_SELECTORS_TO_EXCLUDE_ON_CLICK_OUTSIDE = [ '#nextjs-dev-tools-menu', '[data-nextjs-error-overlay-nav]', '[data-info-popover]', + '[data-nextjs-devtools-panel-overlay]', ] const Dialog: React.FC = function Dialog({ diff --git a/packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator/draggable.tsx b/packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator/draggable.tsx index 427fc907ee7ef..c2d1253d93ffe 100644 --- a/packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator/draggable.tsx +++ b/packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator/draggable.tsx @@ -1,3 +1,4 @@ +import type { Corners } from '../../../shared' import { useRef } from 'react' interface Point { @@ -5,8 +6,6 @@ interface Point { y: number } -type Corners = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' - interface Corner { corner: Corners translation: Point diff --git a/packages/next/src/next-devtools/dev-overlay/components/overlay/overlay.tsx b/packages/next/src/next-devtools/dev-overlay/components/overlay/overlay.tsx index af79cca04d0d3..da11c680e8b9f 100644 --- a/packages/next/src/next-devtools/dev-overlay/components/overlay/overlay.tsx +++ b/packages/next/src/next-devtools/dev-overlay/components/overlay/overlay.tsx @@ -1,9 +1,7 @@ import * as React from 'react' import { lock, unlock } from './body-locker' -export type OverlayProps = { - children?: React.ReactNode - className?: string +export type OverlayProps = React.HTMLAttributes & { fixed?: boolean }