From ad83a2e3f4aaabfd2cd5efb086b6225376fa232c Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Tue, 14 Jul 2020 17:09:36 +0200 Subject: [PATCH] feat: show one hint at a time --- .../templates/Challenges/classic/Editor.js | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/client/src/templates/Challenges/classic/Editor.js b/client/src/templates/Challenges/classic/Editor.js index 5d316827ee..4b66fdabe3 100644 --- a/client/src/templates/Challenges/classic/Editor.js +++ b/client/src/templates/Challenges/classic/Editor.js @@ -35,7 +35,7 @@ const propTypes = { inAccessibilityMode: PropTypes.bool.isRequired, initialEditorContent: PropTypes.string, initialExt: PropTypes.string, - output: PropTypes.string, + output: PropTypes.arrayOf(PropTypes.string), saveEditorContent: PropTypes.func.isRequired, setAccessibilityMode: PropTypes.func.isRequired, setEditorFocusability: PropTypes.func, @@ -478,8 +478,13 @@ class Editor extends Component { createOutputNode() { if (this._outputNode) return this._outputNode; const outputNode = document.createElement('div'); - - outputNode.innerHTML = 'TESTS GO HERE'; + const statusNode = document.createElement('div'); + const hintNode = document.createElement('div'); + outputNode.appendChild(statusNode); + outputNode.appendChild(hintNode); + hintNode.setAttribute('id', 'test-output'); + statusNode.setAttribute('id', 'test-status'); + statusNode.innerHTML = '// tests'; // TODO: does it? // The z-index needs increasing as ViewZones default to below the lines. @@ -910,14 +915,23 @@ class Editor extends Component { } if (this._editor) { + const { output } = this.props; if (this.props.output !== prevProps.output && this._outputNode) { // TODO: output gets wiped when the preview gets updated, keeping the // display is an anti-pattern (the render should not ignore props!). // The correct solution is probably to create a new redux variable // (shownHint,maybe) and have that persist through previews. But, for // now: - if (this.props.output) { - this._outputNode.innerHTML = this.props.output; + if (output) { + console.log('OUTPUT', output); + if (output[0]) { + document.getElementById('test-status').innerHTML = output[0]; + } + + if (output[1]) { + document.getElementById('test-output').innerHTML = output[1]; + } + if (this.data[fileKey].startEditDecId) { this.updateOutputZone(); }