Skip to content

Commit 057fa60

Browse files
authored
Merge pull request #7 from OpenKnots/okcode/blank-screen-on-open
Blend CodeMirror viewer into app background
2 parents 06a0f31 + 147d744 commit 057fa60

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

apps/web/src/components/CodeMirrorViewer.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const baseExtensions: Extension[] = [
2727
"&": {
2828
height: "100%",
2929
fontSize: "12px",
30+
backgroundColor: "var(--background)",
3031
},
3132
".cm-scroller": {
3233
fontFamily: "ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace",
@@ -43,11 +44,29 @@ const baseExtensions: Extension[] = [
4344
opacity: "0.5",
4445
fontSize: "11px",
4546
},
47+
".cm-activeLine": {
48+
backgroundColor: "color-mix(in srgb, var(--accent) 30%, transparent)",
49+
},
50+
".cm-activeLineGutter": {
51+
backgroundColor: "transparent",
52+
},
4653
}),
4754
];
4855

56+
/** Use oneDark for syntax tokens but override its background so the editor
57+
* blends with the app's own dark surface colour (`var(--background)`). */
4958
function getThemeExtension(resolvedTheme: "light" | "dark"): Extension {
50-
return resolvedTheme === "dark" ? oneDark : [];
59+
if (resolvedTheme !== "dark") return [];
60+
return [
61+
oneDark,
62+
EditorView.theme(
63+
{
64+
"&.cm-editor": { backgroundColor: "var(--background)" },
65+
".cm-gutters": { backgroundColor: "transparent" },
66+
},
67+
{ dark: true },
68+
),
69+
];
5170
}
5271

5372
async function loadLanguageExtension(filePath: string): Promise<Extension> {

0 commit comments

Comments
 (0)