fix: editor resize (#39542)

This commit is contained in:
Ahmad Abdolsaheb
2020-09-08 19:50:38 +03:00
committed by Mrugesh Mohapatra
parent 9b1077acf5
commit a500279036
4 changed files with 53 additions and 57 deletions

View File

@ -22,6 +22,8 @@
--red-dark: #850000; --red-dark: #850000;
--love-light: #f8577c; --love-light: #f8577c;
--love-dark: #f82153; --love-dark: #f82153;
--editor-background-light: #fffffe;
--editor-background-dark: #2a2b40;
} }
.dark-palette { .dark-palette {
@ -40,6 +42,7 @@
--danger-color: var(--red-light); --danger-color: var(--red-light);
--danger-background: var(--red-dark); --danger-background: var(--red-dark);
--love-color: var(--love-light); --love-color: var(--love-light);
--editor-background: var(--editor-background-dark);
} }
.light-palette { .light-palette {
@ -58,4 +61,5 @@
--danger-color: var(--red-dark); --danger-color: var(--red-dark);
--danger-background: var(--red-light); --danger-background: var(--red-light);
--love-color: var(--love-dark); --love-color: var(--love-dark);
--editor-background: var(--editor-background-light);
} }

View File

@ -1,4 +1,4 @@
import React, { Component } from 'react'; import React, { Component, Suspense } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
@ -15,6 +15,7 @@ import {
updateFile updateFile
} from '../redux'; } from '../redux';
import { userSelector, isDonationModalOpenSelector } from '../../../redux'; import { userSelector, isDonationModalOpenSelector } from '../../../redux';
import { Loader } from '../../../components/helpers';
import './editor.css'; import './editor.css';
@ -949,15 +950,18 @@ class Editor extends Component {
render() { render() {
const { theme } = this.props; const { theme } = this.props;
const editorTheme = theme === 'night' ? 'vs-dark-custom' : 'vs-custom'; const editorTheme = theme === 'night' ? 'vs-dark-custom' : 'vs-custom';
return ( return (
<MonacoEditor <Suspense fallback={<Loader timeout={600} />}>
editorDidMount={this.editorDidMount} <span className='notranslate'>
editorWillMount={this.editorWillMount} <MonacoEditor
onChange={this.onChange} editorDidMount={this.editorDidMount}
options={this.options} editorWillMount={this.editorWillMount}
theme={editorTheme} onChange={this.onChange}
/> options={this.options}
theme={editorTheme}
/>
</span>
</Suspense>
); );
} }
} }

View File

@ -1,5 +1,5 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component, Suspense } from 'react'; import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { ReflexContainer, ReflexElement, ReflexSplitter } from 'react-reflex'; import { ReflexContainer, ReflexElement, ReflexSplitter } from 'react-reflex';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
@ -17,7 +17,6 @@ import {
updateFile updateFile
} from '../redux'; } from '../redux';
import './editor.css'; import './editor.css';
import { Loader } from '../../../components/helpers';
import Editor from './Editor'; import Editor from './Editor';
const propTypes = { const propTypes = {
@ -201,68 +200,53 @@ class MultifileEditor extends Component {
orientation='horizontal' orientation='horizontal'
{...reflexProps} {...reflexProps}
{...resizeProps} {...resizeProps}
className='editor-container'
> >
<ReflexElement flex={10} {...reflexProps} {...resizeProps}> <ReflexElement flex={10} {...reflexProps} {...resizeProps}>
<ReflexContainer orientation='vertical'> <ReflexContainer orientation='vertical'>
{visibleEditors.indexhtml && ( {visibleEditors.indexhtml && (
<ReflexElement {...reflexProps} {...resizeProps}> <ReflexElement {...reflexProps} {...resizeProps}>
<Suspense fallback={<Loader timeout={600} />}> <Editor
<span className='notranslate'> challengeFiles={challengeFiles}
<Editor containerRef={containerRef}
challengeFiles={challengeFiles} description={
containerRef={containerRef} targetEditor === 'indexhtml' ? description : null
description={ }
targetEditor === 'indexhtml' ? description : null fileKey='indexhtml'
} key='indexhtml'
fileKey='indexhtml' ref={editorRef}
key='indexhtml' resizeProps={resizeProps}
ref={editorRef} theme={editorTheme}
resizeProps={resizeProps} />
theme={editorTheme}
/>
</span>
</Suspense>
</ReflexElement> </ReflexElement>
)} )}
{splitCSS && <ReflexSplitter propagate={true} {...resizeProps} />} {splitCSS && <ReflexSplitter propagate={true} {...resizeProps} />}
{visibleEditors.indexcss && ( {visibleEditors.indexcss && (
<ReflexElement {...reflexProps} {...resizeProps}> <ReflexElement {...reflexProps} {...resizeProps}>
<Suspense fallback={<Loader timeout={600} />}> <Editor
<span className='notranslate'> challengeFiles={challengeFiles}
<Editor containerRef={containerRef}
challengeFiles={challengeFiles} description={targetEditor === 'indexcss' ? description : null}
containerRef={containerRef} fileKey='indexcss'
description={ key='indexcss'
targetEditor === 'indexcss' ? description : null resizeProps={resizeProps}
} theme={editorTheme}
fileKey='indexcss' />
key='indexcss'
resizeProps={resizeProps}
theme={editorTheme}
/>
</span>
</Suspense>
</ReflexElement> </ReflexElement>
)} )}
{splitJS && <ReflexSplitter propagate={true} {...resizeProps} />} {splitJS && <ReflexSplitter propagate={true} {...resizeProps} />}
{visibleEditors.indexjs && ( {visibleEditors.indexjs && (
<ReflexElement {...reflexProps} {...resizeProps}> <ReflexElement {...reflexProps} {...resizeProps}>
<Suspense fallback={<Loader timeout={600} />}> <Editor
<span className='notranslate'> challengeFiles={challengeFiles}
<Editor containerRef={containerRef}
challengeFiles={challengeFiles} description={targetEditor === 'indexjs' ? description : null}
containerRef={containerRef} fileKey='indexjs'
description={ key='indexjs'
targetEditor === 'indexjs' ? description : null resizeProps={resizeProps}
} theme={editorTheme}
fileKey='indexjs' />
key='indexjs'
resizeProps={resizeProps}
theme={editorTheme}
/>
</span>
</Suspense>
</ReflexElement> </ReflexElement>
)} )}
</ReflexContainer> </ReflexContainer>

View File

@ -13,3 +13,7 @@
.vs .monaco-scrollable-element > .scrollbar > .slider { .vs .monaco-scrollable-element > .scrollbar > .slider {
z-index: 11; z-index: 11;
} }
.editor-container {
background: var(--editor-background);
}