From 3d087df1a21f937572e15728b71bb5ae797a85f2 Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Tue, 20 Sep 2016 11:51:09 -0400 Subject: [PATCH] add light and dark codemirrir themes --- client/modules/IDE/components/Editor.js | 9 +- client/modules/IDE/pages/IDEView.js | 1 + .../components/_p5-dark-codemirror-theme.scss | 115 ++++++++++++++++++ ...e.scss => _p5-light-codemirror-theme.scss} | 44 +++---- client/styles/main.scss | 3 +- 5 files changed, 147 insertions(+), 25 deletions(-) create mode 100644 client/styles/components/_p5-dark-codemirror-theme.scss rename client/styles/components/{_p5-widget-codemirror-theme.scss => _p5-light-codemirror-theme.scss} (63%) diff --git a/client/modules/IDE/components/Editor.js b/client/modules/IDE/components/Editor.js index d035a104..ae8c415b 100644 --- a/client/modules/IDE/components/Editor.js +++ b/client/modules/IDE/components/Editor.js @@ -37,7 +37,7 @@ class Editor extends React.Component { componentDidMount() { this.beep = new Audio(beepUrl); this._cm = CodeMirror(this.refs.container, { // eslint-disable-line - theme: 'p5-widget', + theme: `p5-${this.props.theme}`, value: this.props.file.content, lineNumbers: true, styleActiveLine: true, @@ -106,6 +106,10 @@ class Editor extends React.Component { this._cm.setOption('mode', 'htmlmixed'); } } + + if (this.props.theme !== prevProps.theme) { + this._cm.setOption('theme', `p5-${this.props.theme}`); + } } componentWillUnmount() { @@ -191,7 +195,8 @@ Editor.propTypes = { showEditorOptions: PropTypes.func.isRequired, closeEditorOptions: PropTypes.func.isRequired, showKeyboardShortcutModal: PropTypes.func.isRequired, - setUnsavedChanges: PropTypes.func.isRequired + setUnsavedChanges: PropTypes.func.isRequired, + theme: PropTypes.string.isRequired, }; export default Editor; diff --git a/client/modules/IDE/pages/IDEView.js b/client/modules/IDE/pages/IDEView.js index 3f1eaaf3..d989a015 100644 --- a/client/modules/IDE/pages/IDEView.js +++ b/client/modules/IDE/pages/IDEView.js @@ -274,6 +274,7 @@ class IDEView extends React.Component { closeEditorOptions={this.props.closeEditorOptions} showKeyboardShortcutModal={this.props.showKeyboardShortcutModal} setUnsavedChanges={this.props.setUnsavedChanges} + theme={this.props.preferences.theme} />