From 4f1c795291aaf21696609e2640bb81e07e1a05a0 Mon Sep 17 00:00:00 2001 From: Kat Hagan Date: Fri, 14 Aug 2020 15:14:11 -0700 Subject: [PATCH] create custom themes for Monaco (#2272) --- lib/note-content-editor.tsx | 42 ++++++++++++++++++++++++++++++++++--- scss/theme.scss | 16 +------------- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/lib/note-content-editor.tsx b/lib/note-content-editor.tsx index 6ce79aecd..75b0dda50 100644 --- a/lib/note-content-editor.tsx +++ b/lib/note-content-editor.tsx @@ -1,6 +1,10 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; -import Monaco, { ChangeHandler, EditorDidMount } from 'react-monaco-editor'; +import Monaco, { + ChangeHandler, + EditorDidMount, + EditorWillMount, +} from 'react-monaco-editor'; import { editor as Editor, Selection, SelectionDirection } from 'monaco-editor'; import actions from './state/actions'; @@ -150,6 +154,37 @@ class NoteContentEditor extends Component { return true; }; + editorInit: EditorWillMount = () => { + Editor.defineTheme('simplenote', { + base: 'vs', + inherit: true, + rules: [{ background: 'FFFFFF' }], + colors: { + 'editor.foreground': '#2c3338', // $studio-gray-80 AKA theme-color-fg + 'editor.background': '#ffffff', + 'editor.selectionBackground': '#ced9f2', // $studio-simplenote-blue-5 + 'scrollbarSlider.activeBackground': '#8c8f94', // $studio-gray-30 + 'scrollbarSlider.background': '#c3c4c7', // $studio-gray-10 + 'scrollbarSlider.hoverBackground': '#a7aaad', // $studio-gray-20 + 'textLink.foreground': '#1d4fc4', // $studio-simplenote-blue-60 + }, + }); + Editor.defineTheme('simplenote-dark', { + base: 'vs-dark', + inherit: true, + rules: [{ background: '1d2327' }], + colors: { + 'editor.foreground': '#ffffff', + 'editor.background': '#1d2327', // $studio-gray-90 + 'editor.selectionBackground': '#50575e', // $studio-gray-60 + 'scrollbarSlider.activeBackground': '#646970', // $studio-gray-50 + 'scrollbarSlider.background': '#2c3338', // $studio-gray-80 + 'scrollbarSlider.hoverBackground': '#1d2327', // $studio-gray-90 + 'textLink.foreground': '#ced9f2', // studio-simplenote-blue-5 + }, + }); + }; + editorReady: EditorDidMount = (editor, monaco) => { this.editor = editor; this.monaco = monaco; @@ -425,8 +460,9 @@ class NoteContentEditor extends Component { { quickSuggestions: false, renderIndentGuides: false, renderLineHighlight: 'none', - scrollbar: { horizontal: 'hidden' }, + scrollbar: { horizontal: 'hidden', useShadows: false }, scrollBeyondLastLine: false, selectionHighlight: false, wordWrap: 'on', diff --git a/scss/theme.scss b/scss/theme.scss index 61f296e55..93d7ce9fb 100644 --- a/scss/theme.scss +++ b/scss/theme.scss @@ -63,13 +63,6 @@ .search-field { border-color: $studio-gray-10; } - - .monaco-editor-background, - .monaco-editor .margin, - .monaco-editor .scroll-decoration { - background-color: $studio-white; - box-shadow: none; - } } .theme-dark { @@ -194,7 +187,7 @@ .note-list-item { &.note-list-item-selected { - background: #2c3338; + background: $studio-gray-80; } .note-list-item-excerpt { @@ -232,11 +225,4 @@ } } } - - .monaco-editor-background, - .monaco-editor .margin, - .monaco-editor .scroll-decoration { - background-color: $studio-gray-90; - box-shadow: none; - } }