@@ -9,46 +9,6 @@ import {
9
9
} from '../../../../../../shared/lib/devtool/app-segment-tree'
10
10
import type { Trie , TrieNode } from '../../../../../../shared/lib/devtool/trie'
11
11
12
- const IconLayout = ( props : React . SVGProps < SVGSVGElement > ) => {
13
- return (
14
- < svg
15
- { ...props }
16
- viewBox = "0 0 16 16"
17
- fill = "none"
18
- xmlns = "http://www.w3.org/2000/svg"
19
- >
20
- < path
21
- d = "M16 12.5L15.9873 12.7559C15.8677 13.9323 14.9323 14.8677 13.7559 14.9873L13.5 15H2.5L2.24414 14.9873C1.06772 14.8677 0.132274 13.9323 0.0126953 12.7559L0 12.5V1H16V12.5ZM1.5 6.25488V12.5C1.5 13.0523 1.94772 13.5 2.5 13.5H4.99512V6.25488H1.5ZM6.24512 6.25488V13.5H13.5C14.0523 13.5 14.5 13.0523 14.5 12.5V6.25488H6.24512ZM1.5 5.00488H14.5V2.5H1.5V5.00488Z"
22
- fill = "currentColor"
23
- />
24
- </ svg >
25
- )
26
- }
27
-
28
- const IconPage = ( props : React . SVGProps < SVGSVGElement > ) => {
29
- return (
30
- < svg
31
- { ...props }
32
- viewBox = "0 0 16 16"
33
- fill = "none"
34
- strokeLinejoin = "round"
35
- xmlns = "http://www.w3.org/2000/svg"
36
- >
37
- < path
38
- fillRule = "evenodd"
39
- clipRule = "evenodd"
40
- d = "M14.5 6.5V13.5C14.5 14.8807 13.3807 16 12 16H4C2.61929 16 1.5 14.8807 1.5 13.5V1.5V0H3H8H9.08579C9.351 0 9.60536 0.105357 9.79289 0.292893L14.2071 4.70711C14.3946 4.89464 14.5 5.149 14.5 5.41421V6.5ZM13 6.5V13.5C13 14.0523 12.5523 14.5 12 14.5H4C3.44772 14.5 3 14.0523 3 13.5V1.5H8V5V6.5H9.5H13ZM9.5 2.12132V5H12.3787L9.5 2.12132Z"
41
- fill = "currentColor"
42
- />
43
- </ svg >
44
- )
45
- }
46
-
47
- const ICONS = {
48
- layout : < IconLayout width = { 16 } /> ,
49
- page : < IconPage width = { 16 } /> ,
50
- }
51
-
52
12
function PageSegmentTree ( { tree } : { tree : Trie < SegmentNode > | undefined } ) {
53
13
if ( ! tree ) {
54
14
return null
@@ -63,6 +23,7 @@ function PageSegmentTree({ tree }: { tree: Trie<SegmentNode> | undefined }) {
63
23
node = { tree . getRoot ( ) }
64
24
level = { 0 }
65
25
segment = ""
26
+ parentSegment = ""
66
27
/>
67
28
</ div >
68
29
)
@@ -71,11 +32,13 @@ function PageSegmentTree({ tree }: { tree: Trie<SegmentNode> | undefined }) {
71
32
function PageSegmentTreeLayerPresentation ( {
72
33
tree,
73
34
segment,
35
+ parentSegment,
74
36
node,
75
37
level,
76
38
} : {
77
39
tree : Trie < SegmentNode >
78
40
segment : string
41
+ parentSegment : string
79
42
node : TrieNode < SegmentNode >
80
43
level : number
81
44
} ) {
@@ -97,6 +60,12 @@ function PageSegmentTreeLayerPresentation({
97
60
return a . localeCompare ( b )
98
61
} )
99
62
63
+ // check if it has file children
64
+ const hasFileChildren = sortedChildrenKeys . some ( ( key ) => {
65
+ const childNode = node . children [ key ]
66
+ return ! ! childNode ?. value ?. type
67
+ } )
68
+
100
69
return (
101
70
< div
102
71
className = "segment-explorer-item"
@@ -106,38 +75,28 @@ function PageSegmentTreeLayerPresentation({
106
75
< div className = { cx ( 'segment-explorer-item-row' ) } >
107
76
< div className = "segment-explorer-line" >
108
77
< div className = { `segment-explorer-line-text-${ nodeName } ` } >
109
- < span
110
- className = { cx (
111
- 'segment-explorer-line-icon' ,
112
- `segment-explorer-line-icon-${ nodeName } `
113
- ) }
114
- >
115
- { nodeName === 'layout' ? ICONS . layout : ICONS . page }
116
- </ span >
117
- < span className = "segment-explorer-filename-path" > { fileName } </ span >
118
- </ div >
119
- </ div >
120
- </ div >
121
- ) : segment ? (
122
- < div className = { 'segment-explorer-item-row' } >
123
- < div className = "segment-explorer-line" >
124
- < div className = { `segment-explorer-line-text-${ nodeName } ` } >
125
- < span
126
- className = { cx (
127
- 'segment-explorer-line-icon' ,
128
- `segment-explorer-line-icon-${ nodeName } `
78
+ < div className = "segment-explorer-filename" >
79
+ { parentSegment && (
80
+ < span className = "segment-explorer-filename--path" >
81
+ { parentSegment }
82
+ </ span >
129
83
) }
130
- > </ span >
131
- < span className = "segment-explorer-filename-path" >
132
- { ` ${ segment } /` }
133
- </ span >
84
+ < span className = "segment-explorer-filename--name" >
85
+ { fileName }
86
+ </ span >
87
+ </ div >
134
88
</ div >
135
89
</ div >
136
90
</ div >
137
91
) : null }
138
92
139
93
< div
140
- className = "segment-explorer-segment-children"
94
+ className = { cx (
95
+ 'segment-explorer-children' ,
96
+ // If it's children levels, show indents if there's any file at that level.
97
+ // Otherwise it's empty folder, no need to show indents.
98
+ level > 0 && hasFileChildren && 'segment-explorer-children--intended'
99
+ ) }
141
100
data-nextjs-devtool-segment-explorer-level = { level }
142
101
>
143
102
{ sortedChildrenKeys . map ( ( childSegment ) => {
@@ -147,6 +106,7 @@ function PageSegmentTreeLayerPresentation({
147
106
< PageSegmentTreeLayerPresentation
148
107
key = { childSegment }
149
108
segment = { childSegment }
109
+ parentSegment = { segment }
150
110
tree = { tree }
151
111
node = { child }
152
112
level = { level + 1 }
@@ -188,36 +148,23 @@ export const DEV_TOOLS_INFO_RENDER_FILES_STYLES = css`
188
148
padding : 2px 0 ;
189
149
}
190
150
191
- [data-nextjs-devtool-segment-explorer-level ].segment-explorer-segment-children {
192
- padding-left : 20px ;
193
- }
194
- [data-nextjs-devtool-segment-explorer-level = '0' ].segment-explorer-segment-children {
195
- padding-left : 0px ;
151
+ .segment-explorer-children--intended {
152
+ padding-left : 16px ;
196
153
}
197
154
198
- .segment-explorer-filename-path {
199
- display : inline-block ;
155
+ .segment-explorer-filename-- path {
156
+ margin-right : 8 px ;
200
157
}
201
-
202
- .segment-explorer-filename-path a {
203
- color : inherit;
204
- text-decoration : inherit;
158
+ .segment-explorer-filename--name {
159
+ color : var (--color-gray-800 );
205
160
}
206
161
207
162
.segment-explorer-line {
208
163
white-space : pre;
209
164
cursor : default;
210
165
}
211
166
212
- .segment-explorer-line-icon {
213
- margin-right : 4px ;
214
- }
215
- .segment-explorer-line-icon-page {
216
- color : inherit;
217
- }
218
-
219
- .segment-explorer-line-text-page {
167
+ .segment-explorer-line {
220
168
color : var (--color-gray-1000 );
221
- font-weight : 500 ;
222
169
}
223
170
`
0 commit comments