From 47adbde90ba372d3bc8bbdc723c6ed8659ce5164 Mon Sep 17 00:00:00 2001 From: Shaun Hamilton Date: Wed, 28 Jul 2021 15:29:11 +0100 Subject: [PATCH] feat(client): add multifile editor breadcrumbs (#42907) * feat(client): add multifile editor breadcrumbs * adjust margin * update snapshot * re-remove duplicate css * adjust arrow colours * update that pesky snapshot * add title to editor jaw * remove bolding, and center * update snapshot --- .../templates/Challenges/classic/ActionRow.js | 16 ++++++++++------ .../Challenges/classic/DesktopLayout.js | 13 +++++++++++-- .../Challenges/classic/MultifileEditor.js | 6 ++++++ client/src/templates/Challenges/classic/Show.tsx | 5 ++++- .../src/templates/Challenges/classic/editor.css | 5 +---- .../src/templates/Challenges/classic/editor.tsx | 9 ++++++--- .../Challenges/components/bread-crumb.tsx | 4 ---- .../Challenges/components/challenge-title.css | 4 +--- 8 files changed, 39 insertions(+), 23 deletions(-) diff --git a/client/src/templates/Challenges/classic/ActionRow.js b/client/src/templates/Challenges/classic/ActionRow.js index e19e9fbf61..841de84751 100644 --- a/client/src/templates/Challenges/classic/ActionRow.js +++ b/client/src/templates/Challenges/classic/ActionRow.js @@ -1,6 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import EditorTabs from './EditorTabs'; +import BreadCrumb from '../components/bread-crumb'; const propTypes = { block: PropTypes.string, @@ -11,17 +12,20 @@ const propTypes = { switchDisplayTab: PropTypes.func }; -const ActionRow = ({ switchDisplayTab, showPreview, showConsole }) => { +const ActionRow = ({ + switchDisplayTab, + showPreview, + showConsole, + superBlock, + block +}) => { const restartStep = () => { console.log('restart'); }; return (
-
-
- Responsive Web Design > Basic HTML Cat Photo App >{' '} - Step 23 of 213 -
+
+
diff --git a/client/src/templates/Challenges/classic/DesktopLayout.js b/client/src/templates/Challenges/classic/DesktopLayout.js index 3f627614b3..3fa3bf0509 100644 --- a/client/src/templates/Challenges/classic/DesktopLayout.js +++ b/client/src/templates/Challenges/classic/DesktopLayout.js @@ -13,6 +13,7 @@ const paneType = { }; const propTypes = { + block: PropTypes.string, challengeFiles: PropTypes.object, editor: PropTypes.element, hasEditableBoundries: PropTypes.bool, @@ -30,6 +31,7 @@ const propTypes = { onStopResize: PropTypes.func, onResize: PropTypes.func }), + superBlock: PropTypes.string, testOutput: PropTypes.element }; @@ -68,7 +70,9 @@ class DesktopLayout extends Component { hasPreview, layoutState, preview, - hasEditableBoundries + hasEditableBoundries, + superBlock, + block } = this.props; const { showPreview, showConsole } = this.state; @@ -85,7 +89,12 @@ class DesktopLayout extends Component { return ( {projectBasedChallenge && ( - + )} diff --git a/client/src/templates/Challenges/classic/MultifileEditor.js b/client/src/templates/Challenges/classic/MultifileEditor.js index 5d883d9334..694fc373b4 100644 --- a/client/src/templates/Challenges/classic/MultifileEditor.js +++ b/client/src/templates/Challenges/classic/MultifileEditor.js @@ -43,6 +43,7 @@ const propTypes = { setAccessibilityMode: PropTypes.func.isRequired, setEditorFocusability: PropTypes.func, theme: PropTypes.string, + title: PropTypes.string, updateFile: PropTypes.func.isRequired, visibleEditors: PropTypes.shape({ indexjs: PropTypes.bool, @@ -98,6 +99,7 @@ class MultifileEditor extends Component { editorRef, theme, resizeProps, + title, visibleEditors: { indexcss, indexhtml, indexjs, indexjsx } } = this.props; const editorTheme = theme === 'night' ? 'vs-dark-custom' : 'vs-custom'; @@ -155,6 +157,7 @@ class MultifileEditor extends Component { key='indexjsx' resizeProps={resizeProps} theme={editorTheme} + title={title} /> )} @@ -174,6 +177,7 @@ class MultifileEditor extends Component { key='indexhtml' resizeProps={resizeProps} theme={editorTheme} + title={title} /> )} @@ -191,6 +195,7 @@ class MultifileEditor extends Component { key='indexcss' resizeProps={resizeProps} theme={editorTheme} + title={title} /> )} @@ -209,6 +214,7 @@ class MultifileEditor extends Component { key='indexjs' resizeProps={resizeProps} theme={editorTheme} + title={title} /> )} diff --git a/client/src/templates/Challenges/classic/Show.tsx b/client/src/templates/Challenges/classic/Show.tsx index 39615ba1b3..adbeb57751 100644 --- a/client/src/templates/Challenges/classic/Show.tsx +++ b/client/src/templates/Challenges/classic/Show.tsx @@ -303,7 +303,7 @@ class ShowClassic extends Component { renderEditor() { const { files } = this.props; - const { description } = this.getChallenge(); + const { description, title } = this.getChallenge(); // eslint-disable-next-line @typescript-eslint/no-unsafe-return return ( files && ( @@ -314,6 +314,7 @@ class ShowClassic extends Component { editorRef={this.editorRef} hasEditableBoundries={this.hasEditableBoundries()} resizeProps={this.resizeProps} + title={title} /> ) ); @@ -395,6 +396,7 @@ class ShowClassic extends Component { { layoutState={this.state.layout} preview={this.renderPreview()} resizeProps={this.resizeProps} + superBlock={superBlock} testOutput={this.renderTestOutput()} /> diff --git a/client/src/templates/Challenges/classic/editor.css b/client/src/templates/Challenges/classic/editor.css index 819fe329cf..951dbdd66c 100644 --- a/client/src/templates/Challenges/classic/editor.css +++ b/client/src/templates/Challenges/classic/editor.css @@ -16,10 +16,7 @@ .breadcrumbs-demo { font-size: 16px; -} - -.breadcrumbs-demo span { - font-weight: bold; + margin: 0 0 1.2rem; } .tabs-row { diff --git a/client/src/templates/Challenges/classic/editor.tsx b/client/src/templates/Challenges/classic/editor.tsx index 914e08d209..2003faf70b 100644 --- a/client/src/templates/Challenges/classic/editor.tsx +++ b/client/src/templates/Challenges/classic/editor.tsx @@ -67,6 +67,7 @@ interface EditorProps { submitChallenge: () => void; tests: TestType[]; theme: string; + title: string; updateFile: (objest: { key: FileKeyTypes; editorValue: string; @@ -493,7 +494,9 @@ const Editor = (props: EditorProps): JSX.Element => { function createDescription(editor: editor.IStandaloneCodeEditor) { if (data.descriptionNode) return data.descriptionNode; - const { description } = props; + const { description, title } = props; + const jawHeading = document.createElement('h3'); + jawHeading.innerText = title; // TODO: var was used here. Should it? const domNode = document.createElement('div'); const desc = document.createElement('div'); @@ -501,6 +504,7 @@ const Editor = (props: EditorProps): JSX.Element => { descContainer.classList.add('description-container'); domNode.classList.add('editor-upper-jaw'); domNode.appendChild(descContainer); + descContainer.appendChild(jawHeading); descContainer.appendChild(desc); desc.innerHTML = description; // desc.style.background = 'white'; @@ -708,8 +712,7 @@ const Editor = (props: EditorProps): JSX.Element => { // TODO: handle the case that the editable region reaches the bottom of the // editor return ( - data.model?.getDecorationRange(data.endEditDecId) - ?.startLineNumber ?? 1 + data.model?.getDecorationRange(data.endEditDecId)?.startLineNumber ?? 1 ); } diff --git a/client/src/templates/Challenges/components/bread-crumb.tsx b/client/src/templates/Challenges/components/bread-crumb.tsx index ad510ceec4..d21dd8dfe0 100644 --- a/client/src/templates/Challenges/components/bread-crumb.tsx +++ b/client/src/templates/Challenges/components/bread-crumb.tsx @@ -12,8 +12,6 @@ interface BreadCrumbProps { function BreadCrumb({ block, superBlock }: BreadCrumbProps): JSX.Element { return (
- {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */} - {/* @ts-ignore */}
- {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */} - {/* @ts-ignore */}