Skip to content

Commit 31508da

Browse files
committed
simplify codemirror styling
1 parent e8bde7b commit 31508da

File tree

2 files changed

+35
-284
lines changed

2 files changed

+35
-284
lines changed

src/components/CodeMirror.res

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ module CM6 = {
152152
@send
153153
external dispatchEffects: (editorView, dispatchEffectsArg) => unit = "dispatch"
154154

155+
@module("@codemirror/view") @scope("EditorView") @val
156+
external theme: {..} => extension = "theme"
157+
155158
@module("@codemirror/view") @scope("EditorView") @val
156159
external lineWrapping: extension = "lineWrapping"
157160

@@ -380,6 +383,7 @@ module CM6 = {
380383
module TagStyle = {
381384
type t = {
382385
tag: array<tag>,
386+
class?: string,
383387
color?: string,
384388
fontStyle?: string,
385389
fontWeight?: string,
@@ -392,52 +396,39 @@ module CM6 = {
392396

393397
let default = define([
394398
{
395-
tag: [Tags.keyword],
396-
color: "#708",
397-
},
398-
{
399-
tag: [Tags.atom, Tags.bool, Tags.url, Tags.contentSeparator, Tags.labelName],
400-
color: "#219",
401-
},
402-
{
403-
tag: [Tags.literal, Tags.inserted],
404-
color: "#164",
405-
},
406-
{
407-
tag: [Tags.string, Tags.special(Tags.string), Tags.deleted],
408-
color: "#a11",
409-
},
410-
{
411-
tag: [Tags.regexp, Tags.escape],
412-
color: "#040",
399+
tag: [Tags.keyword, Tags.moduleKeyword, Tags.operator],
400+
class: "text-berry-dark-50",
413401
},
414402
{
415-
tag: [Tags.definition(Tags.variableName)],
416-
color: "#00f",
403+
tag: [
404+
Tags.variableName,
405+
Tags.definition(Tags.propertyName),
406+
Tags.tagName,
407+
Tags.labelName,
408+
Tags.definition(Tags.variableName),
409+
Tags.definition(Tags.typeName),
410+
],
411+
class: "text-gray-30",
417412
},
418413
{
419-
tag: [Tags.local(Tags.variableName)],
420-
color: "#30a",
414+
tag: [Tags.bool, Tags.atom, Tags.typeName, Tags.special(Tags.tagName)],
415+
class: "text-orange-dark",
421416
},
422417
{
423-
tag: [Tags.typeName, Tags.namespace],
424-
color: "#085",
418+
tag: [Tags.string, Tags.special(Tags.string), Tags.number],
419+
class: "text-turtle-dark",
425420
},
426421
{
427-
tag: [Tags.special(Tags.variableName), Tags.macroName],
428-
color: "#256",
429-
},
430-
{
431-
tag: [Tags.definition(Tags.propertyName)],
432-
color: "#00c",
422+
tag: [Tags.comment],
423+
class: "text-gray-60",
433424
},
434425
{
435-
tag: [Tags.comment],
436-
color: "#940",
426+
tag: [Tags.definition(Tags.namespace)],
427+
class: "text-orange",
437428
},
438429
{
439-
tag: [Tags.invalid],
440-
color: "#f00",
430+
tag: [Tags.namespace, Tags.annotation],
431+
class: "text-water-dark",
441432
},
442433
])
443434
}
@@ -611,6 +602,16 @@ let createEditor = (config: editorConfig): editorInstance => {
611602
let extensions = [
612603
CM6.Compartment.make(languageConf, (language: CM6.extension)),
613604
CM6.Commands.history(),
605+
CM6.EditorView.theme({
606+
".cm-content": {
607+
"lineHeight": "1.5",
608+
},
609+
".cm-line": {
610+
"lineHeight": "1.5",
611+
},
612+
".cm-gutters": {"backgroundColor": "inherit"},
613+
".cm-gutters.cm-gutters-before": {"border": "none"},
614+
}),
614615
CM6.EditorView.drawSelection(),
615616
CM6.EditorView.dropCursor(),
616617
CM6.Language.bracketMatching(),

styles/main.css

Lines changed: 0 additions & 250 deletions
Original file line numberDiff line numberDiff line change
@@ -299,256 +299,6 @@
299299
}
300300
}
301301

302-
.CodeMirror {
303-
background-color: inherit !important;
304-
color: inherit !important;
305-
height: 100% !important;
306-
}
307-
308-
.CodeMirror-gutters .errors {
309-
/*@apply bg-white text-red-500;*/
310-
@apply w-6;
311-
background-color: inherit;
312-
}
313-
314-
/*.CodeMirror-scroll {*/
315-
/*min-height: 40vh;*/
316-
/*}*/
317-
318-
.cm-s-material.CodeMirror {
319-
/*background-color: #263238;*/
320-
@apply font-mono;
321-
/*py-8;*/
322-
}
323-
324-
.cm-s-material .CodeMirror-gutters {
325-
/*@apply text-gray-80;*/
326-
border: none;
327-
background-color: inherit;
328-
color: inherit;
329-
}
330-
331-
/*.CodeMirror pre.CodeMirror-line,*/
332-
/*.CodeMirror pre.CodeMirror-line-like {*/
333-
/*}*/
334-
335-
.cm-s-material .CodeMirror-guttermarker,
336-
.cm-s-material .CodeMirror-guttermarker-subtle,
337-
.cm-s-material .CodeMirror-linenumber {
338-
@apply text-gray-80;
339-
}
340-
341-
.cm-s-material .CodeMirror-cursor {
342-
border-left: 1px solid #ffcc00;
343-
}
344-
345-
.cm-s-material div.CodeMirror-selected {
346-
background: rgba(128, 203, 196, 0.2);
347-
}
348-
349-
.cm-s-material.CodeMirror-focused div.CodeMirror-selected {
350-
background: rgba(128, 203, 196, 0.2);
351-
}
352-
353-
.cm-s-material .CodeMirror-line::selection,
354-
.cm-s-material .CodeMirror-line > span::selection,
355-
.cm-s-material .CodeMirror-line > span > span::selection {
356-
background: rgba(128, 203, 196, 0.2);
357-
}
358-
359-
.cm-s-material .CodeMirror-line::-moz-selection,
360-
.cm-s-material .CodeMirror-line > span::-moz-selection,
361-
.cm-s-material .CodeMirror-line > span > span::-moz-selection {
362-
background: rgba(128, 203, 196, 0.2);
363-
}
364-
365-
.cm-s-material .CodeMirror-activeline-background {
366-
background: rgba(0, 0, 0, 0.5);
367-
}
368-
369-
.cm-s-material .cm-keyword {
370-
@apply text-berry-dark-50;
371-
}
372-
373-
.cm-s-material .cm-keyword2 {
374-
@apply text-water-dark;
375-
}
376-
377-
.cm-s-material .cm-variant-constructor {
378-
@apply text-orange-dark;
379-
}
380-
381-
.cm-s-material .cm-module {
382-
@apply text-water-dark;
383-
}
384-
385-
.cm-s-material .cm-operator {
386-
@apply text-berry-dark-50;
387-
}
388-
389-
.cm-s-material .cm-variable-2 {
390-
color: #eeffff;
391-
}
392-
393-
.cm-s-material .cm-variable-3,
394-
.cm-s-material .cm-type {
395-
color: #f07178;
396-
}
397-
398-
.cm-s-material .cm-builtin {
399-
@apply text-orange-dark;
400-
}
401-
402-
.cm-s-material .cm-decorator {
403-
@apply text-water-dark;
404-
}
405-
406-
.cm-s-material .cm-type-annotation {
407-
@apply text-gray-40;
408-
}
409-
410-
.cm-s-material .cm-atom {
411-
@apply text-orange-dark;
412-
}
413-
414-
.cm-s-material .cm-number {
415-
@apply text-turtle-dark;
416-
}
417-
418-
.cm-s-material .cm-def {
419-
@apply text-gray-30;
420-
}
421-
422-
.cm-s-material .cm-string {
423-
@apply text-turtle-dark;
424-
}
425-
426-
.cm-s-material .cm-string-2 {
427-
@apply text-turtle-dark;
428-
}
429-
430-
.cm-s-material .cm-comment {
431-
@apply text-gray-60;
432-
}
433-
434-
.cm-s-material .cm-variable {
435-
@apply text-gray-30;
436-
}
437-
438-
.cm-s-material .cm-tag {
439-
color: #ff5370;
440-
}
441-
442-
.cm-s-material .cm-meta {
443-
color: #ffcb6b;
444-
}
445-
446-
.cm-s-material .cm-attribute {
447-
color: #c792ea;
448-
}
449-
450-
.cm-s-material .cm-property {
451-
color: #c792ea;
452-
}
453-
454-
.cm-s-material .cm-qualifier {
455-
color: #decb6b;
456-
}
457-
458-
.cm-s-material .cm-variable-3,
459-
.cm-s-material .cm-type {
460-
color: #decb6b;
461-
}
462-
463-
.cm-s-material .cm-error {
464-
color: rgba(255, 255, 255, 1);
465-
background-color: #ff5370;
466-
}
467-
468-
.cm-s-material .CodeMirror-matchingbracket {
469-
text-decoration: underline;
470-
color: white !important;
471-
}
472-
473-
/* simplescrollbars style */
474-
.CodeMirror-simplescroll-horizontal div,
475-
.CodeMirror-simplescroll-vertical div {
476-
position: absolute;
477-
background: #ccc;
478-
-moz-box-sizing: border-box;
479-
box-sizing: border-box;
480-
border: 1px solid #bbb;
481-
border-radius: 2px;
482-
}
483-
484-
.CodeMirror-simplescroll-horizontal,
485-
.CodeMirror-simplescroll-vertical {
486-
position: absolute;
487-
z-index: 6;
488-
background: #eee;
489-
}
490-
491-
.CodeMirror-simplescroll-horizontal {
492-
bottom: 0;
493-
left: 0;
494-
height: 8px;
495-
}
496-
497-
.CodeMirror-simplescroll-horizontal div {
498-
bottom: 0;
499-
height: 100%;
500-
}
501-
502-
.CodeMirror-simplescroll-vertical {
503-
right: 0;
504-
top: 0;
505-
width: 8px;
506-
}
507-
508-
.CodeMirror-simplescroll-vertical div {
509-
right: 0;
510-
width: 100%;
511-
}
512-
513-
.CodeMirror-overlayscroll .CodeMirror-scrollbar-filler,
514-
.CodeMirror-overlayscroll .CodeMirror-gutter-filler {
515-
display: none;
516-
}
517-
518-
.CodeMirror-overlayscroll-horizontal div,
519-
.CodeMirror-overlayscroll-vertical div {
520-
position: absolute;
521-
background: #bcd;
522-
border-radius: 3px;
523-
}
524-
525-
.CodeMirror-overlayscroll-horizontal,
526-
.CodeMirror-overlayscroll-vertical {
527-
position: absolute;
528-
z-index: 6;
529-
}
530-
531-
.CodeMirror-overlayscroll-horizontal {
532-
bottom: 0;
533-
left: 0;
534-
height: 6px;
535-
}
536-
537-
.CodeMirror-overlayscroll-horizontal div {
538-
bottom: 0;
539-
height: 100%;
540-
}
541-
542-
.CodeMirror-overlayscroll-vertical {
543-
right: 0;
544-
top: 0;
545-
width: 6px;
546-
}
547-
548-
.CodeMirror-overlayscroll-vertical div {
549-
right: 0;
550-
width: 100%;
551-
}
552302

553303
.wrapper {
554304
position: relative;

0 commit comments

Comments
 (0)