Skip to content

Commit 38bab9c

Browse files
floehopperchrislo
authored andcommitted
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 19387c2 commit 38bab9c

File tree

2 files changed

+47
-35
lines changed

2 files changed

+47
-35
lines changed

src/components/gui/gui.css

Lines changed: 5 additions & 1 deletion
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

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ const GUIComponent = props => {
9595
isTotallyNormal,
9696
loading,
9797
logo,
98+
menuBarHidden,
9899
renderLogin,
99100
onClickAbout,
100101
onClickAccountNav,
@@ -148,6 +149,9 @@ const GUIComponent = props => {
148149

149150
return (<MediaQuery minWidth={layout.fullSizeMinWidth}>{isFullSize => {
150151
const stageSize = resolveStageSize(stageSizeMode, isFullSize);
152+
const boxStyles = classNames(styles.bodyWrapper, {
153+
[styles.bodyWrapperWithoutMenuBar]: menuBarHidden
154+
});
151155

152156
return isPlayerOnly ? (
153157
<StageWrapper
@@ -218,40 +222,42 @@ const GUIComponent = props => {
218222
onRequestClose={onRequestCloseBackdropLibrary}
219223
/>
220224
) : null}
221-
<MenuBar
222-
accountNavOpen={accountNavOpen}
223-
authorId={authorId}
224-
authorThumbnailUrl={authorThumbnailUrl}
225-
authorUsername={authorUsername}
226-
canChangeLanguage={canChangeLanguage}
227-
canChangeTheme={canChangeTheme}
228-
canCreateCopy={canCreateCopy}
229-
canCreateNew={canCreateNew}
230-
canEditTitle={canEditTitle}
231-
canManageFiles={canManageFiles}
232-
canRemix={canRemix}
233-
canSave={canSave}
234-
canShare={canShare}
235-
className={styles.menuBarPosition}
236-
enableCommunity={enableCommunity}
237-
isShared={isShared}
238-
isTotallyNormal={isTotallyNormal}
239-
logo={logo}
240-
renderLogin={renderLogin}
241-
showComingSoon={showComingSoon}
242-
onClickAbout={onClickAbout}
243-
onClickAccountNav={onClickAccountNav}
244-
onClickLogo={onClickLogo}
245-
onCloseAccountNav={onCloseAccountNav}
246-
onLogOut={onLogOut}
247-
onOpenRegistration={onOpenRegistration}
248-
onProjectTelemetryEvent={onProjectTelemetryEvent}
249-
onSeeCommunity={onSeeCommunity}
250-
onShare={onShare}
251-
onStartSelectingFileUpload={onStartSelectingFileUpload}
252-
onToggleLoginOpen={onToggleLoginOpen}
253-
/>
254-
<Box className={styles.bodyWrapper}>
225+
{!menuBarHidden &&
226+
<MenuBar
227+
accountNavOpen={accountNavOpen}
228+
authorId={authorId}
229+
authorThumbnailUrl={authorThumbnailUrl}
230+
authorUsername={authorUsername}
231+
canChangeLanguage={canChangeLanguage}
232+
canChangeTheme={canChangeTheme}
233+
canCreateCopy={canCreateCopy}
234+
canCreateNew={canCreateNew}
235+
canEditTitle={canEditTitle}
236+
canManageFiles={canManageFiles}
237+
canRemix={canRemix}
238+
canSave={canSave}
239+
canShare={canShare}
240+
className={styles.menuBarPosition}
241+
enableCommunity={enableCommunity}
242+
isShared={isShared}
243+
isTotallyNormal={isTotallyNormal}
244+
logo={logo}
245+
renderLogin={renderLogin}
246+
showComingSoon={showComingSoon}
247+
onClickAbout={onClickAbout}
248+
onClickAccountNav={onClickAccountNav}
249+
onClickLogo={onClickLogo}
250+
onCloseAccountNav={onCloseAccountNav}
251+
onLogOut={onLogOut}
252+
onOpenRegistration={onOpenRegistration}
253+
onProjectTelemetryEvent={onProjectTelemetryEvent}
254+
onSeeCommunity={onSeeCommunity}
255+
onShare={onShare}
256+
onStartSelectingFileUpload={onStartSelectingFileUpload}
257+
onToggleLoginOpen={onToggleLoginOpen}
258+
/>
259+
}
260+
<Box className={boxStyles}>
255261
<Box className={styles.flexWrapper}>
256262
<Box className={styles.editorWrapper}>
257263
<Tabs
@@ -415,6 +421,7 @@ GUIComponent.propTypes = {
415421
isTotallyNormal: PropTypes.bool,
416422
loading: PropTypes.bool,
417423
logo: PropTypes.string,
424+
menuBarHidden: PropTypes.bool,
418425
onActivateCostumesTab: PropTypes.func,
419426
onActivateSoundsTab: PropTypes.func,
420427
onActivateTab: PropTypes.func,
@@ -467,6 +474,7 @@ GUIComponent.defaultProps = {
467474
isShared: false,
468475
isTotallyNormal: false,
469476
loading: false,
477+
menuBarHidden: false,
470478
showComingSoon: false,
471479
stageSizeMode: STAGE_SIZE_MODES.large
472480
};

0 commit comments

Comments
 (0)