Skip to content

Commit dadc4f1

Browse files
sebjacobsfloehopper
andcommitted
feat: allow MenuBar to be hidden
The MenuBar is quite specific to the canonical version of the online Scratch editor [1]. In RaspberryPiFoundation projects we want to make use of the scratch-gui package without displaying the MenuBar. The MenuBar can be hidden by passing in the `menuBarHidden` prop. Since the height of the menu bar is hard-coded as a CSS variable, I've had to override the height calculation for the body wrapper when the menu bar is not visible. Ideally the height of the menu bar wouldn't be hard-coded and this wouldn't be necessary. We were unable to find an existing unit test for the Gui component and so we have not added any test coverage around the new `menuBarHidden` prop. [1]: https://scratch.mit.edu/projects/editor Co-authored-by: James Mead <james.mead@gofreerange.com>
1 parent b0602f3 commit dadc4f1

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

packages/scratch-gui/src/components/gui/gui.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
background-color: $ui-primary;
1212
}
1313

14+
.body-wrapper-without-menu-bar {
15+
height: 100%;
16+
}
17+
1418
.body-wrapper * {
1519
box-sizing: border-box;
1620
}

packages/scratch-gui/src/components/gui/gui.jsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ const GUIComponent = props => {
102102
loading,
103103
logo,
104104
manuallySaveThumbnails,
105+
menuBarHidden,
105106
renderLogin,
106107
onClickAbout,
107108
onClickAccountNav,
@@ -176,6 +177,9 @@ const GUIComponent = props => {
176177

177178
return (<MediaQuery minWidth={layout.fullSizeMinWidth}>{isFullSize => {
178179
const stageSize = resolveStageSize(stageSizeMode, isFullSize);
180+
const boxStyles = classNames(styles.bodyWrapper, {
181+
[styles.bodyWrapperWithoutMenuBar]: menuBarHidden
182+
});
179183

180184
return isPlayerOnly ? (
181185
<StageWrapper
@@ -255,7 +259,7 @@ const GUIComponent = props => {
255259
onRequestClose={onRequestCloseBackdropLibrary}
256260
/>
257261
) : null}
258-
<MenuBar
262+
{!menuBarHidden && <MenuBar
259263
accountNavOpen={accountNavOpen}
260264
authorId={authorId}
261265
authorThumbnailUrl={authorThumbnailUrl}
@@ -290,8 +294,8 @@ const GUIComponent = props => {
290294
userOwnsProject={userOwnsProject}
291295
username={username}
292296
accountMenuOptions={accountMenuOptions}
293-
/>
294-
<Box className={styles.bodyWrapper}>
297+
/>}
298+
<Box className={boxStyles}>
295299
<Box className={styles.flexWrapper}>
296300
<Box className={styles.editorWrapper}>
297301
<Tabs
@@ -465,6 +469,7 @@ GUIComponent.propTypes = {
465469
loading: PropTypes.bool,
466470
logo: PropTypes.string,
467471
manuallySaveThumbnails: PropTypes.bool,
472+
menuBarHidden: PropTypes.bool,
468473
onActivateCostumesTab: PropTypes.func,
469474
onActivateSoundsTab: PropTypes.func,
470475
onActivateTab: PropTypes.func,
@@ -527,6 +532,7 @@ GUIComponent.defaultProps = {
527532
isShared: false,
528533
isTotallyNormal: false,
529534
loading: false,
535+
menuBarHidden: false,
530536
showComingSoon: false,
531537
stageSizeMode: STAGE_SIZE_MODES.large,
532538
useExternalPeripheralList: false

0 commit comments

Comments
 (0)