From a06d92449381bf732ef6b997756ba684d20e9071 Mon Sep 17 00:00:00 2001 From: Rish Date: Fri, 15 Feb 2019 14:05:03 +0530 Subject: [PATCH] Updated members modal UI structure no issue --- .../static/auth/components/Modal.js | 47 +++++++++---------- .../static/auth/components/Pages.js | 14 ++++-- .../auth/pages/PasswordResetSentPage.js | 22 ++++----- .../auth/pages/RequestPasswordResetPage.js | 18 +++---- .../static/auth/pages/ResetPasswordPage.js | 18 +++---- .../static/auth/pages/SigninPage.js | 31 +++++------- .../static/auth/pages/SignupPage.js | 25 +++++----- .../static/auth/pages/StripePaymentPage.js | 46 ++++++++---------- 8 files changed, 100 insertions(+), 121 deletions(-) diff --git a/ghost/members-api/static/auth/components/Modal.js b/ghost/members-api/static/auth/components/Modal.js index 44d1f83c46..72f5b53f8a 100644 --- a/ghost/members-api/static/auth/components/Modal.js +++ b/ghost/members-api/static/auth/components/Modal.js @@ -8,6 +8,7 @@ import RequestPasswordResetPage from '../pages/RequestPasswordResetPage'; import PasswordResetSentPage from '../pages/PasswordResetSentPage'; import ResetPasswordPage from '../pages/ResetPasswordPage'; import StripePaymentPage from '../pages/StripePaymentPage'; +import { IconClose } from '../components/icons'; export default class Modal extends Component { constructor(props, context) { @@ -23,9 +24,9 @@ export default class Modal extends Component { return; } this.context.members.getConfig().then(paymentConfig => { - this.setState({paymentConfig, loadingConfig: false}); + this.setState({ paymentConfig, loadingConfig: false }); }).catch((error) => { - this.setState({error, loadingConfig: false}); + this.setState({ error, loadingConfig: false }); }); } @@ -37,42 +38,38 @@ export default class Modal extends Component { promise.then((success) => { this.close(success); }, (error) => { - this.setState({error}); + this.setState({ error }); }); } - renderSignupPage(state) { - const { error, paymentConfig } = state; - const { members } = this.context; - const signup = (data) => this.handleAction(members.signup(data)); - const closeModal = () => this.close(); - const createAccountWithSubscription = (data) => this.handleAction( - members.signup(data).then(() => { - members.createSubscription(data); - }) - ); - const stripeConfig = paymentConfig && paymentConfig.find(({adapter}) => adapter === 'stripe'); + renderSignupPage({error, stripeConfig, members, signup, closeModal}) { + if (stripeConfig) { - return + const createAccountWithSubscription = (data) => this.handleAction( + members.signup(data).then(() => { + members.createSubscription(data); + }) + ); + return } return ( - + ) } render(props, state) { - const { queryToken } = props; const { containerClass, error, loadingConfig, paymentConfig } = state; const { members } = this.context; const closeModal = () => this.close(); - const clearError = () => this.setState({error: null}); + const clearError = () => this.setState({ error: null }); const signin = (data) => this.handleAction(members.signin(data)); const signup = (data) => this.handleAction(members.signup(data)); const requestReset = (data) => this.handleAction(members.requestPasswordReset(data)); const resetPassword = (data) => this.handleAction(members.resetPassword(data)); + const stripeConfig = paymentConfig && paymentConfig.find(({ adapter }) => adapter === 'stripe'); if (loadingConfig) { return ( @@ -82,13 +79,13 @@ export default class Modal extends Component { ); } return ( - - - - {this.renderSignupPage(state)} - - - + + + + {this.renderSignupPage({error, stripeConfig, members, signup, closeModal})} + + + ); } diff --git a/ghost/members-api/static/auth/components/Pages.js b/ghost/members-api/static/auth/components/Pages.js index bfc9f2bf46..c847d7916b 100644 --- a/ghost/members-api/static/auth/components/Pages.js +++ b/ghost/members-api/static/auth/components/Pages.js @@ -5,7 +5,7 @@ export default class Pages extends Component { super(props); this.state = this.getStateFromBrowser(); window.addEventListener("hashchange", () => this.onHashChange(), false); - this.handleChange = props.onChange || (() => {}); + this.handleChange = props.onChange || (() => { }); } getStateFromBrowser() { @@ -31,10 +31,18 @@ export default class Pages extends Component { }); } - render({children, className, onClick}, state) { + render({ children, className, onClick, stripeConfig }, state) { + let modalClassName = "gm-modal gm-auth-modal"; + if (state.hash === 'signup' && stripeConfig) { + modalClassName += " gm-subscribe-modal" + } return (
- { this.filterChildren(children, state) } +
+
e.stopPropagation()}> + {this.filterChildren(children, state)} +
+
); } diff --git a/ghost/members-api/static/auth/pages/PasswordResetSentPage.js b/ghost/members-api/static/auth/pages/PasswordResetSentPage.js index 9e8a134e85..06af5092f1 100644 --- a/ghost/members-api/static/auth/pages/PasswordResetSentPage.js +++ b/ghost/members-api/static/auth/pages/PasswordResetSentPage.js @@ -1,18 +1,14 @@ import FormHeader from '../components/FormHeader'; import FormSubmit from '../components/FormSubmit'; -import { IconClose } from '../components/icons'; -export default ({error, handleClose, handleSubmit}) => ( -
-
e.stopPropagation()}> - { IconClose } - -
-
-

We’ve sent a recovery email to your inbox. Follow the link in the email to reset your password.

-
- - -
+export default ({ error, handleSubmit }) => ( +
+ +
+
+

We’ve sent a recovery email to your inbox. Follow the link in the email to reset your password.

+
+ +
); diff --git a/ghost/members-api/static/auth/pages/RequestPasswordResetPage.js b/ghost/members-api/static/auth/pages/RequestPasswordResetPage.js index 5256eadf56..a36f0b9f88 100644 --- a/ghost/members-api/static/auth/pages/RequestPasswordResetPage.js +++ b/ghost/members-api/static/auth/pages/RequestPasswordResetPage.js @@ -1,19 +1,15 @@ import FormHeader from '../components/FormHeader'; import EmailInput from '../components/EmailInput'; import FormSubmit from '../components/FormSubmit'; -import { IconClose } from '../components/icons'; import Form from '../components/Form'; -export default ({error, handleClose, handleSubmit}) => ( -
-
e.stopPropagation()}> - { IconClose } - -
- - - -
+export default ({ error, handleClose, handleSubmit }) => ( +
+ +
+ + +
); diff --git a/ghost/members-api/static/auth/pages/ResetPasswordPage.js b/ghost/members-api/static/auth/pages/ResetPasswordPage.js index 84a92227ef..1a688ca357 100644 --- a/ghost/members-api/static/auth/pages/ResetPasswordPage.js +++ b/ghost/members-api/static/auth/pages/ResetPasswordPage.js @@ -2,7 +2,6 @@ import FormHeader from '../components/FormHeader'; import PasswordInput from '../components/PasswordInput'; import FormSubmit from '../components/FormSubmit'; import Form from '../components/Form'; -import { IconClose } from '../components/icons'; const getTokenData = frameLocation => { const params = new URLSearchParams(frameLocation.query); @@ -11,15 +10,12 @@ const getTokenData = frameLocation => { }; -export default ({error, frameLocation, handleClose, handleSubmit}) => ( -
-
e.stopPropagation()}> - { IconClose } - -
- - - -
+export default ({ error, frameLocation, handleSubmit }) => ( +
+ +
+ + +
); diff --git a/ghost/members-api/static/auth/pages/SigninPage.js b/ghost/members-api/static/auth/pages/SigninPage.js index a6f1adec62..7fd759d2b5 100644 --- a/ghost/members-api/static/auth/pages/SigninPage.js +++ b/ghost/members-api/static/auth/pages/SigninPage.js @@ -6,24 +6,19 @@ import FormSubmit from '../components/FormSubmit'; import EmailInput from '../components/EmailInput'; import PasswordInput from '../components/PasswordInput'; -import { IconClose } from '../components/icons'; - -export default ({error, handleClose, handleSubmit}) => ( -
- ); diff --git a/ghost/members-api/static/auth/pages/SignupPage.js b/ghost/members-api/static/auth/pages/SignupPage.js index 3c23d7a6e2..82a973eb9f 100644 --- a/ghost/members-api/static/auth/pages/SignupPage.js +++ b/ghost/members-api/static/auth/pages/SignupPage.js @@ -8,19 +8,16 @@ import EmailInput from '../components/EmailInput'; import PasswordInput from '../components/PasswordInput'; import { IconClose } from '../components/icons'; -export default ({error, handleClose, handleSubmit}) => ( -
-
e.stopPropagation()}> - { IconClose } - - - -
- - - - - -
+export default ({ error, handleClose, handleSubmit }) => ( +
+ + + +
+ + + + +
); diff --git a/ghost/members-api/static/auth/pages/StripePaymentPage.js b/ghost/members-api/static/auth/pages/StripePaymentPage.js index af807dcf5f..6d9a953b71 100644 --- a/ghost/members-api/static/auth/pages/StripePaymentPage.js +++ b/ghost/members-api/static/auth/pages/StripePaymentPage.js @@ -3,7 +3,6 @@ import { Component } from 'react'; import FormHeader from '../components/FormHeader'; import FormSubmit from '../components/FormSubmit'; import FormHeaderCTA from '../components/FormHeaderCTA'; -import { IconClose } from '../components/icons'; import NameInput from '../components/NameInput'; import EmailInput from '../components/EmailInput'; import PasswordInput from '../components/PasswordInput'; @@ -72,9 +71,9 @@ export default class StripePaymentPage extends Component {
) @@ -106,11 +105,11 @@ export default class StripePaymentPage extends Component { } return (
-
+
-
- The Blueprint - Subscription +
+ The Blueprint + Subscription
@@ -119,27 +118,22 @@ export default class StripePaymentPage extends Component { ) } - render({ error, handleClose, handleSubmit, stripeConfig }) { + render({ error, handleSubmit, stripeConfig }) { const publicKey = stripeConfig.config.publicKey || ''; return ( -
-
e.stopPropagation()}> - {IconClose} -
-
- - - - - - - - -
-
- {this.renderPlansSection()} -
+
+
+ + + + + + + +
+
+ {this.renderPlansSection()}
) }