Skip to content

Commit 6bf9fac

Browse files
committed
addressing comments
* add scratchLogo as default for logo prop * prefer `{featureAllowed && (<Component />)} over ternary operator with a null ‘else’ * renamed `handleSaveToComputer` as `getSaveToComputerHandler` to more clearly represent what it’s doing (returning a function to be the handler) * renamed the parameter that is the function to handle clicking on the load project menu item (also updated the comments in `SBFileUploader`)
1 parent 6d482fd commit 6bf9fac

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

src/components/menu-bar/menu-bar.jsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class MenuBar extends React.Component {
154154
'handleKeyPress',
155155
'handleLanguageMouseUp',
156156
'handleRestoreOption',
157-
'handleSaveToComputer',
157+
'getSaveToComputerHandler',
158158
'restoreOptionMessage'
159159
]);
160160
}
@@ -225,7 +225,7 @@ class MenuBar extends React.Component {
225225
event.preventDefault();
226226
}
227227
}
228-
handleSaveToComputer (downloadProjectCallback) {
228+
getSaveToComputerHandler (downloadProjectCallback) {
229229
return () => {
230230
this.props.onRequestCloseFile();
231231
downloadProjectCallback();
@@ -327,7 +327,7 @@ class MenuBar extends React.Component {
327327
[styles.clickable]: typeof this.props.onClickLogo !== 'undefined'
328328
})}
329329
draggable={false}
330-
src={this.props.logo ? this.props.logo : scratchLogo}
330+
src={this.props.logo}
331331
onClick={this.props.onClickLogo}
332332
/>
333333
</div>
@@ -374,21 +374,21 @@ class MenuBar extends React.Component {
374374
</MenuSection>
375375
{(this.props.canSave || this.props.canCreateCopy || this.props.canRemix) && (
376376
<MenuSection>
377-
{this.props.canSave ? (
377+
{this.props.canSave && (
378378
<MenuItem onClick={this.handleClickSave}>
379379
{saveNowMessage}
380380
</MenuItem>
381-
) : []}
382-
{this.props.canCreateCopy ? (
381+
)}
382+
{this.props.canCreateCopy && (
383383
<MenuItem onClick={this.handleClickSaveAsCopy}>
384384
{createCopyMessage}
385385
</MenuItem>
386-
) : []}
387-
{this.props.canRemix ? (
386+
)}
387+
{this.props.canRemix && (
388388
<MenuItem onClick={this.handleClickRemix}>
389389
{remixMessage}
390390
</MenuItem>
391-
) : []}
391+
)}
392392
</MenuSection>
393393
)}
394394
<MenuSection>
@@ -397,10 +397,10 @@ class MenuBar extends React.Component {
397397
userOwnsProject={this.props.userOwnsProject}
398398
onUpdateProjectTitle={this.props.onUpdateProjectTitle}
399399
>
400-
{(className, renderFileInput, loadProject) => (
400+
{(className, renderFileInput, handleLoadProject) => (
401401
<MenuItem
402402
className={className}
403-
onClick={loadProject}
403+
onClick={handleLoadProject}
404404
>
405405
{/* eslint-disable max-len */}
406406
{this.props.intl.formatMessage(sharedMessages.loadFromComputerTitle)}
@@ -412,7 +412,7 @@ class MenuBar extends React.Component {
412412
<SB3Downloader>{(className, downloadProjectCallback) => (
413413
<MenuItem
414414
className={className}
415-
onClick={this.handleSaveToComputer(downloadProjectCallback)}
415+
onClick={this.getSaveToComputerHandler(downloadProjectCallback)}
416416
>
417417
<FormattedMessage
418418
defaultMessage="Save to your computer"
@@ -758,6 +758,7 @@ MenuBar.propTypes = {
758758
};
759759

760760
MenuBar.defaultProps = {
761+
logo: scratchLogo,
761762
onShare: () => {}
762763
};
763764

src/containers/sb-file-uploader.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ import {
2626
/**
2727
* SBFileUploader component passes a file input, load handler and props to its child.
2828
* It expects this child to be a function with the signature
29-
* function (renderFileInput, loadProject) {}
29+
* function (renderFileInput, handleLoadProject) {}
3030
* The component can then be used to attach project loading functionality
3131
* to any other component:
3232
*
33-
* <SBFileUploader>{(renderFileInput, loadProject) => (
33+
* <SBFileUploader>{(className, renderFileInput, handleLoadProject) => (
3434
* <MyCoolComponent
35-
* onClick={loadProject}
35+
* className={className}
36+
* onClick={handleLoadProject}
3637
* >
3738
* {renderFileInput()}
3839
* </MyCoolComponent>

0 commit comments

Comments
 (0)