Skip to content

Commit 3f34f09

Browse files
silverwind6543
andauthored
Extract CodeMirror styles (#17960)
- Extract CodeMirror-related styles to separate files - Generalize CodeMirror styles where possible - Improve fullscreen and side-by-side mode for dark theme Co-authored-by: 6543 <[email protected]>
1 parent 660c30d commit 3f34f09

File tree

8 files changed

+157
-151
lines changed

8 files changed

+157
-151
lines changed

web_src/less/_base.less

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,12 @@ details summary > * {
214214
background: transparent;
215215
}
216216

217-
.CodeMirror-cursor {
218-
border-color: var(--color-caret) !important;
219-
}
220-
221-
::selection,
222-
.CodeMirror-selected {
217+
::selection {
223218
background: var(--color-primary-light-1) !important;
224219
color: var(--color-white) !important;
225220
}
226221

227222
::placeholder,
228-
.CodeMirror-placeholder,
229223
.ui.dropdown:not(.button) > .default.text,
230224
.ui.default.dropdown:not(.button) > .text {
231225
color: var(--color-placeholder-text) !important;
@@ -280,10 +274,6 @@ a.label,
280274
border-color: var(--color-primary);
281275
}
282276

283-
.CodeMirror-focused {
284-
border-color: var(--color-primary) !important;
285-
}
286-
287277
/* currently used for search bar dropdowns in repo search and explore code */
288278
.ui.action.input:not([class*="left action"]) > .ui.dropdown.selection {
289279
min-width: 10em;

web_src/less/_editor.less

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
.EasyMDEContainer .CodeMirror {
2-
color: var(--color-input-text);
3-
background-color: var(--color-input-background);
4-
border-color: var(--color-secondary);
5-
font: 14px var(--fonts-monospace);
6-
7-
&.cm-s-default {
8-
border-radius: 3px;
9-
padding: 0 !important;
10-
}
11-
12-
.cm-comment {
13-
background: inherit !important;
14-
}
15-
}
16-
171
.repository.file.editor .tab[data-tab="write"] {
182
padding: 0 !important;
193
}
@@ -33,6 +17,10 @@
3317
border-color: var(--color-secondary);
3418
}
3519

20+
.editor-toolbar.fullscreen {
21+
background: var(--color-body);
22+
}
23+
3624
.editor-toolbar button {
3725
border: none !important;
3826
color: var(--color-text-light);
@@ -55,6 +43,24 @@
5543
background: var(--color-active);
5644
}
5745

46+
/* hide preview button, we have the preview tab for this */
47+
.editor-toolbar:not(.fullscreen) .preview {
48+
display: none;
49+
}
50+
51+
/* hide revert button in fullscreen, it breaks the page */
52+
.editor-toolbar.fullscreen .revert-to-textarea {
53+
display: none;
54+
}
55+
56+
.editor-preview {
57+
background-color: var(--color-body);
58+
}
59+
60+
.editor-preview-side {
61+
border-color: var(--color-secondary);
62+
}
63+
5864
.editor-statusbar {
5965
color: var(--color-text-light);
6066
}

web_src/less/_repository.less

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,26 +2040,8 @@
20402040
}
20412041

20422042
&.new {
2043-
.CodeMirror {
2044-
.CodeMirror-code {
2045-
font-family: var(--fonts-monospace);
2046-
2047-
.cm-comment {
2048-
background: inherit;
2049-
}
2050-
}
2051-
}
2052-
2053-
.editor-preview {
2054-
background-color: white;
2055-
}
2056-
20572043
.ui.attached.tabular.menu.previewtabs {
20582044
margin-bottom: 15px;
2059-
2060-
& + .field .editor-toolbar:not(.fullscreen) a.fa-eye {
2061-
display: none;
2062-
}
20632045
}
20642046
}
20652047

web_src/less/codemirror/base.less

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.EasyMDEContainer .CodeMirror {
2+
color: var(--color-input-text);
3+
background-color: var(--color-input-background);
4+
border-color: var(--color-secondary);
5+
font: 14px var(--fonts-monospace);
6+
7+
&.cm-s-default {
8+
border-radius: var(--border-radius);
9+
padding: 0 !important;
10+
}
11+
12+
&.CodeMirror-fullscreen.CodeMirror-focused {
13+
border-right: 1px solid var(--color-primary) !important;
14+
}
15+
}
16+
17+
.CodeMirror-cursor {
18+
border-color: var(--color-caret) !important;
19+
}
20+
21+
.CodeMirror .cm-comment {
22+
background: inherit !important;
23+
}
24+
25+
.CodeMirror .CodeMirror-code {
26+
font: 14px var(--fonts-monospace);
27+
}
28+
29+
.CodeMirror-selected {
30+
background: var(--color-primary-light-1) !important;
31+
color: var(--color-white) !important;
32+
}
33+
34+
.CodeMirror-placeholder {
35+
color: var(--color-placeholder-text) !important;
36+
opacity: 1 !important;
37+
}
38+
39+
.CodeMirror-focused {
40+
border-color: var(--color-primary) !important;
41+
}

web_src/less/codemirror/dark.less

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
.CodeMirror {
2+
&.cm-s-default,
3+
&.cm-s-paper {
4+
.cm-property {
5+
color: #a0cc75;
6+
}
7+
8+
.cm-header {
9+
color: #9daccc;
10+
}
11+
12+
.cm-quote {
13+
color: #009900;
14+
}
15+
16+
.cm-keyword {
17+
color: #cc8a61;
18+
}
19+
20+
.cm-atom {
21+
color: #ef5e77;
22+
}
23+
24+
.cm-number {
25+
color: #ff5656;
26+
}
27+
28+
.cm-def {
29+
color: #e4e4e4;
30+
}
31+
32+
.cm-variable-2 {
33+
color: #00bdbf;
34+
}
35+
36+
.cm-variable-3 {
37+
color: #008855;
38+
}
39+
40+
.cm-comment {
41+
color: #8e9ab3;
42+
}
43+
44+
.cm-string {
45+
color: #a77272;
46+
}
47+
48+
.cm-string-2 {
49+
color: #ff5500;
50+
}
51+
52+
.cm-meta,
53+
.cm-qualifier {
54+
color: #ffb176;
55+
}
56+
57+
.cm-builtin {
58+
color: #b7c951;
59+
}
60+
61+
.cm-bracket {
62+
color: #999977;
63+
}
64+
65+
.cm-tag {
66+
color: #f1d273;
67+
}
68+
69+
.cm-attribute {
70+
color: #bfcc70;
71+
}
72+
73+
.cm-hr {
74+
color: #999999;
75+
}
76+
77+
.cm-url {
78+
color: #c5cfd0;
79+
}
80+
81+
.cm-link {
82+
color: #d8c792;
83+
}
84+
85+
.cm-error {
86+
color: #dbdbeb;
87+
}
88+
}
89+
}

web_src/less/codemirror/light.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* Placeholder, there is no light theme, it uses CM defaults */

web_src/less/index.less

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
@import "./chroma/base.less";
1818
@import "./chroma/light.less";
19+
@import "./codemirror/base.less";
20+
@import "./codemirror/light.less";
1921

2022
@import "_svg";
2123
@import "_tribute";

web_src/less/themes/theme-arc-green.less

Lines changed: 1 addition & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import "../chroma/dark.less";
2+
@import "../codemirror/dark.less";
23

34
:root {
45
--is-dark-theme: true;
@@ -292,19 +293,6 @@ a.ui.basic.green.label:hover {
292293
background-color: #393d4a !important;
293294
}
294295

295-
.repository.file.editor.edit,
296-
.repository.wiki.new .CodeMirror {
297-
.editor-preview,
298-
.editor-preview-side,
299-
& + .editor-preview-side {
300-
background: #353945;
301-
302-
.markup.ui.segment {
303-
border-width: 0;
304-
}
305-
}
306-
}
307-
308296
.overflow.menu .items .item {
309297
color: #9d9d9d;
310298
}
@@ -445,99 +433,6 @@ td.blob-excerpt {
445433
border-right-color: var(--color-secondary) !important;
446434
}
447435

448-
/* code mirror dark theme */
449-
450-
.CodeMirror {
451-
&.cm-s-default,
452-
&.cm-s-paper {
453-
.cm-property {
454-
color: #a0cc75;
455-
}
456-
457-
.cm-header {
458-
color: #9daccc;
459-
}
460-
461-
.cm-quote {
462-
color: #009900;
463-
}
464-
465-
.cm-keyword {
466-
color: #cc8a61;
467-
}
468-
469-
.cm-atom {
470-
color: #ef5e77;
471-
}
472-
473-
.cm-number {
474-
color: #ff5656;
475-
}
476-
477-
.cm-def {
478-
color: #e4e4e4;
479-
}
480-
481-
.cm-variable-2 {
482-
color: #00bdbf;
483-
}
484-
485-
.cm-variable-3 {
486-
color: #008855;
487-
}
488-
489-
.cm-comment {
490-
color: #8e9ab3;
491-
}
492-
493-
.cm-string {
494-
color: #a77272;
495-
}
496-
497-
.cm-string-2 {
498-
color: #ff5500;
499-
}
500-
501-
.cm-meta,
502-
.cm-qualifier {
503-
color: #ffb176;
504-
}
505-
506-
.cm-builtin {
507-
color: #b7c951;
508-
}
509-
510-
.cm-bracket {
511-
color: #999977;
512-
}
513-
514-
.cm-tag {
515-
color: #f1d273;
516-
}
517-
518-
.cm-attribute {
519-
color: #bfcc70;
520-
}
521-
522-
.cm-hr {
523-
color: #999999;
524-
}
525-
526-
.cm-url {
527-
color: #c5cfd0;
528-
}
529-
530-
.cm-link {
531-
color: #d8c792;
532-
}
533-
534-
.cm-error {
535-
/* color: #ff6e00; */
536-
color: #dbdbeb;
537-
}
538-
}
539-
}
540-
541436
footer .container .links > * {
542437
border-left-color: #888;
543438
}

0 commit comments

Comments
 (0)