Skip to content

Commit 27dbb9d

Browse files
authored
fix(nimbus): make boolean text more visible in dark mode in codemirror windows (#13596)
Because - Some text (particularily boolean fields) wasn't visible in dark mode in any codemirror sections This commit - Improves the visibility of the text in dark mode Fixes #13594
1 parent f7a9402 commit 27dbb9d

File tree

4 files changed

+594
-218
lines changed

4 files changed

+594
-218
lines changed

experimenter/experimenter/nimbus_ui/static/js/branch_detail.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
import { basicSetup } from "codemirror";
2-
import { EditorView } from "@codemirror/view";
1+
import {
2+
drawSelection,
3+
EditorView,
4+
highlightSpecialChars,
5+
lineNumbers,
6+
} from "@codemirror/view";
37
import { EditorState } from "@codemirror/state";
48
import { json, jsonParseLinter } from "@codemirror/lang-json";
59
import { linter } from "@codemirror/lint";
10+
import {
11+
HighlightStyle,
12+
syntaxHighlighting,
13+
defaultHighlightStyle,
14+
foldGutter,
15+
} from "@codemirror/language";
16+
import { tags } from "@lezer/highlight";
617

718
import $ from "jquery";
819

@@ -12,11 +23,20 @@ const setupCodemirroReadOnlyJSON = () => {
1223
const selector = ".readonly-json";
1324
const textareas = document.querySelectorAll(selector);
1425

26+
const highlightStyle = HighlightStyle.define([
27+
{ tag: tags.bool, color: "#ffaa00ff", themeType: "dark" },
28+
]);
29+
1530
textareas.forEach((textarea) => {
1631
if (textarea.dataset.is_rendered) return;
1732
textarea.dataset.is_rendered = true;
1833
const extensions = [
19-
basicSetup,
34+
lineNumbers(),
35+
drawSelection(),
36+
highlightSpecialChars(),
37+
foldGutter(),
38+
syntaxHighlighting(highlightStyle),
39+
syntaxHighlighting(defaultHighlightStyle),
2040
json(),
2141
linter(jsonParseLinter()),
2242
EditorState.readOnly.of(true),

experimenter/experimenter/nimbus_ui/static/js/edit_branches.js

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
1-
import { basicSetup } from "codemirror";
2-
import { EditorView } from "@codemirror/view";
1+
import {
2+
drawSelection,
3+
EditorView,
4+
highlightActiveLine,
5+
highlightSpecialChars,
6+
keymap,
7+
lineNumbers,
8+
} from "@codemirror/view";
39
import { json, jsonParseLinter } from "@codemirror/lang-json";
410
import { linter } from "@codemirror/lint";
5-
import { autocompletion } from "@codemirror/autocomplete";
11+
import { autocompletion, closeBrackets } from "@codemirror/autocomplete";
12+
import {
13+
HighlightStyle,
14+
syntaxHighlighting,
15+
defaultHighlightStyle,
16+
foldGutter,
17+
bracketMatching,
18+
indentOnInput,
19+
} from "@codemirror/language";
20+
import {
21+
highlightSelectionMatches,
22+
searchKeymap,
23+
search,
24+
} from "@codemirror/search";
25+
import { defaultKeymap, historyKeymap, history } from "@codemirror/commands";
26+
import { tags } from "@lezer/highlight";
627
import { schemaAutocomplete, schemaLinter } from "./validator.js";
728
import $ from "jquery";
829

@@ -12,8 +33,26 @@ const setupCodemirror = (selector, textarea, extraExtensions) => {
1233
return;
1334
}
1435

36+
const highlightStyle = HighlightStyle.define([
37+
{ tag: tags.bool, color: "#ffaa00ff", themeType: "dark" },
38+
]);
39+
1540
const extensions = [
16-
basicSetup,
41+
lineNumbers(),
42+
drawSelection(),
43+
highlightSpecialChars(),
44+
foldGutter(),
45+
autocompletion(),
46+
bracketMatching(),
47+
closeBrackets(),
48+
highlightSelectionMatches(),
49+
indentOnInput(),
50+
highlightActiveLine(),
51+
syntaxHighlighting(highlightStyle),
52+
syntaxHighlighting(defaultHighlightStyle),
53+
history(),
54+
search(),
55+
keymap.of([...defaultKeymap, ...searchKeymap, ...historyKeymap]),
1756
EditorView.updateListener.of((v) => {
1857
if (v.docChanged) {
1958
const value = v.state.doc.toString();

experimenter/experimenter/nimbus_ui/static/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
},
1212
"dependencies": {
1313
"@fortawesome/fontawesome-free": "^6.5.2",
14+
"@lezer/highlight": "^1.2.2",
1415
"bootstrap": "^5.3.3",
1516
"bootstrap-select": "1.14.0-beta3",
1617
"codemirror": "^6.0.1",

0 commit comments

Comments
 (0)