From 6bf9fac393c619edfd838a06cbd27c79145147e9 Mon Sep 17 00:00:00 2001 From: Chris Garrity Date: Mon, 22 Jul 2019 12:11:07 -0400 Subject: [PATCH] addressing comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add scratchLogo as default for logo prop * prefer `{featureAllowed && ()} 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`) --- src/components/menu-bar/menu-bar.jsx | 25 +++++++++++++------------ src/containers/sb-file-uploader.jsx | 7 ++++--- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/components/menu-bar/menu-bar.jsx b/src/components/menu-bar/menu-bar.jsx index 0222e2bab..1fa7a01cc 100644 --- a/src/components/menu-bar/menu-bar.jsx +++ b/src/components/menu-bar/menu-bar.jsx @@ -154,7 +154,7 @@ class MenuBar extends React.Component { 'handleKeyPress', 'handleLanguageMouseUp', 'handleRestoreOption', - 'handleSaveToComputer', + 'getSaveToComputerHandler', 'restoreOptionMessage' ]); } @@ -225,7 +225,7 @@ class MenuBar extends React.Component { event.preventDefault(); } } - handleSaveToComputer (downloadProjectCallback) { + getSaveToComputerHandler (downloadProjectCallback) { return () => { this.props.onRequestCloseFile(); downloadProjectCallback(); @@ -327,7 +327,7 @@ class MenuBar extends React.Component { [styles.clickable]: typeof this.props.onClickLogo !== 'undefined' })} draggable={false} - src={this.props.logo ? this.props.logo : scratchLogo} + src={this.props.logo} onClick={this.props.onClickLogo} /> @@ -374,21 +374,21 @@ class MenuBar extends React.Component { {(this.props.canSave || this.props.canCreateCopy || this.props.canRemix) && ( - {this.props.canSave ? ( + {this.props.canSave && ( {saveNowMessage} - ) : []} - {this.props.canCreateCopy ? ( + )} + {this.props.canCreateCopy && ( {createCopyMessage} - ) : []} - {this.props.canRemix ? ( + )} + {this.props.canRemix && ( {remixMessage} - ) : []} + )} )} @@ -397,10 +397,10 @@ class MenuBar extends React.Component { userOwnsProject={this.props.userOwnsProject} onUpdateProjectTitle={this.props.onUpdateProjectTitle} > - {(className, renderFileInput, loadProject) => ( + {(className, renderFileInput, handleLoadProject) => ( {/* eslint-disable max-len */} {this.props.intl.formatMessage(sharedMessages.loadFromComputerTitle)} @@ -412,7 +412,7 @@ class MenuBar extends React.Component { {(className, downloadProjectCallback) => ( {} }; diff --git a/src/containers/sb-file-uploader.jsx b/src/containers/sb-file-uploader.jsx index 771ce29b4..ae5f42915 100644 --- a/src/containers/sb-file-uploader.jsx +++ b/src/containers/sb-file-uploader.jsx @@ -26,13 +26,14 @@ import { /** * SBFileUploader component passes a file input, load handler and props to its child. * It expects this child to be a function with the signature - * function (renderFileInput, loadProject) {} + * function (renderFileInput, handleLoadProject) {} * The component can then be used to attach project loading functionality * to any other component: * - * {(renderFileInput, loadProject) => ( + * {(className, renderFileInput, handleLoadProject) => ( * * {renderFileInput()} *