From 9a03c330b6fee10e9f86fc888ef654d842378283 Mon Sep 17 00:00:00 2001 From: Connor Hudson <technoboy10@users.noreply.github.com> Date: Thu, 9 Aug 2018 17:54:43 -0400 Subject: [PATCH] Add hideIntro prop to GUI component (#2831) * Don't show intro modal if hideIntro passed to PreviewModal * Add hideIntro prop to GUI * Move intro modal hiding logic into its own function --- src/components/gui/gui.jsx | 4 +++- src/containers/preview-modal.jsx | 27 +++++++++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/components/gui/gui.jsx b/src/components/gui/gui.jsx index c3b7cff71..c7859c5aa 100644 --- a/src/components/gui/gui.jsx +++ b/src/components/gui/gui.jsx @@ -62,6 +62,7 @@ const GUIComponent = props => { costumeLibraryVisible, costumesTabVisible, enableCommunity, + hideIntro, importInfoVisible, intl, isPlayerOnly, @@ -115,7 +116,7 @@ const GUIComponent = props => { {...componentProps} > {previewInfoVisible ? ( - <PreviewModal /> + <PreviewModal hideIntro={hideIntro} /> ) : null} {loading ? ( <Loader /> @@ -281,6 +282,7 @@ GUIComponent.propTypes = { costumeLibraryVisible: PropTypes.bool, costumesTabVisible: PropTypes.bool, enableCommunity: PropTypes.bool, + hideIntro: PropTypes.bool, importInfoVisible: PropTypes.bool, intl: intlShape.isRequired, isPlayerOnly: PropTypes.bool, diff --git a/src/containers/preview-modal.jsx b/src/containers/preview-modal.jsx index dd1ca6701..a53f398ee 100644 --- a/src/containers/preview-modal.jsx +++ b/src/containers/preview-modal.jsx @@ -27,6 +27,25 @@ class PreviewModal extends React.Component { previewing: false }; } + + /** + * Conditionally returns an intro modal depending on the hideIntro prop + * @returns { React.Component | null } null if hideIntro is true, the intro modal component otherwise + */ + introIfShown () { + if (this.props.hideIntro) { + return null; // If hideIntro is true, the intro modal should not appear + } + + // otherwise, show the intro modal + return (<PreviewModalComponent + previewing={this.state.previewing} + onCancel={this.handleCancel} + onTryIt={this.handleTryIt} + onViewProject={this.handleViewProject} + />); + + } handleTryIt () { this.setState({previewing: true}); // try to run in fullscreen mode on tablets. @@ -41,12 +60,7 @@ class PreviewModal extends React.Component { } render () { return (supportedBrowser() ? - <PreviewModalComponent - previewing={this.state.previewing} - onCancel={this.handleCancel} - onTryIt={this.handleTryIt} - onViewProject={this.handleViewProject} - /> : + this.introIfShown() : <BrowserModalComponent onBack={this.handleCancel} /> @@ -55,6 +69,7 @@ class PreviewModal extends React.Component { } PreviewModal.propTypes = { + hideIntro: PropTypes.bool, onTryIt: PropTypes.func, onViewProject: PropTypes.func }; -- GitLab