Skip to content

Commit 6e5f7f2

Browse files
committed
Allow MenuBar to be hidden
The MenuBar is quite specific to the canonical version of the online Scratch editor [1]. 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
1 parent 657fd15 commit 6e5f7f2

File tree

2 files changed

+47
-35
lines changed

2 files changed

+47
-35
lines changed

src/components/gui/gui.css

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77
}
88

99
.body-wrapper {
10-
height: calc(100% - $menu-bar-height);
1110
background-color: $ui-primary;
11+
height: calc(100% - $menu-bar-height);
12+
}
13+
14+
.body-wrapper-without-menu-bar {
15+
height: 100%;
1216
}
1317

1418
.body-wrapper * {

src/components/gui/gui.jsx

+42-34
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ const GUIComponent = props => {
9393
isTotallyNormal,
9494
loading,
9595
logo,
96+
menuBarHidden,
9697
renderLogin,
9798
onClickAbout,
9899
onClickAccountNav,
@@ -145,6 +146,9 @@ const GUIComponent = props => {
145146

146147
return (<MediaQuery minWidth={layout.fullSizeMinWidth}>{isFullSize => {
147148
const stageSize = resolveStageSize(stageSizeMode, isFullSize);
149+
const boxStyles = classNames(styles.bodyWrapper, {
150+
[styles.bodyWrapperWithoutMenuBar]: menuBarHidden
151+
});
148152

149153
return isPlayerOnly ? (
150154
<StageWrapper
@@ -211,40 +215,42 @@ const GUIComponent = props => {
211215
onRequestClose={onRequestCloseBackdropLibrary}
212216
/>
213217
) : null}
214-
<MenuBar
215-
accountNavOpen={accountNavOpen}
216-
authorId={authorId}
217-
authorThumbnailUrl={authorThumbnailUrl}
218-
authorUsername={authorUsername}
219-
canChangeLanguage={canChangeLanguage}
220-
canChangeTheme={canChangeTheme}
221-
canCreateCopy={canCreateCopy}
222-
canCreateNew={canCreateNew}
223-
canEditTitle={canEditTitle}
224-
canManageFiles={canManageFiles}
225-
canRemix={canRemix}
226-
canSave={canSave}
227-
canShare={canShare}
228-
className={styles.menuBarPosition}
229-
enableCommunity={enableCommunity}
230-
isShared={isShared}
231-
isTotallyNormal={isTotallyNormal}
232-
logo={logo}
233-
renderLogin={renderLogin}
234-
showComingSoon={showComingSoon}
235-
onClickAbout={onClickAbout}
236-
onClickAccountNav={onClickAccountNav}
237-
onClickLogo={onClickLogo}
238-
onCloseAccountNav={onCloseAccountNav}
239-
onLogOut={onLogOut}
240-
onOpenRegistration={onOpenRegistration}
241-
onProjectTelemetryEvent={onProjectTelemetryEvent}
242-
onSeeCommunity={onSeeCommunity}
243-
onShare={onShare}
244-
onStartSelectingFileUpload={onStartSelectingFileUpload}
245-
onToggleLoginOpen={onToggleLoginOpen}
246-
/>
247-
<Box className={styles.bodyWrapper}>
218+
{!menuBarHidden &&
219+
<MenuBar
220+
accountNavOpen={accountNavOpen}
221+
authorId={authorId}
222+
authorThumbnailUrl={authorThumbnailUrl}
223+
authorUsername={authorUsername}
224+
canChangeLanguage={canChangeLanguage}
225+
canChangeTheme={canChangeTheme}
226+
canCreateCopy={canCreateCopy}
227+
canCreateNew={canCreateNew}
228+
canEditTitle={canEditTitle}
229+
canManageFiles={canManageFiles}
230+
canRemix={canRemix}
231+
canSave={canSave}
232+
canShare={canShare}
233+
className={styles.menuBarPosition}
234+
enableCommunity={enableCommunity}
235+
isShared={isShared}
236+
isTotallyNormal={isTotallyNormal}
237+
logo={logo}
238+
renderLogin={renderLogin}
239+
showComingSoon={showComingSoon}
240+
onClickAbout={onClickAbout}
241+
onClickAccountNav={onClickAccountNav}
242+
onClickLogo={onClickLogo}
243+
onCloseAccountNav={onCloseAccountNav}
244+
onLogOut={onLogOut}
245+
onOpenRegistration={onOpenRegistration}
246+
onProjectTelemetryEvent={onProjectTelemetryEvent}
247+
onSeeCommunity={onSeeCommunity}
248+
onShare={onShare}
249+
onStartSelectingFileUpload={onStartSelectingFileUpload}
250+
onToggleLoginOpen={onToggleLoginOpen}
251+
/>
252+
}
253+
<Box className={boxStyles}>
248254
<Box className={styles.flexWrapper}>
249255
<Box className={styles.editorWrapper}>
250256
<Tabs
@@ -407,6 +413,7 @@ GUIComponent.propTypes = {
407413
isTotallyNormal: PropTypes.bool,
408414
loading: PropTypes.bool,
409415
logo: PropTypes.string,
416+
menuBarHidden: PropTypes.bool,
410417
onActivateCostumesTab: PropTypes.func,
411418
onActivateSoundsTab: PropTypes.func,
412419
onActivateTab: PropTypes.func,
@@ -458,6 +465,7 @@ GUIComponent.defaultProps = {
458465
isShared: false,
459466
isTotallyNormal: false,
460467
loading: false,
468+
menuBarHidden: false,
461469
showComingSoon: false,
462470
stageSizeMode: STAGE_SIZE_MODES.large
463471
};

0 commit comments

Comments
 (0)