@@ -10,6 +10,14 @@ import { isConsoleError } from '../shared/console-error'
10
10
11
11
export type Corners = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
12
12
13
+ const BASE_SIZE = 16
14
+
15
+ export const NEXT_DEV_TOOLS_SCALE = {
16
+ Small : BASE_SIZE / 14 ,
17
+ Medium : BASE_SIZE / 16 ,
18
+ Large : BASE_SIZE / 18 ,
19
+ }
20
+
13
21
type FastRefreshState =
14
22
/** No refresh in progress. */
15
23
| { type : 'idle' }
@@ -33,6 +41,7 @@ export interface OverlayState {
33
41
isErrorOverlayOpen : boolean
34
42
isDevToolsPanelOpen : boolean
35
43
indicatorPosition : Corners
44
+ scale : number
36
45
}
37
46
export type OverlayDispatch = React . Dispatch < DispatcherEvent >
38
47
@@ -61,6 +70,7 @@ export const ACTION_DEVTOOLS_PANEL_CLOSE = 'devtools-panel-close'
61
70
export const ACTION_DEVTOOLS_PANEL_TOGGLE = 'devtools-panel-toggle'
62
71
63
72
export const ACTION_DEVTOOLS_INDICATOR_POSITION = 'devtools-indicator-position'
73
+ export const ACTION_DEVTOOLS_SCALE = 'devtools-scale'
64
74
65
75
export const STORAGE_KEY_THEME = '__nextjs-dev-tools-theme'
66
76
export const STORAGE_KEY_POSITION = '__nextjs-dev-tools-position'
@@ -150,6 +160,11 @@ export interface DevToolsIndicatorPositionAction {
150
160
indicatorPosition : Corners
151
161
}
152
162
163
+ export interface DevToolsScaleAction {
164
+ type : typeof ACTION_DEVTOOLS_SCALE
165
+ scale : number
166
+ }
167
+
153
168
export type DispatcherEvent =
154
169
| BuildOkAction
155
170
| BuildErrorAction
@@ -172,6 +187,7 @@ export type DispatcherEvent =
172
187
| DevToolsPanelCloseAction
173
188
| DevToolsPanelToggleAction
174
189
| DevToolsIndicatorPositionAction
190
+ | DevToolsScaleAction
175
191
176
192
const REACT_ERROR_STACK_BOTTOM_FRAME_REGEX =
177
193
// 1st group: v8
@@ -212,8 +228,12 @@ export const INITIAL_OVERLAY_STATE: Omit<
212
228
debugInfo : { devtoolsFrontendUrl : undefined } ,
213
229
isDevToolsPanelOpen : false ,
214
230
indicatorPosition :
215
- ( localStorage . getItem ( STORAGE_KEY_POSITION ) as DevToolsIndicatorPosition ) ??
231
+ ( localStorage . getItem ( STORAGE_KEY_POSITION ) as Corners ) ??
216
232
'bottom-left' ,
233
+ scale :
234
+ localStorage . getItem ( STORAGE_KEY_SCALE )
235
+ ? Number ( localStorage . getItem ( STORAGE_KEY_SCALE ) )
236
+ : NEXT_DEV_TOOLS_SCALE . Medium ,
217
237
}
218
238
219
239
function getInitialState (
@@ -388,6 +408,9 @@ export function useErrorOverlayReducer(
388
408
case ACTION_DEVTOOLS_INDICATOR_POSITION : {
389
409
return { ...state , indicatorPosition : action . indicatorPosition }
390
410
}
411
+ case ACTION_DEVTOOLS_SCALE : {
412
+ return { ...state , scale : action . scale }
413
+ }
391
414
default : {
392
415
return state
393
416
}
0 commit comments