Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My Home: Add "Connect social media accounts" Task #41018

Merged
merged 16 commits into from
Apr 16, 2020
2 changes: 2 additions & 0 deletions client/layout/guided-tours/all-tours.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { JetpackSignInTour } from './tours/jetpack-sign-in-tour';
import { JetpackSiteAcceleratorTour } from './tours/jetpack-site-accelerator-tour';
import { JetpackVideoHostingTour } from './tours/jetpack-video-hosting-tour';
import { MainTour } from './tours/main-tour';
import { marketingConnectionsTour } from './tours/marketing-connections-tour';
import { MediaBasicsTour } from './tours/media-basics-tour';
import { SimplePaymentsEmailTour } from './tours/simple-payments-email-tour';
import { SimplePaymentsTour } from './tours/simple-payments-tour';
Expand All @@ -35,6 +36,7 @@ export default combineTours( {
jetpackSiteAccelerator: JetpackSiteAcceleratorTour,
jetpackVideoHosting: JetpackVideoHostingTour,
main: MainTour,
marketingConnectionsTour: marketingConnectionsTour,
mediaBasicsTour: MediaBasicsTour,
simplePaymentsEmailTour: SimplePaymentsEmailTour,
simplePaymentsTour: SimplePaymentsTour,
Expand Down
2 changes: 2 additions & 0 deletions client/layout/guided-tours/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import tutorialSitePreview from 'layout/guided-tours/tours/tutorial-site-preview
import gdocsIntegrationTour from 'layout/guided-tours/tours/gdocs-integration-tour/meta';
import simplePaymentsTour from 'layout/guided-tours/tours/simple-payments-tour/meta';
import editorBasicsTour from 'layout/guided-tours/tours/editor-basics-tour/meta';
import marketingConnectionsTour from 'layout/guided-tours/tours/marketing-connections-tour/meta';
import mediaBasicsTour from 'layout/guided-tours/tours/media-basics-tour/meta';
import checklistSiteTitle from 'layout/guided-tours/tours/checklist-site-title-tour/meta';
import jetpackBackupsRewind from 'layout/guided-tours/tours/jetpack-backups-rewind-tour/meta';
Expand All @@ -32,6 +33,7 @@ export default {
jetpackVideoHosting,
main,
editorBasicsTour,
marketingConnectionsTour,
mediaBasicsTour,
tutorialSitePreview,
gdocsIntegrationTour,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* External dependencies
*/
import React from 'react';

/**
* Internal dependencies
*/
import meta from './meta';
import { ButtonRow, makeTour, Quit, Link, Step, Tour } from 'layout/guided-tours/config-elements';
import { localizeUrl } from 'lib/i18n-utils';

export const marketingConnectionsTour = makeTour(
<Tour { ...meta }>
<Step
arrow="right-middle"
name="init"
placement="beside"
style={ {
marginLeft: '-24px',
} }
target={ '.sharing-service.not-connected .button.is-compact' }
>
{ ( { translate } ) => (
<>
<p>
{ translate(
"Select the service which you'd like to connect. " +
'Whenever you publish a new post, your social media followers will receive an update.'
) }
</p>
<ButtonRow>
<Link href={ localizeUrl( 'https://wordpress.com/support/publicize/' ) }>
Aurorum marked this conversation as resolved.
Show resolved Hide resolved
{ translate( 'Learn more' ) }
</Link>
<Quit primary>{ translate( 'Got it' ) }</Quit>
</ButtonRow>
</>
) }
</Step>
</Tour>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* External dependencies
*/
import { isDesktop } from '@automattic/viewport';

export default {
name: 'marketingConnectionsTour',
version: '20200410',
path: [ '/marketing/connections/' ],
when: isDesktop,
};
101 changes: 101 additions & 0 deletions client/my-sites/customer-home/cards/tasks/connect-accounts.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**
* External dependencies
*/
import React, { useState } from 'react';
import { useTranslate } from 'i18n-calypso';
import { connect } from 'react-redux';
import { Button } from '@automattic/components';
import { isMobile } from '@automattic/viewport';

/**
* Internal dependencies
*/
import ActionPanel from 'components/action-panel';
import ActionPanelTitle from 'components/action-panel/title';
import ActionPanelBody from 'components/action-panel/body';
import ActionPanelFigure from 'components/action-panel/figure';
import ActionPanelCta from 'components/action-panel/cta';
import Gridicon from 'components/gridicon';
import QueryPublicizeConnections from 'components/data/query-publicize-connections';
import { getSelectedSiteId, getSelectedSiteSlug } from 'state/ui/selectors';
import { savePreference } from 'state/preferences/actions';

/**
* Style dependencies
*/
import './style.scss';

const ConnectAccountsTask = ( { skipTask, siteSlug } ) => {
const translate = useTranslate();
const [ isVisible, setIsVisible ] = useState( true );

if ( ! isVisible ) {
return null;
}
return (
<ActionPanel className="tasks connect-accounts">
<QueryPublicizeConnections selectedSite />
<ActionPanelBody>
{ ! isMobile() && (
<ActionPanelFigure align="right">
<img src="/calypso/images/stats/tasks/social-links.svg" alt="" />
</ActionPanelFigure>
) }
<div className="tasks__timing">
<Gridicon icon="time" size={ 18 } />
<p>{ translate( '3 minutes' ) }</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we please not hardcode values into translatable strings? This should be

translate( '%d minute', '%d minutes', { count: 3, arguments: [ 3 ] } )

like it's done in all the other places where we already do this, for example here: https://github.com/Automattic/wp-calypso/blob/master/client/my-sites/customer-home/cards/tasks/checklist-site-setup/wpcom-checklist/component.jsx#L263

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, thank you! I opened #41271 to address that. :)

</div>
<ActionPanelTitle>{ translate( 'Drive traffic to your site' ) }</ActionPanelTitle>
Aurorum marked this conversation as resolved.
Show resolved Hide resolved
mmtr marked this conversation as resolved.
Show resolved Hide resolved
<p className="tasks__description">
{ translate(
'Integrate your site with social media to automatically post your content and drive traffic to your site.'
) }
</p>
<ActionPanelCta>
<Button
className="tasks__action"
primary
href={
isMobile()
mmtr marked this conversation as resolved.
Show resolved Hide resolved
? `/marketing/connections/${ siteSlug }`
: `/marketing/connections/${ siteSlug }?tour=marketingConnectionsTour`
}
>
{ translate( 'Connect accounts' ) }
Aurorum marked this conversation as resolved.
Show resolved Hide resolved
</Button>
<Button
className="tasks__action-skip is-link"
onClick={ () => {
setIsVisible( false );
skipTask();
} }
>
{ translate( 'Skip for now' ) }
</Button>
</ActionPanelCta>
</ActionPanelBody>
</ActionPanel>
);
};

const mapStateToProps = state => {
return {
siteId: getSelectedSiteId( state ),
siteSlug: getSelectedSiteSlug( state ),
};
};

const mapDispatchToProps = {
skipTask: siteId =>
savePreference( `dismissible-card-home-task-connect-accounts-${ siteId }`, true ),
};

const mergeProps = ( stateProps, dispatchProps, ownProps ) => {
return {
...stateProps,
skipTask: () => dispatchProps.skipTask( stateProps.siteId ),
...ownProps,
};
};

export default connect( mapStateToProps, mapDispatchToProps, mergeProps )( ConnectAccountsTask );
30 changes: 30 additions & 0 deletions client/my-sites/customer-home/cards/tasks/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.tasks.action-panel {
.tasks__timing {
display: flex;

.gridicon {
margin-right: 4px;
}
}

.action-panel__title {
font-family: 'Recoleta', serif;
Aurorum marked this conversation as resolved.
Show resolved Hide resolved
font-size: 36px;
}

.action-panel__figure {
max-width: 280px;
}

.tasks__description {
font-size: 16px;
}

.action-panel__cta {
display: flex;

.tasks__action-skip {
margin: auto 16px;
}
}
}
2 changes: 2 additions & 0 deletions client/my-sites/customer-home/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import QueryHomeLayout from 'components/data/query-home-layout';
import { getHomeLayout } from 'state/selectors/get-home-layout';
import Notices from 'my-sites/customer-home/locations/notices';
import Upsells from 'my-sites/customer-home/locations/upsells';
import ConnectAccountsTask from 'my-sites/customer-home/cards/tasks/connect-accounts';
import Primary from 'my-sites/customer-home/locations/primary';
import Secondary from 'my-sites/customer-home/locations/secondary';

Expand Down Expand Up @@ -93,6 +94,7 @@ const Home = ( {
displayChecklist={ displayChecklist }
/>
<Upsells cards={ layout.upsells } />
{ ! displayChecklist && <ConnectAccountsTask /> }
mmtr marked this conversation as resolved.
Show resolved Hide resolved
{ hasChecklistData && (
<div className="customer-home__layout">
<div className="customer-home__layout-col customer-home__layout-col-left">
Expand Down