Skip to content

Commit 9c33d98

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. 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. [1]: https://scratch.mit.edu/projects/editor Co-authored-by: James Mead <[email protected]>
1 parent 8c3ab8b commit 9c33d98

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
@@ -101,6 +101,7 @@ const GUIComponent = props => {
101101
isTotallyNormal,
102102
loading,
103103
logo,
104+
menuBarHidden,
104105
renderLogin,
105106
onClickAbout,
106107
onClickAccountNav,
@@ -174,6 +175,9 @@ const GUIComponent = props => {
174175

175176
return (<MediaQuery minWidth={layout.fullSizeMinWidth}>{isFullSize => {
176177
const stageSize = resolveStageSize(stageSizeMode, isFullSize);
178+
const boxStyles = classNames(styles.bodyWrapper, {
179+
[styles.bodyWrapperWithoutMenuBar]: menuBarHidden
180+
});
177181

178182
return isPlayerOnly ? (
179183
<StageWrapper
@@ -248,7 +252,7 @@ const GUIComponent = props => {
248252
onRequestClose={onRequestCloseBackdropLibrary}
249253
/>
250254
) : null}
251-
<MenuBar
255+
{!menuBarHidden && <MenuBar
252256
accountNavOpen={accountNavOpen}
253257
authorId={authorId}
254258
authorThumbnailUrl={authorThumbnailUrl}
@@ -283,8 +287,8 @@ const GUIComponent = props => {
283287
userOwnsProject={userOwnsProject}
284288
username={username}
285289
accountMenuOptions={accountMenuOptions}
286-
/>
287-
<Box className={styles.bodyWrapper}>
290+
/>}
291+
<Box className={boxStyles}>
288292
<Box className={styles.flexWrapper}>
289293
<Box className={styles.editorWrapper}>
290294
<Tabs
@@ -457,6 +461,7 @@ GUIComponent.propTypes = {
457461
isTotallyNormal: PropTypes.bool,
458462
loading: PropTypes.bool,
459463
logo: PropTypes.string,
464+
menuBarHidden: PropTypes.bool,
460465
onActivateCostumesTab: PropTypes.func,
461466
onActivateSoundsTab: PropTypes.func,
462467
onActivateTab: PropTypes.func,
@@ -518,6 +523,7 @@ GUIComponent.defaultProps = {
518523
isShared: false,
519524
isTotallyNormal: false,
520525
loading: false,
526+
menuBarHidden: false,
521527
showComingSoon: false,
522528
stageSizeMode: STAGE_SIZE_MODES.large,
523529
useExternalPeripheralList: false

0 commit comments

Comments
 (0)