From 1ca84068afa2609ffc93c0dda25c04c6185c7864 Mon Sep 17 00:00:00 2001 From: thsparks Date: Tue, 29 Oct 2024 14:31:04 -0700 Subject: [PATCH 1/4] Add an option to hide Done in tutorials --- localtypings/pxtarget.d.ts | 1 + webapp/src/components/tutorial/TutorialContainer.tsx | 12 +++++++----- .../src/components/tutorial/TutorialStepCounter.tsx | 8 +++++--- webapp/src/sidepanel.tsx | 1 + webapp/src/tutorial.tsx | 3 ++- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/localtypings/pxtarget.d.ts b/localtypings/pxtarget.d.ts index feb1d9700a61..d0f1f29e7f15 100644 --- a/localtypings/pxtarget.d.ts +++ b/localtypings/pxtarget.d.ts @@ -1205,6 +1205,7 @@ declare namespace pxt.tutorial { codeStop?: string; // command to run when code stops (MINECRAFT HOC ONLY) autoexpandOff?: boolean; // INTERNAL TESTING ONLY preferredEditor?: string; // preferred editor for opening the tutorial + hideDone?: boolean; // Do not show a "Done" button at the end of the tutorial } interface TutorialBlockConfigEntry { diff --git a/webapp/src/components/tutorial/TutorialContainer.tsx b/webapp/src/components/tutorial/TutorialContainer.tsx index 4f2d26957bad..72b9c38a03e8 100644 --- a/webapp/src/components/tutorial/TutorialContainer.tsx +++ b/webapp/src/components/tutorial/TutorialContainer.tsx @@ -23,6 +23,7 @@ interface TutorialContainerProps { hasTemplate?: boolean; preferredEditor?: string; hasBeenResized?: boolean; + hideDone?: boolean; tutorialOptions?: pxt.tutorial.TutorialOptions; // TODO (shakao) pass in only necessary subset tutorialSimSidebar?: boolean; @@ -37,7 +38,7 @@ const MAX_HEIGHT = 194; export function TutorialContainer(props: TutorialContainerProps) { const { parent, tutorialId, name, steps, hideIteration, hasTemplate, - preferredEditor, tutorialOptions, onTutorialStepChange, onTutorialComplete, + preferredEditor, tutorialOptions, hideDone, onTutorialStepChange, onTutorialComplete, setParentHeight } = props; const [ currentStep, setCurrentStep ] = React.useState(props.currentStep || 0); const [ stepErrorAttemptCount, setStepErrorAttemptCount ] = React.useState(0); @@ -49,7 +50,7 @@ export function TutorialContainer(props: TutorialContainerProps) { const showBack = currentStep !== 0; const showNext = currentStep !== steps.length - 1; - const showDone = !showNext && !pxt.appTarget.appTheme.lockedEditor && !hideIteration; + const isDone = !showNext && !pxt.appTarget.appTheme.lockedEditor && !hideIteration; const showImmersiveReader = pxt.appTarget.appTheme.immersiveReader; const isHorizontal = props.tutorialSimSidebar || pxt.BrowserUtils.isTabletSize(); @@ -237,8 +238,8 @@ export function TutorialContainer(props: TutorialContainerProps) { const doneButtonLabel = lf("Finish the tutorial."); const nextButtonLabel = lf("Go to the next step of the tutorial."); - const nextButton = showDone - ?