Skip to content

Commit b881828

Browse files
committed
share devtools position for panel and indicator
1 parent 2be468c commit b881828

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
ACTION_ERROR_OVERLAY_CLOSE,
1616
STORAGE_KEY_POSITION,
1717
ACTION_DEVTOOLS_PANEL_CLOSE,
18-
ACTION_DEVTOOLS_INDICATOR_POSITION,
18+
ACTION_DEVTOOLS_POSITION,
1919
} from '../../shared'
2020
import { Draggable } from '../errors/dev-tools-indicator/draggable'
2121

@@ -36,7 +36,7 @@ export function DevToolsIndicator({
3636
}) {
3737
const [open, setOpen] = useState(false)
3838

39-
const [vertical, horizontal] = state.indicatorPosition.split('-', 2)
39+
const [vertical, horizontal] = state.devToolsPosition.split('-', 2)
4040

4141
const toggleErrorOverlay = () => {
4242
dispatch({ type: ACTION_DEVTOOLS_PANEL_CLOSE })
@@ -65,11 +65,11 @@ export function DevToolsIndicator({
6565
<Draggable
6666
padding={INDICATOR_PADDING}
6767
onDragStart={() => setOpen(false)}
68-
position={state.indicatorPosition}
68+
position={state.devToolsPosition}
6969
setPosition={(p) => {
7070
dispatch({
71-
type: ACTION_DEVTOOLS_INDICATOR_POSITION,
72-
indicatorPosition: p,
71+
type: ACTION_DEVTOOLS_POSITION,
72+
devToolsPosition: p,
7373
})
7474
localStorage.setItem(STORAGE_KEY_POSITION, p)
7575
}}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const state: OverlayState = {
6161
isErrorOverlayOpen: false,
6262
// TODO: This will be handled on the next stack——with proper story.
6363
isDevToolsPanelOpen: false,
64-
indicatorPosition: 'bottom-left',
64+
devToolsPosition: 'bottom-left',
6565
}
6666

6767
export const StaticRoute: Story = {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import imgApp from './app.png'
77
import { useReducer } from 'react'
88
import { DevOverlay } from './dev-overlay'
99
import {
10-
ACTION_DEVTOOLS_INDICATOR_POSITION,
10+
ACTION_DEVTOOLS_POSITION,
1111
ACTION_DEVTOOLS_PANEL_CLOSE,
1212
ACTION_DEVTOOLS_PANEL_TOGGLE,
1313
ACTION_ERROR_OVERLAY_CLOSE,
@@ -98,7 +98,7 @@ const initialState: OverlayState = {
9898
},
9999
isErrorOverlayOpen: false,
100100
isDevToolsPanelOpen: false,
101-
indicatorPosition: 'bottom-left',
101+
devToolsPosition: 'bottom-left',
102102
}
103103

104104
function useOverlayReducer() {
@@ -120,8 +120,8 @@ function useOverlayReducer() {
120120
case ACTION_DEVTOOLS_PANEL_CLOSE: {
121121
return { ...state, isDevToolsPanelOpen: false }
122122
}
123-
case ACTION_DEVTOOLS_INDICATOR_POSITION: {
124-
return { ...state, indicatorPosition: action.indicatorPosition }
123+
case ACTION_DEVTOOLS_POSITION: {
124+
return { ...state, devToolsPosition: action.devToolsPosition }
125125
}
126126
default: {
127127
return state

packages/next/src/next-devtools/dev-overlay/shared.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface OverlayState {
3030
routerType: 'pages' | 'app'
3131
isErrorOverlayOpen: boolean
3232
isDevToolsPanelOpen: boolean
33-
indicatorPosition: Corners
33+
devToolsPosition: Corners
3434
}
3535
export type OverlayDispatch = React.Dispatch<DispatcherEvent>
3636

@@ -58,7 +58,7 @@ export const ACTION_DEVTOOLS_PANEL_OPEN = 'devtools-panel-open'
5858
export const ACTION_DEVTOOLS_PANEL_CLOSE = 'devtools-panel-close'
5959
export const ACTION_DEVTOOLS_PANEL_TOGGLE = 'devtools-panel-toggle'
6060

61-
export const ACTION_DEVTOOLS_INDICATOR_POSITION = 'devtools-indicator-position'
61+
export const ACTION_DEVTOOLS_POSITION = 'devtools-position'
6262

6363
export const STORAGE_KEY_THEME = '__nextjs-dev-tools-theme'
6464
export const STORAGE_KEY_POSITION = '__nextjs-dev-tools-position'
@@ -142,8 +142,8 @@ export interface DevToolsPanelToggleAction {
142142
}
143143

144144
export interface DevToolsIndicatorPositionAction {
145-
type: typeof ACTION_DEVTOOLS_INDICATOR_POSITION
146-
indicatorPosition: Corners
145+
type: typeof ACTION_DEVTOOLS_POSITION
146+
devToolsPosition: Corners
147147
}
148148

149149
export type DispatcherEvent =
@@ -207,7 +207,7 @@ export const INITIAL_OVERLAY_STATE: Omit<
207207
versionInfo: { installed: '0.0.0', staleness: 'unknown' },
208208
debugInfo: { devtoolsFrontendUrl: undefined },
209209
isDevToolsPanelOpen: false,
210-
indicatorPosition: 'bottom-left',
210+
devToolsPosition: 'bottom-left',
211211
}
212212

213213
function getInitialState(
@@ -379,8 +379,8 @@ export function useErrorOverlayReducer(
379379
case ACTION_DEVTOOLS_PANEL_TOGGLE: {
380380
return { ...state, isDevToolsPanelOpen: !state.isDevToolsPanelOpen }
381381
}
382-
case ACTION_DEVTOOLS_INDICATOR_POSITION: {
383-
return { ...state, indicatorPosition: action.indicatorPosition }
382+
case ACTION_DEVTOOLS_POSITION: {
383+
return { ...state, devToolsPosition: action.devToolsPosition }
384384
}
385385
default: {
386386
return state

0 commit comments

Comments
 (0)