fix(client): split Editor panes correctly (#41570)
* refactor: clean up MultifileEditor * fix: show correct splitters * fix: include splitter for JSX
This commit is contained in:
committed by
GitHub
parent
963c3c5af5
commit
73d9b4c194
@ -169,7 +169,7 @@ class MultifileEditor extends Component {
|
|||||||
editorRef,
|
editorRef,
|
||||||
theme,
|
theme,
|
||||||
resizeProps,
|
resizeProps,
|
||||||
visibleEditors
|
visibleEditors: { indexcss, indexhtml, indexjs, indexjsx }
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const editorTheme = theme === 'night' ? 'vs-dark-custom' : 'vs-custom';
|
const editorTheme = theme === 'night' ? 'vs-dark-custom' : 'vs-custom';
|
||||||
// TODO: the tabs mess up the rendering (scroll doesn't work properly and
|
// TODO: the tabs mess up the rendering (scroll doesn't work properly and
|
||||||
@ -185,11 +185,22 @@ class MultifileEditor extends Component {
|
|||||||
renderOnResizeRate: 20
|
renderOnResizeRate: 20
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: this approach (||ing the visibleEditors) isn't great.
|
let splitterJSXRight, splitterHTMLRight, splitterCSSRight;
|
||||||
const splitCSS = visibleEditors.indexhtml && visibleEditors.indexcss;
|
if (indexjsx) {
|
||||||
const splitJS =
|
if (indexhtml || indexcss || indexjs) {
|
||||||
visibleEditors.indexcss ||
|
splitterJSXRight = true;
|
||||||
(visibleEditors.indexhtml && visibleEditors.indexjs);
|
}
|
||||||
|
}
|
||||||
|
if (indexhtml) {
|
||||||
|
if (indexcss || indexjs) {
|
||||||
|
splitterHTMLRight = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (indexcss) {
|
||||||
|
if (indexjs) {
|
||||||
|
splitterCSSRight = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: tabs should be dynamically created from the challengeFiles
|
// TODO: tabs should be dynamically created from the challengeFiles
|
||||||
// TODO: the tabs mess up the rendering (scroll doesn't work properly and
|
// TODO: the tabs mess up the rendering (scroll doesn't work properly and
|
||||||
@ -204,7 +215,23 @@ class MultifileEditor extends Component {
|
|||||||
>
|
>
|
||||||
<ReflexElement flex={10} {...reflexProps} {...resizeProps}>
|
<ReflexElement flex={10} {...reflexProps} {...resizeProps}>
|
||||||
<ReflexContainer orientation='vertical'>
|
<ReflexContainer orientation='vertical'>
|
||||||
{visibleEditors.indexhtml && (
|
{indexjsx && (
|
||||||
|
<ReflexElement {...reflexProps} {...resizeProps}>
|
||||||
|
<Editor
|
||||||
|
challengeFiles={challengeFiles}
|
||||||
|
containerRef={containerRef}
|
||||||
|
description={targetEditor === 'indexjsx' ? description : null}
|
||||||
|
fileKey='indexjsx'
|
||||||
|
key='indexjsx'
|
||||||
|
resizeProps={resizeProps}
|
||||||
|
theme={editorTheme}
|
||||||
|
/>
|
||||||
|
</ReflexElement>
|
||||||
|
)}
|
||||||
|
{splitterJSXRight && (
|
||||||
|
<ReflexSplitter propagate={true} {...resizeProps} />
|
||||||
|
)}
|
||||||
|
{indexhtml && (
|
||||||
<ReflexElement {...reflexProps} {...resizeProps}>
|
<ReflexElement {...reflexProps} {...resizeProps}>
|
||||||
<Editor
|
<Editor
|
||||||
challengeFiles={challengeFiles}
|
challengeFiles={challengeFiles}
|
||||||
@ -220,8 +247,10 @@ class MultifileEditor extends Component {
|
|||||||
/>
|
/>
|
||||||
</ReflexElement>
|
</ReflexElement>
|
||||||
)}
|
)}
|
||||||
{splitCSS && <ReflexSplitter propagate={true} {...resizeProps} />}
|
{splitterHTMLRight && (
|
||||||
{visibleEditors.indexcss && (
|
<ReflexSplitter propagate={true} {...resizeProps} />
|
||||||
|
)}
|
||||||
|
{indexcss && (
|
||||||
<ReflexElement {...reflexProps} {...resizeProps}>
|
<ReflexElement {...reflexProps} {...resizeProps}>
|
||||||
<Editor
|
<Editor
|
||||||
challengeFiles={challengeFiles}
|
challengeFiles={challengeFiles}
|
||||||
@ -234,9 +263,11 @@ class MultifileEditor extends Component {
|
|||||||
/>
|
/>
|
||||||
</ReflexElement>
|
</ReflexElement>
|
||||||
)}
|
)}
|
||||||
{splitJS && <ReflexSplitter propagate={true} {...resizeProps} />}
|
{splitterCSSRight && (
|
||||||
|
<ReflexSplitter propagate={true} {...resizeProps} />
|
||||||
|
)}
|
||||||
|
|
||||||
{visibleEditors.indexjs && (
|
{indexjs && (
|
||||||
<ReflexElement {...reflexProps} {...resizeProps}>
|
<ReflexElement {...reflexProps} {...resizeProps}>
|
||||||
<Editor
|
<Editor
|
||||||
challengeFiles={challengeFiles}
|
challengeFiles={challengeFiles}
|
||||||
@ -249,19 +280,6 @@ class MultifileEditor extends Component {
|
|||||||
/>
|
/>
|
||||||
</ReflexElement>
|
</ReflexElement>
|
||||||
)}
|
)}
|
||||||
{visibleEditors.indexjsx && (
|
|
||||||
<ReflexElement {...reflexProps} {...resizeProps}>
|
|
||||||
<Editor
|
|
||||||
challengeFiles={challengeFiles}
|
|
||||||
containerRef={containerRef}
|
|
||||||
description={targetEditor === 'indexjsx' ? description : null}
|
|
||||||
fileKey='indexjsx'
|
|
||||||
key='indexjsx'
|
|
||||||
resizeProps={resizeProps}
|
|
||||||
theme={editorTheme}
|
|
||||||
/>
|
|
||||||
</ReflexElement>
|
|
||||||
)}
|
|
||||||
</ReflexContainer>
|
</ReflexContainer>
|
||||||
</ReflexElement>
|
</ReflexElement>
|
||||||
</ReflexContainer>
|
</ReflexContainer>
|
||||||
|
Reference in New Issue
Block a user