Skip to content

Commit f58532d

Browse files
Merge pull request #354 from preactjs/profiler-hoc-styling
2 parents 11e2a2f + 424c067 commit f58532d

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

src/view/components/Devtools.module.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ input {
9595
--color-radio: #7245c7;
9696
--color-shadow: rgba(0, 0, 0, 0.15);
9797
--color-hoc-bg: #ddd;
98+
--color-hoc-not-rendered: #ddd;
9899
--color-hoc-text: #111;
99100
--color-hoc-selected-text: #fff;
100101
--color-hoc-selected-bg: #4101b3;
@@ -185,6 +186,7 @@ input {
185186
--color-radio: #d2adff;
186187
--color-shadow: rgba(255, 255, 255, 0.15);
187188
--color-hoc-bg: #505050;
189+
--color-hoc-not-rendered: black;
188190
--color-hoc-text: #fff;
189191
--color-hoc-selected-text: #fff;
190192
--color-hoc-selected-bg: #8251d8;

src/view/components/elements/TreeView.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,18 @@ export function TreeItem(props: { key: any; id: ID; top: number }) {
259259
export function HocLabels({
260260
hocs,
261261
nodeId,
262+
canMark = true,
262263
}: {
263264
hocs: string[];
264265
nodeId: number;
266+
canMark?: boolean;
265267
}) {
266268
return (
267269
<span class={s.hocs} data-testid="hoc-labels">
268270
{hocs.map((hoc, i) => {
269271
return (
270272
<Hoc key={i} small>
271-
<MarkResult text={hoc} id={nodeId} />
273+
{canMark ? <MarkResult text={hoc} id={nodeId} /> : hoc}
272274
</Hoc>
273275
);
274276
})}

src/view/components/profiler/flamegraph/FlameGraph.module.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@
6565
background-color: transparent;
6666
background-size: 0.25rem 0.25rem;
6767
}
68+
69+
.node[data-weight="-1"]:not([data-commit-parent])
70+
[data-testid="hoc-labels"]
71+
> * {
72+
background: var(--color-hoc-not-rendered);
73+
}
74+
6875
:global(.dark) .node[data-weight="-1"]:not([data-commit-parent])::after {
6976
opacity: 0.5;
7077
}

src/view/components/profiler/flamegraph/modes/FlamegraphLayout.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,24 @@ export function FlamegraphLayout({
4747
const node = commit.nodes.get(pos.id)!;
4848
let text: any = "";
4949
if (pos.commitParent || pos.weight === -1) {
50-
text = <span data-testid="node-name">{node.name}</span>;
50+
text = (
51+
<span data-testid="node-name">
52+
{node.name}
53+
{filterHoc && node.hocs ? (
54+
<HocLabels hocs={node.hocs} nodeId={node.id} canMark={false} />
55+
) : (
56+
""
57+
)}
58+
</span>
59+
);
5160
} else {
5261
const self = formatTime(commit.selfDurations.get(node.id)!);
5362
const total = formatTime(node.endTime - node.startTime);
5463
text = (
5564
<>
5665
<span data-testid="node-name">{node.name}</span>
5766
{filterHoc && node.hocs ? (
58-
<HocLabels hocs={node.hocs} nodeId={node.id} />
67+
<HocLabels hocs={node.hocs} nodeId={node.id} canMark={false} />
5968
) : (
6069
""
6170
)}{" "}

src/view/components/profiler/flamegraph/ranked/RankedLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function RankedLayout({
6262
const selfDuration = commit.selfDurations.get(node.id) || 0;
6363
const hocs =
6464
filterHoc && node.hocs ? (
65-
<HocLabels hocs={node.hocs} nodeId={node.id} />
65+
<HocLabels hocs={node.hocs} nodeId={node.id} canMark={false} />
6666
) : (
6767
""
6868
);

0 commit comments

Comments
 (0)