diff --git a/ghost/portal/src/components/PopupModal.js b/ghost/portal/src/components/PopupModal.js index 3baf49ac39..13b6599a6e 100644 --- a/ghost/portal/src/components/PopupModal.js +++ b/ghost/portal/src/components/PopupModal.js @@ -35,19 +35,6 @@ const Styles = { height: '60%', backgroundColor: 'white' }, - menu: { - position: 'fixed', - padding: '0', - outline: '0', - bottom: '100px', - right: '20px', - borderRadius: '8px', - boxShadow: 'rgba(0, 0, 0, 0.16) 0px 5px 40px', - opacity: '1', - overflow: 'hidden', - height: '60%', - backgroundColor: 'white' - }, signin: { minHeight: '200px', maxHeight: '330px' @@ -57,9 +44,9 @@ const Styles = { maxHeight: '620px' }, accountHome: { - width: '280px', - minHeight: '200px', - maxHeight: '240px' + width: '500px', + minHeight: '300px', + maxHeight: '350px' }, magiclink: { minHeight: '230px', @@ -144,9 +131,8 @@ export default class PopupModal extends React.Component { renderFrameContainer() { const page = this.context.page; - const commonStyle = this.context.page === 'accountHome' ? Styles.frame.menu : Styles.frame.common; const frameStyle = { - ...commonStyle, + ...Styles.frame.common, ...Styles.frame[page] }; return ( diff --git a/ghost/portal/src/components/pages/AccountHomePage.js b/ghost/portal/src/components/pages/AccountHomePage.js index 0fe227a7bd..0ac7f50ac8 100644 --- a/ghost/portal/src/components/pages/AccountHomePage.js +++ b/ghost/portal/src/components/pages/AccountHomePage.js @@ -1,4 +1,6 @@ import {ParentContext} from '../ParentContext'; +import MemberAvatar from '../common/MemberGravatar'; +import ActionButton from '../common/ActionButton'; const React = require('react'); @@ -10,108 +12,6 @@ export default class AccountHomePage extends React.Component { this.context.onAction('signout'); } - handlePlanCheckout(e) { - e.preventDefault(); - const plan = e.target.name; - const email = this.context.member.email; - this.context.onAction('checkoutPlan', {email, plan}); - } - - renderPlanSelectButton({name}) { - const buttonStyle = { - display: 'inline-block', - height: '38px', - border: '0', - fontSize: '14px', - fontWeight: '300', - textAlign: 'center', - textDecoration: 'none', - whiteSpace: 'nowrap', - borderRadius: '5px', - cursor: 'pointer', - transition: '.4s ease', - color: '#fff', - backgroundColor: this.context.brandColor, - boxShadow: 'none', - userSelect: 'none', - width: '90px', - marginBottom: '12px' - }; - - return ( - - ); - } - - renderPlanBox({position, id, type, price, currency, name}) { - const boxStyle = (position) => { - const style = { - padding: '12px 24px', - flexBasis: '100%' - }; - if (position !== 'last') { - style.borderRight = '1px solid black'; - } - return style; - }; - - const nameStyle = { - fontSize: '14px', - fontWeight: 'bold', - display: 'flex', - justifyContent: 'center' - }; - - const priceStyle = { - fontSize: '12px', - fontWeight: 'bold', - display: 'flex', - justifyContent: 'center', - marginBottom: '9px' - }; - const checkboxStyle = { - display: 'flex', - justifyContent: 'center' - }; - - return ( -
-
{name}
-
- {currency} {price} - {` / ${type}`} -
-
{this.renderPlanSelectButton({name})}
-
- ); - } - - renderPlans() { - const containerStyle = { - display: 'flex', - border: '1px solid black', - marginBottom: '12px' - }; - const siteTitle = this.context.site.title; - const plans = this.context.site.plans; - return ( -
-
- {`Hey there! You are subscribed to free updates from ${siteTitle}, but don't have a paid subscription to unlock full access`} -
-
Choose a Plan
-
- {this.renderPlanBox({position: 'first', type: 'month', price: plans.monthly, currency: plans.currency_symbol, name: 'Monthly'})} - {this.renderPlanBox({position: 'last', type: 'year', price: plans.yearly, currency: plans.currency_symbol, name: 'Yearly'})} -
-
- ); - } - renderHeader() { const memberEmail = this.context.member.email; @@ -130,43 +30,65 @@ export default class AccountHomePage extends React.Component { renderUserAvatar() { const avatarImg = (this.context.member && this.context.member.avatar_image); - const logoStyle = { + const avatarContainerStyle = { position: 'relative', - display: 'block', + display: 'flex', width: '64px', height: '64px', marginBottom: '6px', - backgroundPosition: '50%', - backgroundSize: 'cover', borderRadius: '100%', boxShadow: '0 0 0 3px #fff', - border: '1px solid gray' + border: '1px solid gray', + overflow: 'hidden', + justifyContent: 'center', + alignItems: 'center' }; - if (avatarImg) { - logoStyle.backgroundImage = `url(${avatarImg})`; - return ( - - ); - } - return null; - } - - renderUserHeader() { - const memberEmail = this.context.member.email; - const memberName = this.context.member.name; - return ( -
- {this.renderUserAvatar()} - {memberName ?
{memberName}
: null} -
{memberEmail}
+
+
); } - handleAccountDetail(e) { - // No-op + renderUserHeader() { + return ( +
+ {this.renderUserAvatar()} +
Your Account
+
+ ); + } + + openSettings(e) { + // no-op + } + + renderAccountFooter() { + return ( +
+
Contact support
+
+
this.openSettings(e)} role='button'> Settings
+
this.handleSignout(e)} role='button'> Logout
+
+
+ ); + } + + renderAccountDetail(e) { + const {name, firstname, email} = this.context.member; + const siteTitle = this.context.site.title; + + return ( +
+
+ Hey {firstname || name || email}! + You are subscribed to free updates from {siteTitle}, but you don't have a paid subscription to unlock full access +
+ {}} brandColor={this.context.brandColor} /> +
+ ); } renderLogoutButton() { @@ -184,10 +106,11 @@ export default class AccountHomePage extends React.Component { render() { return ( -
+
{this.renderUserHeader()} - {this.renderLogoutButton()} + {this.renderAccountDetail()} + {this.renderAccountFooter()}
); } -} +} \ No newline at end of file diff --git a/ghost/portal/src/components/pages/AccountHomePage.test.js b/ghost/portal/src/components/pages/AccountHomePage.test.js index 4e9547f744..d5d29b245b 100644 --- a/ghost/portal/src/components/pages/AccountHomePage.test.js +++ b/ghost/portal/src/components/pages/AccountHomePage.test.js @@ -6,11 +6,13 @@ const setup = (overrides) => { const {mockOnActionFn, ...utils} = render( ); - const memberEmail = utils.getByText('member@example.com'); - const logoutButton = utils.queryByRole('button', {name: 'Log out'}); + const logoutBtn = utils.queryByRole('button', {name: 'Logout'}); + const settingsBtn = utils.queryByRole('button', {name: 'Settings'}); + const supportBtn = utils.queryByRole('button', {name: 'Contact support'}); return { - memberEmail, - logoutButton, + logoutBtn, + settingsBtn, + supportBtn, mockOnActionFn, ...utils }; @@ -18,16 +20,17 @@ const setup = (overrides) => { describe('Account Home Page', () => { test('renders', () => { - const {memberEmail, logoutButton} = setup(); + const {settingsBtn, supportBtn, logoutBtn} = setup(); - expect(memberEmail).toBeInTheDocument(); - expect(logoutButton).toBeInTheDocument(); + expect(settingsBtn).toBeInTheDocument(); + expect(logoutBtn).toBeInTheDocument(); + expect(supportBtn).toBeInTheDocument(); }); test('can call signout', () => { - const {mockOnActionFn, logoutButton} = setup(); + const {mockOnActionFn, logoutBtn} = setup(); - fireEvent.click(logoutButton); + fireEvent.click(logoutBtn); expect(mockOnActionFn).toHaveBeenCalledWith('signout'); }); });