Skip to content

Commit 8927fbb

Browse files
committed
[devtools] add fullscreen mode
1 parent bc831bb commit 8927fbb

File tree

2 files changed

+49
-14
lines changed

2 files changed

+49
-14
lines changed

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

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { Draggable } from '../errors/dev-tools-indicator/draggable'
2121
import { INDICATOR_PADDING } from '../devtools-indicator/devtools-indicator'
2222
import { FullScreenIcon } from '../../icons/fullscreen'
2323
import { Cross } from '../../icons/cross'
24+
import { MinimizeIcon } from '../../icons/minimize'
2425

2526
export type DevToolsPanelTabType = 'issues' | 'route' | 'settings'
2627

@@ -38,6 +39,7 @@ export function DevToolsPanel({
3839
getSquashedHydrationErrorDetails: (error: Error) => HydrationErrorState | null
3940
}) {
4041
const [activeTab, setActiveTab] = useState<DevToolsPanelTabType>('issues')
42+
const [isFullscreen, setIsFullscreen] = useState(false)
4143
const [vertical, horizontal] = state.devToolsPosition.split('-', 2)
4244

4345
const onCloseDevToolsPanel = () => {
@@ -60,19 +62,27 @@ export function DevToolsPanel({
6062
localStorage.setItem(STORAGE_KEY_SCALE, e.target.value)
6163
}
6264

65+
const handleFullscreenToggle = () => {
66+
setIsFullscreen((prev) => !prev)
67+
}
68+
6369
return (
6470
<Overlay
6571
data-nextjs-devtools-panel-overlay
66-
style={{
67-
[vertical]: `${INDICATOR_PADDING}px`,
68-
[horizontal]: `${INDICATOR_PADDING}px`,
69-
[vertical === 'top' ? 'bottom' : 'top']: 'auto',
70-
[horizontal === 'left' ? 'right' : 'left']: 'auto',
71-
}}
72+
style={
73+
!isFullscreen
74+
? {
75+
[vertical]: `${INDICATOR_PADDING}px`,
76+
[horizontal]: `${INDICATOR_PADDING}px`,
77+
[vertical === 'top' ? 'bottom' : 'top']: 'auto',
78+
[horizontal === 'left' ? 'right' : 'left']: 'auto',
79+
}
80+
: {}
81+
}
7282
>
7383
{/* TODO: Investigate why onCloseDevToolsPanel on Dialog doesn't close when clicked outside. */}
7484
<OverlayBackdrop
75-
data-nextjs-devtools-panel-overlay-backdrop
85+
data-nextjs-devtools-panel-overlay-backdrop={isFullscreen}
7686
onClick={onCloseDevToolsPanel}
7787
/>
7888
<Draggable
@@ -128,9 +138,15 @@ export function DevToolsPanel({
128138
</button>
129139
</div>
130140
<div data-nextjs-devtools-panel-header-action-button-group>
131-
{/* TODO: Currently no-op, will add fullscreen toggle. */}
132-
<button data-nextjs-devtools-panel-header-action-button>
133-
<FullScreenIcon width={16} height={16} />
141+
<button
142+
data-nextjs-devtools-panel-header-action-button
143+
onClick={handleFullscreenToggle}
144+
>
145+
{isFullscreen ? (
146+
<MinimizeIcon width={16} height={16} />
147+
) : (
148+
<FullScreenIcon width={16} height={16} />
149+
)}
134150
</button>
135151
<button
136152
data-nextjs-devtools-panel-header-action-button
@@ -212,11 +228,8 @@ export const DEVTOOLS_PANEL_STYLES = css`
212228
}
213229
214230
[data-nextjs-devtools-panel-overlay] {
215-
padding: initial;
216231
margin: auto;
217232
width: 100%;
218-
/* TODO: This is for fullscreen mode. */
219-
/* top: 10vh; */
220233
221234
@media (max-width: 575px) {
222235
left: 20px !important;
@@ -238,10 +251,13 @@ export const DEVTOOLS_PANEL_STYLES = css`
238251
}
239252
240253
[data-nextjs-devtools-panel-overlay-backdrop] {
241-
/* TODO: Blur on fullscreen mode. */
242254
opacity: 0;
243255
}
244256
257+
[data-nextjs-devtools-panel-overlay-backdrop='true'] {
258+
opacity: 1;
259+
}
260+
245261
[data-nextjs-devtools-panel-draggable] {
246262
/* For responsiveness */
247263
width: 100%;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export function MinimizeIcon(props: React.SVGProps<SVGSVGElement>) {
2+
return (
3+
<svg
4+
xmlns="http://www.w3.org/2000/svg"
5+
width="16"
6+
height="16"
7+
viewBox="0 0 16 16"
8+
fill="none"
9+
{...props}
10+
>
11+
<path
12+
fill-rule="evenodd"
13+
clip-rule="evenodd"
14+
d="M1 6V4.5H4.5V1H6V5C6 5.55228 5.55228 6 5 6H1ZM11.5 1H10V5C10 5.55228 10.4477 6 11 6H15V4.5H11.5V1ZM15.04 11.5V10H11C10.4477 10 10 10.4477 10 11V15H11.5V11.5H15.04ZM4.5 15H6V11C6 10.4477 5.55228 10 5 10H1V11.5H4.5V15Z"
15+
fill="currentColor"
16+
/>
17+
</svg>
18+
)
19+
}

0 commit comments

Comments
 (0)