Skip to content

Commit 82659a4

Browse files
committed
Fix colon styling in trace panel
This prevents a non-italic colon immediately following the italic origin type if there's no label.
1 parent 3704cb4 commit 82659a4

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

packages/react-hook-tracer/src/components/TracePanel.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,18 @@ interface TraceOriginEntryProps {
9797
traceOrigin: TraceOrigin
9898
isHighlighted: boolean
9999
}
100-
const TraceOriginEntry = ({ traceOrigin, isHighlighted }: TraceOriginEntryProps) => (
101-
<div className="trace-origin" data-is-highlighted={isHighlighted} data-testid="trace-origin">
102-
<span className="origin-type">{traceOrigin.originType}</span>
103-
{traceOrigin.label && <span className="origin-label">{${traceOrigin.label}»`}</span>}
104-
{traceOrigin.info && ':'}
105-
{traceOrigin.info && <span className="origin-info">{traceOrigin.info}</span>}
106-
</div>
107-
)
100+
const TraceOriginEntry = ({ traceOrigin, isHighlighted }: TraceOriginEntryProps) => {
101+
const { originType, label, info } = traceOrigin
102+
103+
// To match the styles, the colon before info is added to typeStr if there's no label, and to labelStr if there is.
104+
const typeStr = `${originType}${info !== null && label === null ? ':' : ''}`
105+
const labelStr = ${label}»${info !== null ? ':' : ''}`
106+
107+
return (
108+
<div className="trace-origin" data-is-highlighted={isHighlighted} data-testid="trace-origin">
109+
<span className="origin-type">{typeStr}</span>
110+
{label !== null && <span className="origin-label">{labelStr}</span>}
111+
{info !== null && <span className="origin-info">{info}</span>}
112+
</div>
113+
)
114+
}

0 commit comments

Comments
 (0)