Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide Toolbox in Minecraft Python Hour of Code #10234

Merged
merged 9 commits into from
Oct 15, 2024

Conversation

thsparks
Copy link
Contributor

@thsparks thsparks commented Oct 15, 2024

Fixes

Fixes https://github.com/microsoft/pxt-minecraft/issues/2571
This adds a hideToolbox metadata field for tutorials (only supported for monaco at the moment, not sure it makes much sense in a blocks scenario). When present, the toolbox is not shown and the user actually has to type things out.

Fixes https://github.com/microsoft/pxt-minecraft/issues/2595
It also fixes a separate issue (that I initially thought was related to these changes but actually wasn't) with the workspace header, where it was always assuming we were in blocks mode. Now it accepts a property for the workspace id, which allows it to size everything correctly (thus, fixing the border).

flyoutOnly CSS

In our Minecraft css, we've evidently started using flyoutOnly as a de facto indicator for HOC tutorials, so I've had to include it even when hideToolbox is true (and flyoutOnly is false), otherwise all the styling disappears. Ideally, this css class would be refactored/renamed to something more generic, but I worry doing so will be a big, cross-repo change and could have unexpected side-effects, so I've left it for now.

Patch to avoid content changes

After chatting with Abhijith, it sounds like we don't want to require any content updates for the existing 2024 HOC tutorials, so I've added a quick patch setting hideToolbox to true automatically for python tutorials with the legacy layout and flyoutOnly set to true (actual flyoutOnly mode is not supported anyway).

Screenshot

Python:
image

Blocks mode unaffected:
image

Related change: https://github.com/microsoft/pxt-minecraft/pull/2596

@thsparks thsparks requested a review from a team October 15, 2024 21:59
@abchatra
Copy link
Contributor

Nice. Thank you!

@@ -22,6 +22,12 @@ namespace pxt.tutorial {
simThemeJson
} = computeBodyMetadata(body);

// For python HOC, hide the toolbox (we don't support flyoutOnly mode).
if (pxt.BrowserUtils.useOldTutorialLayout() && language === "python" && metadata.flyoutOnly) {
metadata.flyoutOnly = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is breaking the change that I made recently for getting rid of the icons for block snippets for flyoutOnly tutorials, based on one of the screenshots you included. To get rid of the icon, I'm checking that the metadata has flyoutOnly to true..

const hasCategories = !parent.state.tutorialOptions?.metadata?.flyoutOnly;

Maybe add, on this line, a check for if hideToolbox is true as well, because that would also mean that the tutorial wouldn't have categories.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Made your suggested change and updated the screenshot.

… so we're not relying on its right border. Will send separate Minecraft repo change to add border to the workspaceHeader instead.
@@ -384,7 +384,7 @@ export class MarkedContent extends data.Component<MarkedContentProps, MarkedCont
// Renders inline blocks, such as "||controller: Controller||".
private renderInlineBlocks(content: HTMLElement) {
const { parent } = this.props;
const hasCategories = !parent.state.tutorialOptions?.metadata?.flyoutOnly;
const hasCategories = !parent.state.tutorialOptions?.metadata?.flyoutOnly && !parent.state.tutorialOptions?.metadata?.hideToolbox;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the change, I think this might fail in the blocks scenario now, though, since you said that the hideToolbox flag is only being used in Monaco 😅.

Suggested change
const hasCategories = !parent.state.tutorialOptions?.metadata?.flyoutOnly && !parent.state.tutorialOptions?.metadata?.hideToolbox;
const hasCategories = !parent.state.tutorialOptions?.metadata?.flyoutOnly || !parent.state.tutorialOptions?.metadata?.hideToolbox;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it only has categories when both of these checks are false, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm, blocks look as expected (I think):
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh you are totally right. Sorry about that!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that looks good!

Copy link
Contributor

@srietkerk srietkerk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice change!

@thsparks thsparks merged commit 9e6dd9e into master Oct 15, 2024
6 checks passed
@thsparks thsparks deleted the thsparks/mc/hide_python_toolbox branch October 15, 2024 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants