fix(editor): update night mode styles for the editor
This commit is contained in:
@ -5,6 +5,8 @@ import { connect } from 'react-redux';
|
|||||||
import MonacoEditor from 'react-monaco-editor';
|
import MonacoEditor from 'react-monaco-editor';
|
||||||
|
|
||||||
import { executeChallenge, updateFile } from '../redux';
|
import { executeChallenge, updateFile } from '../redux';
|
||||||
|
import { userSelector } from '../../../redux/app';
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
contents: PropTypes.string,
|
contents: PropTypes.string,
|
||||||
@ -12,10 +14,14 @@ const propTypes = {
|
|||||||
executeChallenge: PropTypes.func.isRequired,
|
executeChallenge: PropTypes.func.isRequired,
|
||||||
ext: PropTypes.string,
|
ext: PropTypes.string,
|
||||||
fileKey: PropTypes.string,
|
fileKey: PropTypes.string,
|
||||||
|
theme: PropTypes.string,
|
||||||
updateFile: PropTypes.func.isRequired
|
updateFile: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapStateToProps = () => ({});
|
const mapStateToProps = createSelector(
|
||||||
|
userSelector,
|
||||||
|
({ theme = 'default' }) => ({ theme })
|
||||||
|
);
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch =>
|
const mapDispatchToProps = dispatch =>
|
||||||
bindActionCreators(
|
bindActionCreators(
|
||||||
@ -93,16 +99,18 @@ class Editor extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { contents, ext } = this.props;
|
const { contents, ext, theme, fileKey } = this.props;
|
||||||
|
const editorTheme = theme === 'night' ? 'vs-dark' : 'vs';
|
||||||
return (
|
return (
|
||||||
<div className='classic-editor editor'>
|
<div className='classic-editor editor'>
|
||||||
<base href='/' />
|
<base href='/' />
|
||||||
<MonacoEditor
|
<MonacoEditor
|
||||||
editorDidMount={::this.editorDidMount}
|
editorDidMount={::this.editorDidMount}
|
||||||
|
key={`${editorTheme}-${fileKey}`}
|
||||||
language={modeMap[ext]}
|
language={modeMap[ext]}
|
||||||
onChange={::this.onChange}
|
onChange={::this.onChange}
|
||||||
options={this.options}
|
options={this.options}
|
||||||
theme='vs'
|
theme={editorTheme}
|
||||||
value={contents}
|
value={contents}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user