Skip to content

Free Listings + Paid Ads: Add the boost product listings section #1649

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions js/src/components/stepper/step-content-footer/index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.gla-step-content-footer {
display: flex;
justify-content: flex-end;

&[hidden] {
display: none;
}
}
1 change: 1 addition & 0 deletions js/src/css/abstracts/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Typography

$gla-font-smallest: 11px;
$gla-font-smaller: 12px;
$gla-font-small: 14px;
$gla-font-small-medium: 20px;
$gla-font-medium: 24px;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { Flex, FlexItem, FlexBlock } from '@wordpress/components';
import { Pill } from '@woocommerce/components';
import GridiconCheckmark from 'gridicons/dist/checkmark';
import GridiconGift from 'gridicons/dist/gift';

/**
* Internal dependencies
*/
import Section from '.~/wcdl/section';
import AppDocumentationLink from '.~/components/app-documentation-link';
import './paid-ads-features-section.scss';

function FeatureList() {
const featuresItems = [
{
Icon: GridiconCheckmark,
content: __(
'Promote your products across Google Search, YouTube, Display, Discover, Maps, Gmail, and more.',
'google-listings-and-ads'
),
},
{
Icon: GridiconCheckmark,
content: __(
'Set a daily budget, and only pay when someone clicks.',
'google-listings-and-ads'
),
},
{
Icon: GridiconGift,
content: __(
'Claim $500 in ads credit when you spend your first $500 with Google Ads. Terms and conditions apply.',
'google-listings-and-ads'
),
Comment on lines +17 to +38
Copy link
Contributor

Choose a reason for hiding this comment

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

💅 Possible to divide the components in multiple files? 1 per component?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. However, I lean toward keeping the component here because it is not used by others and it's a plain component.

},
];

return (
<div className="gla-paid-ads-features-section__feature-list">
{ featuresItems.map( ( { Icon, content }, idx ) => (
<Flex key={ idx } align="flex-start">
<Icon size="18" />
<FlexBlock>{ content }</FlexBlock>
</Flex>
) ) }
</div>
);
}

// TODO: `href` is not yet ready. Will be added later.
/**
* @fires gla_documentation_link_click with `{ context: 'setup-paid-ads', link_id: 'paid-ads-with-performance-max-campaigns-learn-more', href: 'https://example.com' }`
*/

