Commit 11df36dd authored by Paul Slaughter's avatar Paul Slaughter

Merge branch '195701-web-ide-dark-theme' into 'master'

Dark syntax highlighting theme for Web IDE

See merge request gitlab-org/gitlab!24158
parents f5030f1e 6e1f27b4
import { editor as monacoEditor, languages as monacoLanguages, Uri } from 'monaco-editor'; import { editor as monacoEditor, languages as monacoLanguages, Uri } from 'monaco-editor';
import gitlabTheme from '~/ide/lib/themes/gl_theme'; import whiteTheme from '~/ide/lib/themes/white';
import { defaultEditorOptions } from '~/ide/lib/editor_options'; import { defaultEditorOptions } from '~/ide/lib/editor_options';
import { clearDomElement } from './utils'; import { clearDomElement } from './utils';
...@@ -19,8 +19,8 @@ export default class Editor { ...@@ -19,8 +19,8 @@ export default class Editor {
} }
static setupMonacoTheme() { static setupMonacoTheme() {
monacoEditor.defineTheme(gitlabTheme.themeName, gitlabTheme.monacoTheme); monacoEditor.defineTheme('white', whiteTheme);
monacoEditor.setTheme('gitlab'); monacoEditor.setTheme('white');
} }
createInstance({ el = undefined, blobPath = '', blobContent = '' } = {}) { createInstance({ el = undefined, blobPath = '', blobContent = '' } = {}) {
......
...@@ -38,6 +38,7 @@ export default { ...@@ -38,6 +38,7 @@ export default {
'panelResizing', 'panelResizing',
'currentActivityView', 'currentActivityView',
'renderWhitespaceInCode', 'renderWhitespaceInCode',
'editorTheme',
]), ]),
...mapGetters([ ...mapGetters([
'currentMergeRequest', 'currentMergeRequest',
...@@ -85,6 +86,7 @@ export default { ...@@ -85,6 +86,7 @@ export default {
editorOptions() { editorOptions() {
return { return {
renderWhitespace: this.renderWhitespaceInCode ? 'all' : 'none', renderWhitespace: this.renderWhitespaceInCode ? 'all' : 'none',
theme: this.editorTheme,
}; };
}, },
}, },
......
...@@ -7,6 +7,7 @@ import store from './stores'; ...@@ -7,6 +7,7 @@ import store from './stores';
import router from './ide_router'; import router from './ide_router';
import { parseBoolean } from '../lib/utils/common_utils'; import { parseBoolean } from '../lib/utils/common_utils';
import { resetServiceWorkersPublicPath } from '../lib/utils/webpack'; import { resetServiceWorkersPublicPath } from '../lib/utils/webpack';
import { DEFAULT_THEME } from './lib/themes';
Vue.use(Translate); Vue.use(Translate);
...@@ -51,6 +52,7 @@ export function initIde(el, options = {}) { ...@@ -51,6 +52,7 @@ export function initIde(el, options = {}) {
this.setInitialData({ this.setInitialData({
clientsidePreviewEnabled: parseBoolean(el.dataset.clientsidePreviewEnabled), clientsidePreviewEnabled: parseBoolean(el.dataset.clientsidePreviewEnabled),
renderWhitespaceInCode: parseBoolean(el.dataset.renderWhitespaceInCode), renderWhitespaceInCode: parseBoolean(el.dataset.renderWhitespaceInCode),
editorTheme: window.gon?.user_color_scheme || DEFAULT_THEME,
}); });
}, },
methods: { methods: {
......
...@@ -6,13 +6,14 @@ import DirtyDiffController from './diff/controller'; ...@@ -6,13 +6,14 @@ import DirtyDiffController from './diff/controller';
import Disposable from './common/disposable'; import Disposable from './common/disposable';
import ModelManager from './common/model_manager'; import ModelManager from './common/model_manager';
import editorOptions, { defaultEditorOptions } from './editor_options'; import editorOptions, { defaultEditorOptions } from './editor_options';
import gitlabTheme from './themes/gl_theme'; import { themes } from './themes';
import keymap from './keymap.json'; import keymap from './keymap.json';
import { clearDomElement } from '~/editor/utils'; import { clearDomElement } from '~/editor/utils';
function setupMonacoTheme() { function setupThemes() {
monacoEditor.defineTheme(gitlabTheme.themeName, gitlabTheme.monacoTheme); themes.forEach(theme => {
monacoEditor.setTheme('gitlab'); monacoEditor.defineTheme(theme.name, theme.data);
});
} }
export default class Editor { export default class Editor {
...@@ -35,7 +36,7 @@ export default class Editor { ...@@ -35,7 +36,7 @@ export default class Editor {
...options, ...options,
}; };
setupMonacoTheme(); setupThemes();
this.debouncedUpdate = _.debounce(() => { this.debouncedUpdate = _.debounce(() => {
this.updateDimensions(); this.updateDimensions();
......
/*
https://github.com/brijeshb42/monaco-themes/blob/master/themes/Tomorrow-Night.json
The MIT License (MIT)
Copyright (c) Brijesh Bittu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
export default {
base: 'vs-dark',
inherit: true,
rules: [
{
foreground: '969896',
token: 'comment',
},
{
foreground: 'ced1cf',
token: 'keyword.operator.class',
},
{
foreground: 'ced1cf',
token: 'constant.other',
},
{
foreground: 'ced1cf',
token: 'source.php.embedded.line',
},
{
foreground: 'cc6666',
token: 'variable',
},
{
foreground: 'cc6666',
token: 'support.other.variable',
},
{
foreground: 'cc6666',
token: 'string.other.link',
},
{
foreground: 'cc6666',
token: 'string.regexp',
},
{
foreground: 'cc6666',
token: 'entity.name.tag',
},
{
foreground: 'cc6666',
token: 'entity.other.attribute-name',
},
{
foreground: 'cc6666',
token: 'meta.tag',
},
{
foreground: 'cc6666',
token: 'declaration.tag',
},
{
foreground: 'cc6666',
token: 'markup.deleted.git_gutter',
},
{
foreground: 'de935f',
token: 'constant.numeric',
},
{
foreground: 'de935f',
token: 'constant.language',
},
{
foreground: 'de935f',
token: 'support.constant',
},
{
foreground: 'de935f',
token: 'constant.character',
},
{
foreground: 'de935f',
token: 'variable.parameter',
},
{
foreground: 'de935f',
token: 'punctuation.section.embedded',
},
{
foreground: 'de935f',
token: 'keyword.other.unit',
},
{
foreground: 'f0c674',
token: 'entity.name.class',
},
{
foreground: 'f0c674',
token: 'entity.name.type.class',
},
{
foreground: 'f0c674',
token: 'support.type',
},
{
foreground: 'f0c674',
token: 'support.class',
},
{
foreground: 'b5bd68',
token: 'string',
},
{
foreground: 'b5bd68',
token: 'constant.other.symbol',
},
{
foreground: 'b5bd68',
token: 'entity.other.inherited-class',
},
{
foreground: 'b5bd68',
token: 'markup.heading',
},
{
foreground: 'b5bd68',
token: 'markup.inserted.git_gutter',
},
{
foreground: '8abeb7',
token: 'keyword.operator',
},
{
foreground: '8abeb7',
token: 'constant.other.color',
},
{
foreground: '81a2be',
token: 'entity.name.function',
},
{
foreground: '81a2be',
token: 'meta.function-call',
},
{
foreground: '81a2be',
token: 'support.function',
},
{
foreground: '81a2be',
token: 'keyword.other.special-method',
},
{
foreground: '81a2be',
token: 'meta.block-level',
},
{
foreground: '81a2be',
token: 'markup.changed.git_gutter',
},
{
foreground: 'b294bb',
token: 'keyword',
},
{
foreground: 'b294bb',
token: 'storage',
},
{
foreground: 'b294bb',
token: 'storage.type',
},
{
foreground: 'b294bb',
token: 'entity.name.tag.css',
},
{
foreground: 'ced2cf',
background: 'df5f5f',
token: 'invalid',
},
{
foreground: 'ced2cf',
background: '82a3bf',
token: 'meta.separator',
},
{
foreground: 'ced2cf',
background: 'b798bf',
token: 'invalid.deprecated',
},
{
foreground: 'ffffff',
token: 'markup.inserted.diff',
},
{
foreground: 'ffffff',
token: 'markup.deleted.diff',
},
{
foreground: 'ffffff',
token: 'meta.diff.header.to-file',
},
{
foreground: 'ffffff',
token: 'meta.diff.header.from-file',
},
{
foreground: '718c00',
token: 'markup.inserted.diff',
},
{
foreground: '718c00',
token: 'meta.diff.header.to-file',
},
{
foreground: 'c82829',
token: 'markup.deleted.diff',
},
{
foreground: 'c82829',
token: 'meta.diff.header.from-file',
},
{
foreground: 'ffffff',
background: '4271ae',
token: 'meta.diff.header.from-file',
},
{
foreground: 'ffffff',
background: '4271ae',
token: 'meta.diff.header.to-file',
},
{
foreground: '3e999f',
fontStyle: 'italic',
token: 'meta.diff.range',
},
],
colors: {
'editor.foreground': '#C5C8C6',
'editor.background': '#1D1F21',
'editor.selectionBackground': '#373B41',
'editor.lineHighlightBackground': '#282A2E',
'editorCursor.foreground': '#AEAFAD',
'editorWhitespace.foreground': '#4B4E55',
},
};
export default {
themeName: 'gitlab',
monacoTheme: {
base: 'vs',
inherit: true,
rules: [],
colors: {
'editorLineNumber.foreground': '#CCCCCC',
'diffEditor.insertedTextBackground': '#ddfbe6',
'diffEditor.removedTextBackground': '#f9d7dc',
'editor.selectionBackground': '#aad6f8',
'editorIndentGuide.activeBackground': '#cccccc',
},
},
};
import white from './white';
import dark from './dark';
export const themes = [
{
name: 'white',
data: white,
},
{
name: 'dark',
data: dark,
},
];
export const DEFAULT_THEME = 'white';
export default {
base: 'vs',
inherit: true,
rules: [],
colors: {
'editorLineNumber.foreground': '#CCCCCC',
'diffEditor.insertedTextBackground': '#A0F5B420',
'diffEditor.removedTextBackground': '#f9d7dc20',
'editor.selectionBackground': '#aad6f8',
'editorIndentGuide.activeBackground': '#cccccc',
},
};
import { activityBarViews, viewerTypes } from '../constants'; import { activityBarViews, viewerTypes } from '../constants';
import { DEFAULT_THEME } from '../lib/themes';
export default () => ({ export default () => ({
currentProjectId: '', currentProjectId: '',
...@@ -32,4 +33,5 @@ export default () => ({ ...@@ -32,4 +33,5 @@ export default () => ({
}, },
clientsidePreviewEnabled: false, clientsidePreviewEnabled: false,
renderWhitespaceInCode: false, renderWhitespaceInCode: false,
editorTheme: DEFAULT_THEME,
}); });
...@@ -296,8 +296,8 @@ $ide-commit-header-height: 48px; ...@@ -296,8 +296,8 @@ $ide-commit-header-height: 48px;
height: 100%; height: 100%;
min-height: 0; // firefox fix min-height: 0; // firefox fix
&.is-readonly, &.is-readonly .vs,
.editor.original { .vs .editor.original {
.monaco-editor, .monaco-editor,
.monaco-editor-background, .monaco-editor-background,
.monaco-editor .inputarea.ime-input { .monaco-editor .inputarea.ime-input {
......
---
title: Dark syntax highlighting theme for Web IDE
merge_request: 24158
author:
type: added
...@@ -74,6 +74,7 @@ describe('Multi-file editor library', () => { ...@@ -74,6 +74,7 @@ describe('Multi-file editor library', () => {
renderSideBySide: true, renderSideBySide: true,
renderLineHighlight: 'all', renderLineHighlight: 'all',
hideCursorInOverviewRuler: false, hideCursorInOverviewRuler: false,
theme: 'vs white',
}); });
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment