Skip to content

Commit 3a57d50

Browse files
committed
sync with origin
1 parent a362b34 commit 3a57d50

File tree

5 files changed

+61
-21
lines changed

5 files changed

+61
-21
lines changed

packages/next/src/next-devtools/dev-overlay/components/devtools-indicator/devtools-indicator.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
} from '../../shared'
2020
import { Draggable } from '../errors/dev-tools-indicator/draggable'
2121

22-
const INDICATOR_PADDING = 20
22+
export const INDICATOR_PADDING = 20
2323

2424
export function DevToolsIndicator({
2525
state,
@@ -59,6 +59,7 @@ export function DevToolsIndicator({
5959
zIndex: 2147483647,
6060
[vertical]: `${INDICATOR_PADDING}px`,
6161
[horizontal]: `${INDICATOR_PADDING}px`,
62+
visibility: state.isDevToolsPanelOpen ? 'hidden' : 'visible',
6263
} as CSSProperties
6364
}
6465
>

packages/next/src/next-devtools/dev-overlay/components/devtools-panel/devtools-panel.tsx

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,83 @@ import type { OverlayDispatch, OverlayState } from '../../shared'
22

33
import { Dialog, DialogContent, DialogHeader, DialogBody } from '../dialog'
44
import { Overlay } from '../overlay/overlay'
5-
import { ACTION_DEVTOOLS_PANEL_TOGGLE } from '../../shared'
5+
import {
6+
ACTION_DEVTOOLS_PANEL_CLOSE,
7+
ACTION_DEVTOOLS_POSITION,
8+
STORAGE_KEY_POSITION,
9+
} from '../../shared'
610
import { css } from '../../utils/css'
11+
import { OverlayBackdrop } from '../overlay'
12+
import { Draggable } from '../errors/dev-tools-indicator/draggable'
13+
import { INDICATOR_PADDING } from '../devtools-indicator/devtools-indicator'
714

815
export function DevToolsPanel({
9-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1016
state,
1117
dispatch,
1218
}: {
1319
state: OverlayState
1420
dispatch: OverlayDispatch
1521
}) {
22+
const [vertical, horizontal] = state.devToolsPosition.split('-', 2)
23+
1624
const onClose = () => {
17-
dispatch({ type: ACTION_DEVTOOLS_PANEL_TOGGLE })
25+
dispatch({ type: ACTION_DEVTOOLS_PANEL_CLOSE })
1826
}
1927

2028
return (
21-
<Overlay data-nextjs-devtools-panel-overlay>
22-
<Dialog
23-
data-nextjs-devtools-panel-dialog
24-
aria-labelledby="nextjs__container_dev_tools_panel_label"
25-
aria-describedby="nextjs__container_dev_tools_panel_desc"
26-
onClose={onClose}
29+
<Overlay
30+
data-nextjs-devtools-panel-overlay
31+
style={{
32+
[vertical]: `${INDICATOR_PADDING}px`,
33+
[horizontal]: `${INDICATOR_PADDING}px`,
34+
[vertical === 'top' ? 'bottom' : 'top']: 'auto',
35+
[horizontal === 'left' ? 'right' : 'left']: 'auto',
36+
}}
37+
>
38+
{/* TODO: Investigate why onClose on Dialog doesn't close when clicked outside. */}
39+
<OverlayBackdrop
40+
data-nextjs-devtools-panel-overlay-backdrop
41+
onClick={onClose}
42+
/>
43+
<Draggable
44+
padding={INDICATOR_PADDING}
45+
onDragStart={() => {}}
46+
position={state.devToolsPosition}
47+
setPosition={(p) => {
48+
localStorage.setItem(STORAGE_KEY_POSITION, p)
49+
dispatch({
50+
type: ACTION_DEVTOOLS_POSITION,
51+
devToolsPosition: p,
52+
})
53+
}}
2754
>
28-
<DialogContent>
29-
<DialogHeader></DialogHeader>
30-
<DialogBody></DialogBody>
31-
</DialogContent>
32-
</Dialog>
55+
<Dialog
56+
data-nextjs-devtools-panel-dialog
57+
aria-labelledby="nextjs__container_dev_tools_panel_label"
58+
aria-describedby="nextjs__container_dev_tools_panel_desc"
59+
onClose={onClose}
60+
>
61+
<DialogContent>
62+
<DialogHeader></DialogHeader>
63+
<DialogBody></DialogBody>
64+
</DialogContent>
65+
</Dialog>
66+
</Draggable>
3367
</Overlay>
3468
)
3569
}
3670

3771
export const DEVTOOLS_PANEL_STYLES = css`
3872
[data-nextjs-devtools-panel-overlay] {
3973
padding: initial;
40-
top: 10vh;
74+
margin: auto;
75+
/* TODO: This is for fullscreen mode. */
76+
/* top: 10vh; */
77+
}
78+
79+
[data-nextjs-devtools-panel-overlay-backdrop] {
80+
/* TODO: Blur on fullscreen mode. */
81+
opacity: 0;
4182
}
4283
4384
[data-nextjs-devtools-panel-dialog] {

packages/next/src/next-devtools/dev-overlay/components/dialog/dialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const CSS_SELECTORS_TO_EXCLUDE_ON_CLICK_OUTSIDE = [
1616
'#nextjs-dev-tools-menu',
1717
'[data-nextjs-error-overlay-nav]',
1818
'[data-info-popover]',
19+
'[data-nextjs-devtools-panel-overlay]',
1920
]
2021

2122
const Dialog: React.FC<DialogProps> = function Dialog({

packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator/draggable.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
import type { Corners } from '../../../shared'
12
import { useRef } from 'react'
23

34
interface Point {
45
x: number
56
y: number
67
}
78

8-
type Corners = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
9-
109
interface Corner {
1110
corner: Corners
1211
translation: Point

packages/next/src/next-devtools/dev-overlay/components/overlay/overlay.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import * as React from 'react'
22
import { lock, unlock } from './body-locker'
33

4-
export type OverlayProps = {
5-
children?: React.ReactNode
6-
className?: string
4+
export type OverlayProps = React.HTMLAttributes<HTMLDivElement> & {
75
fixed?: boolean
86
}
97

0 commit comments

Comments
 (0)