Skip to content

Commit 074acf1

Browse files
authored
Merge pull request #12991 from CesiumGS/sandcastle-console-index
Prevent selecting console index in sandcastle
2 parents 8902897 + 51e3923 commit 074acf1

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

packages/sandcastle/src/ConsoleMirror.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,20 @@
2929
gap: var(--stratakit-space-x2);
3030
margin: var(--stratakit-space-x1);
3131
padding: var(--stratakit-space-x1) 0 var(--stratakit-space-x05);
32+
font-family: var(--stratakit-font-family-mono);
3233
}
3334
.message + .message {
3435
border-top: var(--stratakit-ext-border-border) solid
3536
var(--stratakit-color-border-neutral-muted);
3637
}
38+
.no-icon {
39+
/* "Filler" icon to take up the same space */
40+
width: 1rem;
41+
height: 1rem;
42+
}
43+
.message-index {
44+
user-select: none;
45+
}
3746
.content {
3847
text-wrap: wrap;
3948
}

packages/sandcastle/src/ConsoleMirror.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ export type ConsoleMessage = {
1313
id: string;
1414
};
1515

16+
function ConsoleIcon({ type }: { type: ConsoleMessageType }) {
17+
if (type === "error") {
18+
return <Icon href={statusError} />;
19+
}
20+
if (type === "warn") {
21+
return <Icon href={statusWarning} />;
22+
}
23+
return <div className="no-icon"></div>;
24+
}
25+
1626
export function ConsoleMirror({
1727
logs,
1828
expanded: consoleExpanded,
@@ -63,12 +73,6 @@ export function ConsoleMirror({
6373
</div>
6474
)}
6575
{logs.map((log, i) => {
66-
let icon = "";
67-
if (log.type === "warn") {
68-
icon = statusWarning;
69-
} else if (log.type === "error") {
70-
icon = statusError;
71-
}
7276
return (
7377
<div
7478
key={i}
@@ -77,10 +81,9 @@ export function ConsoleMirror({
7781
error: log.type === "error",
7882
})}
7983
>
80-
<Icon href={icon} />
81-
<pre className="content">
82-
{i + 1}: {log.message}
83-
</pre>
84+
<ConsoleIcon type={log.type} />
85+
<span className="message-index">{i + 1}:</span>
86+
<pre className="content">{log.message}</pre>
8487
</div>
8588
);
8689
})}

0 commit comments

Comments
 (0)