From 0c68fb3da5af9b11dbe1bd32585efc097e023994 Mon Sep 17 00:00:00 2001 From: thsparks Date: Mon, 16 Dec 2024 12:14:33 -0800 Subject: [PATCH] Show feedback comments on the sidebar --- theme/common.less | 78 ++++++++- theme/themes/pxt/globals/site.variables | 1 + webapp/src/app.tsx | 4 + webapp/src/editortoolbar.tsx | 95 ----------- webapp/src/feedbackPanel.tsx | 205 ++++++++++++++++++++++++ 5 files changed, 281 insertions(+), 102 deletions(-) create mode 100644 webapp/src/feedbackPanel.tsx diff --git a/theme/common.less b/theme/common.less index 49f3ac692729..f7a33913b9bb 100644 --- a/theme/common.less +++ b/theme/common.less @@ -97,6 +97,10 @@ pre { overflow: visible; } +.hasFeedback #maineditor { + right: @feedbackPanelWidth; +} + /* Editor tools */ @editorToolsHeight: 10rem; @editorToolsCollapsedHeight: 4.7rem; @@ -183,16 +187,76 @@ pre { cursor: pointer; } -#feedbackNavArea { - margin: auto; +#feedbackPanel { + display: flex; + flex-direction: column; + position: fixed; + top: @mainMenuHeight; + bottom: 4rem; + right: 0; + background-color: @filelistBackgroundColor; + z-index: @filelistZIndex; + font-family: @pageFont !important; + border-left: 2px solid #dadaef; + width: @feedbackPanelWidth; - .feedback-nav-container { + #feedbackNavArea { + margin: auto; + padding: 1rem; + border-bottom: 1px solid #dadaef; + width: 100%; display: flex; - flex-direction: row; - .feedback-nav-text { - font-size: 1.2rem; - font-weight: 600; + justify-content: center; + + .feedback-nav-container { + display: flex; + flex-direction: row; + .feedback-nav-text { + font-size: 1.2rem; + font-weight: 600; + margin: 0.5rem; + display: flex; + justify-content: center; + align-items: center; + } + .feedback-nav-btn { + margin: 0 0.5rem; + padding: 0.2rem; + } + } + } + + .feedback-comments-area { + display: flex; + flex-direction: column; + align-items: center; + justify-content: flex-start; + margin-top: 1rem; + gap: 1rem; + flex-grow: 1; + + .feedback-comment-btn { margin: 0.5rem; + padding: 0; + width: 80%; + height: fit-content; + background-color: #c7f8ff; + border: 1px solid #00b4cc; + color: black; + border-radius: 0; + text-align: start; + + .feedback-comment-header { + background-color: #00b4cc; + color: white; + font-weight: bold; + padding: 0.3rem 0.5rem; + } + + .feedback-comment-text-area { + padding: 0.5rem; + text-wrap: auto; + } } } } diff --git a/theme/themes/pxt/globals/site.variables b/theme/themes/pxt/globals/site.variables index c291bef67ff2..541cc4330050 100644 --- a/theme/themes/pxt/globals/site.variables +++ b/theme/themes/pxt/globals/site.variables @@ -173,6 +173,7 @@ @sideBarWidthLarge: 28rem; @simulatorWidth: 23rem; @simulatorWidthSmall: 20rem; +@feedbackPanelWidth: 20rem; /*------------------- Background diff --git a/webapp/src/app.tsx b/webapp/src/app.tsx index eab841f53d32..020ceacf209d 100644 --- a/webapp/src/app.tsx +++ b/webapp/src/app.tsx @@ -82,6 +82,7 @@ import { Tour } from "./components/onboarding/Tour"; import { parseTourStepsAsync } from "./onboarding"; import { initGitHubDb } from "./idbworkspace"; import { BlockDefinition, CategoryNameID } from "./toolbox"; +import { FeedbackPanel, getBlocksWithFeedback } from "./feedbackPanel"; pxt.blocks.requirePxtBlockly = () => pxtblockly as any; pxt.blocks.requireBlockly = () => Blockly; @@ -5275,6 +5276,7 @@ export class ProjectView const collapseIconTooltip = this.state.collapseEditorTools ? lf("Show the simulator") : lf("Hide the simulator"); const isApp = cmds.isNativeHost() || pxt.BrowserUtils.isElectron(); const hc = this.getData(auth.HIGHCONTRAST) + const hasFeedback = getBlocksWithFeedback(this).length > 0; let rootClassList = [ "ui", @@ -5313,6 +5315,7 @@ export class ProjectView this.editor == this.textEditor && this.state.errorListState, 'full-abs', pxt.appTarget.appTheme.embeddedTutorial ? "tutorial-embed" : "", + hasFeedback ? "hasFeedback" : "", ]; this.rootClasses = rootClassList; const rootClasses = sui.cx(rootClassList); @@ -5380,6 +5383,7 @@ export class ProjectView {showCollapseButton && } {this.allEditors.map(e => e.displayOuter(editorOffset))} + {hasFeedback && } {inHome ?
diff --git a/webapp/src/editortoolbar.tsx b/webapp/src/editortoolbar.tsx index 6bc9ba3a7bc2..f04c3233c88e 100644 --- a/webapp/src/editortoolbar.tsx +++ b/webapp/src/editortoolbar.tsx @@ -443,9 +443,6 @@ export class EditorToolbar extends data.Component
} - + } + className="feedback-comment-btn" + title={this.props.commentText} + onClick={this.onClick} + /> + ); + } +} + +interface EditorToolbarFeedbackNavProps { + parent: pxt.editor.IProjectView; + blocksWithFeedback: Blockly.Block[]; + isBlocksActive: boolean; + handlePrevFeedbackClick: () => void; + handleNextFeedbackClick: () => void; + focusOnBlockAtIndex: (index: number) => void; +} +interface EditorToolbarFeedbackNavState { +} +class EditorToolbarFeedbackNav extends React.Component { + constructor(props: EditorToolbarFeedbackNavProps) { + super(props); + } + + render() { + return this.props.blocksWithFeedback?.length ? ( +
+
+ ) : null; + } +}