Skip to content

Commit

Permalink
fix(editor): update night mode styles for the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
raisedadead authored and Bouncey committed Jun 29, 2018
1 parent 2d6beb7 commit 1dca9b8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/templates/Challenges/classic/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ import { connect } from 'react-redux';
import MonacoEditor from 'react-monaco-editor';

import { executeChallenge, updateFile } from '../redux';
import { userSelector } from '../../../redux/app';
import { createSelector } from 'reselect';

const propTypes = {
contents: PropTypes.string,
dimensions: PropTypes.object,
executeChallenge: PropTypes.func.isRequired,
ext: PropTypes.string,
fileKey: PropTypes.string,
theme: PropTypes.string,
updateFile: PropTypes.func.isRequired
};

const mapStateToProps = () => ({});
const mapStateToProps = createSelector(
userSelector,
({ theme = 'default' }) => ({ theme })
);

const mapDispatchToProps = dispatch =>
bindActionCreators(
Expand Down Expand Up @@ -93,16 +99,18 @@ class Editor extends PureComponent {
}

render() {
const { contents, ext } = this.props;
const { contents, ext, theme, fileKey } = this.props;
const editorTheme = theme === 'night' ? 'vs-dark' : 'vs';
return (
<div className='classic-editor editor'>
<base href='/' />
<MonacoEditor
editorDidMount={::this.editorDidMount}
key={`${editorTheme}-${fileKey}`}
language={modeMap[ext]}
onChange={::this.onChange}
options={this.options}
theme='vs'
theme={editorTheme}
value={contents}
/>
</div>
Expand Down

0 comments on commit 1dca9b8

Please sign in to comment.