/**
* Renders a section layout to elaborate on the features of paid ads and show the buttons
* for the next actions: skip or continue the paid ads setup.
*
* @param {Object} props React props.
* @param {boolean} props.hideFooterButtons Whether to hide the buttons at the card footer.
* @param {JSX.Element} props.skipButton Button to skip paid ads setup.
* @param {JSX.Element} props.continueButton Button to continue paid ads setup.
*/
export default function PaidAdsFeaturesSection( {
hideFooterButtons,
skipButton,
continueButton,
} ) {
return (
<Section
className="gla-paid-ads-features-section"
topContent={
<Pill>{ __( 'Recommended', 'google-listings-and-ads' ) }</Pill>
}
title={ __(
'Boost product listings with paid ads',
'google-listings-and-ads'
) }
description={
<>
<p>
{ __(
'Get the most out of your paid ads with Performance Max campaigns. With Google’s machine learning technology, your Performance Max campaigns will be automated to show the most impactful ads at the right time and place.',
'google-listings-and-ads'
) }
</p>
<p>
<AppDocumentationLink
context="setup-paid-ads"
linkId="paid-ads-with-performance-max-campaigns-learn-more"
href="https://example.com" // TODO: Not yet ready. Will be added later.
>
{ __( 'Learn more', 'google-listings-and-ads' ) }
</AppDocumentationLink>
</p>
</>
}
>
<Section.Card>
<Section.Card.Body>
<Flex align="center" gap={ 9 }>
<FlexBlock>
<Section.Card.Title>
{ __(
'Drive more traffic and sales by using both free listings and paid ads',
'google-listings-and-ads'
) }
</Section.Card.Title>
<div className="gla-paid-ads-features-section__subtitle">
{ __(
'Using free listings and paid ads together can double impressions and increase clicks by 50%*',
'google-listings-and-ads'
) }
</div>
<FeatureList />
<cite className="gla-paid-ads-features-section__cite">
{ __(
'Source: Google Internal Data, July 2020',
'google-listings-and-ads'
) }
</cite>
</FlexBlock>
<FlexItem>
<div style={ { width: '205px' } }>
Will be added by another PR
</div>
</FlexItem>
</Flex>
</Section.Card.Body>
<Section.Card.Footer hidden={ hideFooterButtons }>
{ skipButton }
{ continueButton }
</Section.Card.Footer>
</Section.Card>
</Section>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.gla-paid-ads-features-section {
.woocommerce-pill {
color: $gray-700;
}

.wcdl-section-card-title {
margin-bottom: $grid-unit-15;
line-height: $gla-line-height-medium-large;
font-weight: normal;
font-size: $gla-font-small-medium;
color: $gray-900;
}

&__subtitle {
line-height: $gla-line-height-medium;
font-size: $gla-font-small;
color: $gray-800;
}

&__feature-list {
display: flex;
flex-direction: column;
gap: $grid-unit-20;
margin: $grid-unit-30 0 $grid-unit-20;
line-height: $gla-line-height-smaller;
color: $gray-800;

.gridicon {
fill: #5ec862;
}
}

&__cite {
font-style: normal;
font-size: $gla-font-smaller;
color: $gray-600;
}
}
56 changes: 42 additions & 14 deletions js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ import StepContentFooter from '.~/components/stepper/step-content-footer';
import FaqsSection from '.~/components/paid-ads/faqs-section';
import AppButton from '.~/components/app-button';
import ProductFeedStatusSection from './product-feed-status-section';
import PaidAdsFeaturesSection from './paid-ads-features-section';
import { getProductFeedUrl } from '.~/utils/urls';
import { GUIDE_NAMES } from '.~/constants';
import { API_NAMESPACE } from '.~/data/constants';

export default function SetupPaidAds() {
const adminUrl = useAdminUrl();
const { createNotice } = useDispatchCoreNotices();
const [ showPaidAdsSetup, setShowPaidAdsSetup ] = useState( false );
const [ completing, setCompleting ] = useState( null );

const finishFreeListingsSetup = async ( event ) => {
Expand Down Expand Up @@ -56,6 +58,19 @@ export default function SetupPaidAds() {
await finishFreeListingsSetup( event );
};

function createSkipButton( text ) {
return (
<AppButton
isTertiary
data-action="skip-ads"
text={ text }
loading={ completing === 'skip-ads' }
disabled={ completing === 'complete-ads' }
Comment on lines +67 to +68
Copy link
Contributor

@puntope puntope Aug 29, 2022

Choose a reason for hiding this comment

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

💅 WDYT about using some constants here?

Copy link
Member Author

@eason9487 eason9487 Aug 30, 2022

Choose a reason for hiding this comment

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

Considering the following two PRs are also changing related code fragments, I updated it in PR #1655 by 0e65308 and c08364f.

onClick={ finishFreeListingsSetup }
/>
);
}

return (
<StepContent>
<StepContentHeader
Expand All @@ -69,30 +84,43 @@ export default function SetupPaidAds() {
) }
/>
<ProductFeedStatusSection />
<PaidAdsFeaturesSection
hideFooterButtons={ showPaidAdsSetup }
skipButton={ createSkipButton(
__( 'Skip this step for now', 'google-listings-and-ads' )
) }
continueButton={
<AppButton
isPrimary
text={ __(
'Create a paid ad campaign',
'google-listings-and-ads'
) }
disabled={ completing === 'skip-ads' }
onClick={ () => setShowPaidAdsSetup( true ) }
/>
}
/>
<FaqsSection />
<StepContentFooter>
<StepContentFooter hidden={ ! showPaidAdsSetup }>
<Flex justify="right" gap={ 4 }>
<AppButton
isTertiary
data-action="skip-ads"
loading={ completing === 'skip-ads' }
disabled={ completing === 'complete-ads' }
onClick={ finishFreeListingsSetup }
>
{ __(
{ createSkipButton(
__(
'Skip paid ads creation',
'google-listings-and-ads'
) }
</AppButton>
)
) }
<AppButton
isPrimary
data-action="complete-ads"
text={ __(
'Complete setup',
'google-listings-and-ads'
) }
loading={ completing === 'complete-ads' }
disabled={ completing === 'skip-ads' }
onClick={ handleCompleteClick }
>
{ __( 'Complete setup', 'google-listings-and-ads' ) }
</AppButton>
/>
</Flex>
</StepContentFooter>
</StepContent>
Expand Down
4 changes: 4 additions & 0 deletions js/src/wcdl/section/card/footer/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.wcdl-section-card-footer {
padding: calc(var(--large-gap) / 2) var(--large-gap);

&[hidden] {
display: none;
}
}
11 changes: 10 additions & 1 deletion js/src/wcdl/section/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@ import './index.scss';
* @param {string} [props.className] Additional CSS class name to be appended.
* @param {JSX.Element} [props.title] Section title at the left side.
* @param {JSX.Element} [props.description] Section description under the title.
* @param {JSX.Element} [props.topContent] Content at the top of the section title.
* @param {JSX.Element} [props.children] Section content at the right side.
* @param {boolean} [props.disabled] Whether display the whole section in disabled style.
*/
const Section = ( { className, title, description, children, disabled } ) => {
const Section = ( {
className,
title,
description,
topContent,
children,
disabled,
} ) => {
const sectionClassName = classnames(
'wcdl-section',
disabled ? 'wcdl-section--is-disabled' : false,
Expand All @@ -29,6 +37,7 @@ const Section = ( { className, title, description, children, disabled } ) => {
return (
<section className={ sectionClassName }>
<header>
{ topContent && <p>{ topContent }</p> }
{ title && <h1>{ title }</h1> }
{ description }
</header>
Expand Down
2 changes: 1 addition & 1 deletion js/src/wcdl/section/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}

p {
margin: 0 0 1em;
margin: 0 0 $grid-unit;
line-height: $gla-line-height-smaller;
}
}
Expand Down