Skip to content

Commit

Permalink
Adds sales and download page for Traffic Guide
Browse files Browse the repository at this point in the history
  • Loading branch information
aneeshd16 committed Dec 11, 2020
1 parent dfc3958 commit 0a8524b
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 1 deletion.
7 changes: 7 additions & 0 deletions client/my-sites/marketing/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Sharing from './main';
import SharingButtons from './buttons/buttons';
import SharingConnections from './connections/connections';
import Traffic from './traffic/';
import UltimateTrafficGuide from './ultimate-traffic-guide';
import { requestSite } from 'calypso/state/sites/actions';
import {
getSiteSlug,
Expand Down Expand Up @@ -133,3 +134,9 @@ export const traffic = ( context, next ) => {

next();
};

export const ultimateTrafficGuide = ( context, next ) => {
context.contentComponent = createElement( UltimateTrafficGuide );

next();
};
13 changes: 13 additions & 0 deletions client/my-sites/marketing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
redirectSharingButtons,
sharingButtons,
traffic,
ultimateTrafficGuide,
} from './controller';
import { makeLayout, render as clientRender } from 'calypso/controller';

Expand All @@ -27,6 +28,7 @@ export default function () {
'/marketing/sharing-buttons',
'/marketing/tools',
'/marketing/traffic',
'/marketing/ultimate-traffic-guide',
'/sharing',
'/sharing/buttons',
];
Expand Down Expand Up @@ -81,4 +83,15 @@ export default function () {
makeLayout,
clientRender
);

