Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
c2621a14
Unverified
Commit
c2621a14
authored
Jun 06, 2025
by
Jiachi Liu
Committed by
GitHub
Jun 06, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[devtool] style the segment explorer as nested view (#80212)
parent
ecf970a7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
18 deletions
+41
-18
segment-explorer.tsx
...t-dev-overlay/ui/components/overview/segment-explorer.tsx
+35
-12
segment-explorer.test.ts
...lopment/app-dir/segment-explorer/segment-explorer.test.ts
+6
-6
No files found.
packages/next/src/client/components/react-dev-overlay/ui/components/overview/segment-explorer.tsx
View file @
c2621a14
...
...
@@ -76,13 +76,33 @@ function PageSegmentTreeLayerPresentation({
node
:
TrieNode
<
SegmentNode
>
level
:
number
})
{
const
segments
=
node
.
value
?.
pagePath
?.
split
(
'/'
)
||
[]
const
fileName
=
segments
[
segments
.
length
-
1
]
||
''
const
pagePath
=
node
.
value
?.
pagePath
||
''
const
nodeName
=
node
.
value
?.
type
const
pagePathPrefix
=
segments
.
slice
(
0
,
-
1
).
join
(
'/'
)
const
segments
=
pagePath
.
split
(
'/'
)
||
[]
const
fileName
=
segments
.
pop
()
||
''
const
segmentPath
=
segments
.
join
(
'/'
)
let
pagePathPrefix
=
segmentPath
const
childrenKeys
=
Object
.
keys
(
node
.
children
).
sort
((
a
,
b
)
=>
{
// Prioritize if it's a file convention like layout or page,
// then the rest parallel routes.
const
aHasExt
=
a
.
includes
(
'.'
)
const
bHasExt
=
b
.
includes
(
'.'
)
if
(
aHasExt
&&
!
bHasExt
)
return
-
1
if
(
!
aHasExt
&&
bHasExt
)
return
1
// Otherwise sort alphabetically
return
a
.
localeCompare
(
b
)
})
return
(
<
div
className=
"segment-explorer-item"
>
<
div
className=
{
cx
(
'segment-explorer-item'
,
level
>
1
&&
'segment-explorer-item--nested'
)
}
>
{
!
fileName
||
level
===
0
?
null
:
(
<
div
className=
"segment-explorer-item-row"
>
<
div
className=
"segment-explorer-line"
>
...
...
@@ -103,17 +123,19 @@ function PageSegmentTreeLayerPresentation({
)
}
<
div
className=
"tree-node-expanded-rendered-children"
>
{
Object
.
entries
(
node
.
children
).
map
(
([
key
,
child
])
=>
{
childrenKeys
.
map
((
segment
)
=>
{
const
child
=
node
.
children
[
segment
]
return
(
child
&&
(
<
PageSegmentTreeLayerPresentation
key=
{
key
}
key=
{
segment
}
tree=
{
tree
}
node=
{
child
}
level=
{
level
+
1
}
/>
)
)
}
)
})
}
</
div
>
</
div
>
)
...
...
@@ -141,6 +163,10 @@ export const DEV_TOOLS_INFO_RENDER_FILES_STYLES = css`
font-size: var(--size-14);
}
.segment-explorer-item--nested {
padding-left: 20px;
}
.segment-explorer-item-row {
display: flex;
align-items: center;
...
...
@@ -168,12 +194,9 @@ export const DEV_TOOLS_INFO_RENDER_FILES_STYLES = css`
.segment-explorer-line-icon-page {
color: inherit;
}
.segment-explorer-line-icon-layout {
color: var(--color-gray-1-00);
}
.segment-explorer-line-text-page {
color: var(--color-
blue-9
00);
color: var(--color-
gray-10
00);
font-weight: 500;
}
`
test/development/app-dir/segment-explorer/segment-explorer.test.ts
View file @
c2621a14
...
...
@@ -22,13 +22,13 @@ describe('segment-explorer', () => {
'[data-nextjs-devtool-segment-explorer]'
)
expect
(
await
content
.
text
()).
toMatchInlineSnapshot
(
`
"app/parallel-routes/page.tsx
app/parallel-routes/@foo/page.tsx
app/parallel-routes/@foo/layout.tsx
app/parallel-routes/@bar/page.tsx
app/parallel-routes/@bar/layout.tsx
"app/layout.tsx
app/parallel-routes/layout.tsx
app/layout.tsx"
app/parallel-routes/page.tsx
app/parallel-routes/@bar/layout.tsx
app/parallel-routes/@bar/page.tsx
app/parallel-routes/@foo/layout.tsx
app/parallel-routes/@foo/page.tsx"
`
)
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment