diff --git a/packages/learn/src/templates/Challenges/classic/Editor.js b/packages/learn/src/templates/Challenges/classic/Editor.js
index 13f4989f00..b72972d83d 100644
--- a/packages/learn/src/templates/Challenges/classic/Editor.js
+++ b/packages/learn/src/templates/Challenges/classic/Editor.js
@@ -8,6 +8,7 @@ import { executeChallenge, updateFile } from '../redux';
const propTypes = {
contents: PropTypes.string,
+ dimensions: PropTypes.object,
executeChallenge: PropTypes.func.isRequired,
ext: PropTypes.string,
fileKey: PropTypes.string,
@@ -80,6 +81,12 @@ class Editor extends PureComponent {
updateFile({ key: fileKey, editorValue });
}
+ componentDidUpdate(prevProps) {
+ if (this.props.dimensions !== prevProps.dimensions && this._editor) {
+ this._editor.layout();
+ }
+ }
+
render() {
const { contents, ext } = this.props;
return (
diff --git a/packages/learn/src/templates/Challenges/classic/Show.js b/packages/learn/src/templates/Challenges/classic/Show.js
index 63e04a16b9..6a0ae113fd 100644
--- a/packages/learn/src/templates/Challenges/classic/Show.js
+++ b/packages/learn/src/templates/Challenges/classic/Show.js
@@ -142,14 +142,14 @@ class ShowClassic extends PureComponent {
const editors = Object.keys(files)
.map(key => files[key])
.map((file, index) => (
-
+
{index !== 0 && }
-
+
- {index + 1 === Object.keys(files).length && }
+ {index + 1 === Object.keys(files).length && }
{index + 1 === Object.keys(files).length ? (
-
+
) : null}
-
+
));
-
const showPreview =
challengeType === challengeTypes.html ||
challengeType === challengeTypes.modern;
@@ -184,9 +183,7 @@ class ShowClassic extends PureComponent {
-
- {editors}
-
+ {editors}
diff --git a/packages/learn/src/templates/Challenges/classic/classic.css b/packages/learn/src/templates/Challenges/classic/classic.css
index af0e05bf46..b46f229576 100644
--- a/packages/learn/src/templates/Challenges/classic/classic.css
+++ b/packages/learn/src/templates/Challenges/classic/classic.css
@@ -1,6 +1,5 @@
-.editor{
+.editor {
height: 100%;
- margin-bottom: 1.45rem;
}
.instructions-panel {
@@ -12,6 +11,7 @@
height: 100%;
display: flex;
align-items: end;
+ overflow: hidden;
}
.monaco-menu .action-label {
diff --git a/packages/learn/src/templates/Challenges/components/Output.js b/packages/learn/src/templates/Challenges/components/Output.js
index cb5c9afd20..5f2dc4f866 100644
--- a/packages/learn/src/templates/Challenges/components/Output.js
+++ b/packages/learn/src/templates/Challenges/components/Output.js
@@ -1,9 +1,10 @@
-import React, { Fragment } from 'react';
+import React, { Fragment, PureComponent } from 'react';
import PropTypes from 'prop-types';
import MonacoEditor from 'react-monaco-editor';
const propTypes = {
defaultOutput: PropTypes.string,
+ dimensions: PropTypes.object,
height: PropTypes.number,
output: PropTypes.string
};
@@ -21,18 +22,40 @@ const options = {
wordWrap: 'on'
};
-function Output({ output, defaultOutput, height }) {
- return (
-
-
-
-
- );
+class Output extends PureComponent {
+ constructor() {
+ super();
+
+ this._editor = null;
+ }
+
+ editorDidMount(editor) {
+ this._editor = editor;
+ }
+
+ componentDidUpdate(prevProps) {
+ if (this.props.dimensions !== prevProps.dimensions && this._editor) {
+ this._editor.layout();
+ }
+ }
+
+ resizeOutput = () => this._editor.layout();
+
+ render() {
+ const { output, defaultOutput, height } = this.props;
+ return (
+
+
+
+
+ );
+ }
}
Output.displayName = 'Output';