Skip to content

Commit 9eccfdb

Browse files
committed
[devtool] optimize segement explorer tree view
1 parent cd156f9 commit 9eccfdb

File tree

1 file changed

+17
-82
lines changed

1 file changed

+17
-82
lines changed

packages/next/src/client/components/react-dev-overlay/ui/components/overview/segment-explorer.tsx

Lines changed: 17 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,6 @@ import {
99
} from '../../../../../../shared/lib/devtool/app-segment-tree'
1010
import type { Trie, TrieNode } from '../../../../../../shared/lib/devtool/trie'
1111

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-
5212
function PageSegmentTree({ tree }: { tree: Trie<SegmentNode> | undefined }) {
5313
if (!tree) {
5414
return null
@@ -63,6 +23,7 @@ function PageSegmentTree({ tree }: { tree: Trie<SegmentNode> | undefined }) {
6323
node={tree.getRoot()}
6424
level={0}
6525
segment=""
26+
parentSegment=""
6627
/>
6728
</div>
6829
)
@@ -71,11 +32,13 @@ function PageSegmentTree({ tree }: { tree: Trie<SegmentNode> | undefined }) {
7132
function PageSegmentTreeLayerPresentation({
7233
tree,
7334
segment,
35+
parentSegment,
7436
node,
7537
level,
7638
}: {
7739
tree: Trie<SegmentNode>
7840
segment: string
41+
parentSegment: string
7942
node: TrieNode<SegmentNode>
8043
level: number
8144
}) {
@@ -106,31 +69,14 @@ function PageSegmentTreeLayerPresentation({
10669
<div className={cx('segment-explorer-item-row')}>
10770
<div className="segment-explorer-line">
10871
<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}`
129-
)}
130-
></span>
131-
<span className="segment-explorer-filename-path">
132-
{`${segment}/`}
133-
</span>
72+
<div className="segment-explorer-filename">
73+
<span className="segment-explorer-filename--path">
74+
{parentSegment}
75+
</span>
76+
<span className="segment-explorer-filename--name">
77+
{fileName}
78+
</span>
79+
</div>
13480
</div>
13581
</div>
13682
</div>
@@ -147,6 +93,7 @@ function PageSegmentTreeLayerPresentation({
14793
<PageSegmentTreeLayerPresentation
14894
key={childSegment}
14995
segment={childSegment}
96+
parentSegment={segment}
15097
tree={tree}
15198
node={child}
15299
level={level + 1}
@@ -189,35 +136,23 @@ export const DEV_TOOLS_INFO_RENDER_FILES_STYLES = css`
189136
}
190137
191138
[data-nextjs-devtool-segment-explorer-level].segment-explorer-segment-children {
192-
padding-left: 20px;
139+
padding-left: 16px;
193140
}
194141
[data-nextjs-devtool-segment-explorer-level='0'].segment-explorer-segment-children {
195142
padding-left: 0px;
196143
}
197144
198-
.segment-explorer-filename-path {
199-
display: inline-block;
200-
}
201-
202-
.segment-explorer-filename-path a {
203-
color: inherit;
204-
text-decoration: inherit;
145+
.segment-explorer-filename--name {
146+
margin-left: 8px;
147+
color: var(--color-gray-800);
205148
}
206149
207150
.segment-explorer-line {
208151
white-space: pre;
209152
cursor: default;
210153
}
211154
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 {
155+
.segment-explorer-line {
220156
color: var(--color-gray-1000);
221-
font-weight: 500;
222157
}
223158
`

0 commit comments

Comments
 (0)