page(
'/marketing/ultimate-traffic-guide/:domain',
siteSelection,
sites,
navigation,
ultimateTrafficGuide,
layout,
makeLayout,
clientRender
);
}
4 changes: 4 additions & 0 deletions client/my-sites/marketing/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ export const marketingTraffic = ( siteSlug?: string | null ): string => {
export const marketingSharingButtons = ( siteSlug?: string | null ): string => {
return `/marketing/sharing-buttons/${ siteSlug || '' }`;
};

export const marketingUltimateTrafficGuide = ( siteSlug?: string | null ): string => {
return `/marketing/ultimate-traffic-guide/${ siteSlug || '' }`;
};
22 changes: 21 additions & 1 deletion client/my-sites/marketing/tools/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import { Button } from '@automattic/components';
import { getSelectedSiteSlug } from 'calypso/state/ui/selectors';
import MarketingToolsFeature from './feature';
import MarketingToolsHeader from './header';
import { marketingConnections, marketingTraffic } from 'calypso/my-sites/marketing/paths';
import {
marketingConnections,
marketingTraffic,
marketingUltimateTrafficGuide,
} from 'calypso/my-sites/marketing/paths';
import PageViewTracker from 'calypso/lib/analytics/page-view-tracker';
import { recordTracksEvent as recordTracksEventAction } from 'calypso/state/analytics/actions';

Expand Down Expand Up @@ -75,6 +79,12 @@ export const MarketingTools: FunctionComponent< Props > = ( {
page( marketingConnections( selectedSiteSlug ) );
};

const handleUltimateTrafficGuideClick = () => {
recordTracksEvent( 'calypso_marketing_tools_ultimate_traffic_guide_button_click' );

page( marketingUltimateTrafficGuide( selectedSiteSlug ) );
};

return (
<Fragment>
<PageViewTracker path="/marketing/tools/:site" title="Marketing > Tools" />
Expand Down Expand Up @@ -156,6 +166,16 @@ export const MarketingTools: FunctionComponent< Props > = ( {
{ translate( 'Find your expert' ) }
</Button>
</MarketingToolsFeature>

<MarketingToolsFeature
title={ translate( 'Introducing the WordPress.com Ultimate Traffic Guide' ) }
description={ translate( 'Discover today’s most important traffic secrets' ) }
imagePath="/calypso/images/marketing/upwork-logo.png"
>
<Button onClick={ handleUltimateTrafficGuideClick }>
{ translate( 'Download now' ) }
</Button>
</MarketingToolsFeature>
</div>
</Fragment>
);
Expand Down
192 changes: 192 additions & 0 deletions client/my-sites/marketing/ultimate-traffic-guide/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
/**
* External dependencies
*/

import React, { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import { useTranslate } from 'i18n-calypso';

/**
* Internal dependencies
*/
import { Button, CompactCard } from '@automattic/components';
import {
getProductDisplayCost,
isProductsListFetching,
} from 'calypso/state/products-list/selectors';
import QueryUserPurchases from 'calypso/components/data/query-user-purchases';
import { getUserPurchases } from 'calypso/state/purchases/selectors';
import { getCurrentUserId } from 'calypso/state/current-user/selectors';
import { getSiteSlug } from 'calypso/state/sites/selectors';
import { getSelectedSiteId } from 'calypso/state/ui/selectors';

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

const WPCOM_TRAFFIC_GUIDE = 'traffic-guide';

const Placeholder = () => (
<div className="ultimate-traffic-guide__placeholder">
<div className="ultimate-traffic-guide__placeholder-animation"></div>
</div>
);

const SalesPage = ( { translate } ) => {
const cost = useSelector( ( state ) => getProductDisplayCost( state, WPCOM_TRAFFIC_GUIDE ) );
const isLoading = useSelector( ( state ) => isProductsListFetching( state ) );
const siteId = useSelector( ( state ) => getSelectedSiteId( state ) );
const siteSlug = useSelector( ( state ) => getSiteSlug( state, siteId ) );

return (
<>
<h1>{ translate( 'Introducing the WordPress.com Ultimate Traffic Guide' ) }</h1>
<h2>{ translate( 'Discover today’s most important traffic secrets' ) }</h2>
<p>
{ translate(
'We developed this 96 page guide to teach you every modern website traffic trick you need to know in 2020 and beyond.'
) }
</p>
<p>
{ translate(
'Here are just a few of the topics we cover in {{i}}The Ultimate Traffic Guide:{{/i}}',
{
components: {
i: <i />,
},
}
) }
</p>
<p>
<strong>{ translate( 'The complete SEO checklist for your website (page 53)' ) }</strong>
<br></br>
{ translate(
'Following this simple 7-step checklist will help you get your site featured at the top of search engine results for your most important keywords (and help you avoid the most common pitfalls that you absolutely must avoid if you want to rank well).'
) }
</p>
<p>
<strong>
{ translate(
'Why email is STILL a must-have marketing channel (hint: it’s simple, free, and effective) (page 88)'
) }
</strong>
<br></br>
{ translate(
'This guide will teach you everything you need to know: from which email marketing tools you should use, to how to collect email addresses and write great subject lines, and more.'
) }
</p>
<p>
<strong>
{ translate( 'Harness the power of social media to expand your reach (page 65)' ) }
</strong>
<br></br>
{ translate(
'Discover the best ways to leverage social media channels like FaceBook, Twitter, and LinkedIn to connect with your audience and turn them into raving fans.'
) }
</p>
<p>
<strong>
{ translate(
'How to build a simple “traffic magnet” to instantly attract the right audience (page 7)'
) }
</strong>
<br></br>
{ translate(
'It’s so effective you don’t even have to come close to a “perfect” site before you launch… even the ugliest site can drive an endless stream of business if you get this right!'
) }
</p>
<p>
{ translate(
'If you’ve spent any time looking for marketing help, you know that marketing guides like this often cost $100 or more. But you won’t have to pay anywhere near that amount.'
) }
</p>

{ isLoading ? (
<Placeholder />
) : (
<p>
<strong>
{ translate(
'In fact, if you act today you’ll pay just %(cost)s for The Ultimate Traffic Guide.',
{
args: { cost },
}
) }
</strong>
</p>
) }

<p>
<Button href={ `/checkout/${ siteSlug }/${ WPCOM_TRAFFIC_GUIDE }` } primary>
{ translate( 'Click here to buy the guide now!' ) }
</Button>
</p>
</>
);
};

const DownloadPage = ( { translate } ) => {
const handleDownloadPageButtonClick = () => {
//download
};

return (
<>
<p>
{ translate(
// eslint-disable-next-line inclusive-language/use-inclusive-words
'Congratulations for taking this important step towards mastering the art of online marketing! To download your copy of The Ultimate Traffic Guide, simply click the button below and confirm the download prompt.'
) }
</p>
<p>
{ translate(
'The Ultimate Traffic GuideThis is a goldmine of traffic tips and how-tos that reveals the exact “Breakthrough Traffic” process we’ve developed over the past decade.'
) }
</p>
<p>
{ translate(
'We’ve done all the hard work for you. We’ve sifted through an ocean of marketing articles, tested the ideas to see if they actually work, and then distilled the very best ideas into this printable guide.'
) }
</p>
<p>
<Button onClick={ handleDownloadPageButtonClick } primary>
{ translate( 'Click here to download your copy now.' ) }
</Button>
</p>
</>
);
};

export default function UltimateTrafficGuide() {
const translate = useTranslate();
const userId = useSelector( ( state ) => getCurrentUserId( state ) );
const purchases = useSelector( ( state ) => getUserPurchases( state, userId ) );
const [ hasPurchase, setHasPurchase ] = useState( false );
useEffect( () => {
if (
purchases &&
purchases.find( ( purchase ) => WPCOM_TRAFFIC_GUIDE === purchase.productSlug )
) {
setHasPurchase( true );
}
}, [ purchases, setHasPurchase ] );

const renderPlaceholders = () =>
[ ...Array( 5 ) ].map( ( e, i ) => <Placeholder key={ `${ i }` } /> );

const renderContent = () => {
return hasPurchase ? (
<DownloadPage translate={ translate } />
) : (
<SalesPage translate={ translate } />
);
};

return (
<CompactCard className="ultimate-traffic-guide">
{ ! purchases && <QueryUserPurchases userId={ userId } /> }
{ ! purchases ? renderPlaceholders() : renderContent() }
</CompactCard>
);
}
19 changes: 19 additions & 0 deletions client/my-sites/marketing/ultimate-traffic-guide/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.ultimate-traffic-guide {
h1 {
font-size: $font-title-large;
}

h2 {
font-size: $font-title-medium;
margin-bottom: 1em;
}
.ultimate-traffic-guide__placeholder {
margin-bottom: 1.5em;
.ultimate-traffic-guide__placeholder-animation {
animation: pulse-light 1.6s ease-in-out infinite;
background-color: var( --color-neutral-10 );
color: transparent;
min-height: $font-title-small;
}
}
}

0 comments on commit 0a8524b

Please sign in to comment.