Skip to content

Commit

Permalink
Merge pull request #9560 from google/enhancement/9335-siwg-banner-cta
Browse files Browse the repository at this point in the history
Enhancement/9335 SiWG Setup Banner CTA
  • Loading branch information
tofumatt authored Nov 5, 2024
2 parents ffe957d + 3a3caf2 commit 5ebbb60
Show file tree
Hide file tree
Showing 35 changed files with 500 additions and 71 deletions.
45 changes: 24 additions & 21 deletions assets/js/components/consent-mode/ConsentModeSetupCTAWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,28 +241,31 @@ function ConsentModeSetupCTAWidget( { Widget, WidgetNull } ) {
'google-site-kit'
) }
</h3>
<p className="googlesitekit-setup-cta-banner__description">
{ createInterpolateElement(
__(
'Consent mode interacts with your Consent Management Platform (CMP) or custom implementation for obtaining visitor consent, such as a cookie consent banner. <a>Learn more</a>',
'google-site-kit'
),
{
a: (
<Link
href={
consentModeDocumentationURL
}
external
aria-label={ __(
'Learn more about consent mode',
'google-site-kit'
) }
/>
<div className="googlesitekit-setup-cta-banner__description">
<p>
{ createInterpolateElement(
__(
'Consent mode interacts with your Consent Management Platform (CMP) or custom implementation for obtaining visitor consent, such as a cookie consent banner. <a>Learn more</a>',
'google-site-kit'
),
}
) }
</p>
{
a: (
<Link
href={
consentModeDocumentationURL
}
external
aria-label={ __(
'Learn more about consent mode',
'google-site-kit'
) }
/>
),
}
) }
</p>
</div>

{ saveError && (
<ErrorText
message={ saveError.message }
Expand Down
14 changes: 8 additions & 6 deletions assets/js/components/notifications/AdsModuleSetupCTAWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ function AdsModuleSetupCTAWidget( { WidgetNull, Widget } ) {
'google-site-kit'
) }
</h3>
<p className="googlesitekit-setup-cta-banner__description">
{ __(
'Help drive sales, leads, or site traffic by getting your business in front of people who are actively searching Google for products or services you offer.',
'google-site-kit'
) }
</p>
<div className="googlesitekit-setup-cta-banner__description">
<p>
{ __(
'Help drive sales, leads, or site traffic by getting your business in front of people who are actively searching Google for products or services you offer.',
'google-site-kit'
) }
</p>
</div>

<div className="googlesitekit-setup-cta-banner__actions-wrapper">
<Button
Expand Down
8 changes: 7 additions & 1 deletion assets/js/googlesitekit-modules-sign-in-with-google.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
*/
import Data from 'googlesitekit-data';
import Modules from 'googlesitekit-modules';
import { registerModule, registerStore } from './modules/sign-in-with-google';
import Notifications from 'googlesitekit-notifications';
import {
registerModule,
registerStore,
registerNotifications,
} from './modules/sign-in-with-google';

registerModule( Modules );
registerStore( Data );
registerNotifications( Notifications );
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,26 @@ import CTALink from './CTALink';

export default function ActionsCTALinkDismiss( {
id,
className = 'googlesitekit-publisher-win__actions',
ctaLink,
ctaLabel,
onCTAClick,
dismissLabel = __( 'OK, Got it!', 'google-site-kit' ),
dismissExpires = 0,
} ) {
const isNavigatingToCTALink = useSelect( ( select ) =>
select( CORE_LOCATION ).isNavigatingTo( ctaLink )
);
const isNavigatingToCTALink = useSelect( ( select ) => {
return ctaLink
? select( CORE_LOCATION ).isNavigatingTo( ctaLink )
: false;
} );

return (
<div className="googlesitekit-publisher-win__actions">
<div className={ className }>
<CTALink
id={ id }
ctaLink={ ctaLink }
ctaLabel={ ctaLabel }
onCTAClick={ onCTAClick }
dismissExpires={ dismissExpires }
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@ export default function CTALink( {

const trackEvents = useNotificationEvents( id );

const isNavigatingToCTALink = useSelect( ( select ) =>
select( CORE_LOCATION ).isNavigatingTo( ctaLink )
);
const isNavigatingToCTALink = useSelect( ( select ) => {
return ctaLink
? select( CORE_LOCATION ).isNavigatingTo( ctaLink )
: false;
} );

const { dismissNotification } = useDispatch( CORE_NOTIFICATIONS );
const { navigateTo } = useDispatch( CORE_LOCATION );

const handleCTAClick = async ( event ) => {
event.persist();
if ( ! event.defaultPrevented ) {
if ( ! event.defaultPrevented && ctaLink ) {
event.preventDefault();
}

Expand All @@ -79,7 +81,9 @@ export default function CTALink( {

await Promise.all( ctaClickActions );

navigateTo( ctaLink );
if ( ctaLink ) {
navigateTo( ctaLink );
}
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
*/
import { sanitizeHTML } from '../../../../util';

export default function Description( { text, learnMoreLink } ) {
export default function Description( {
className = 'googlesitekit-publisher-win__desc',
text,
learnMoreLink,
} ) {
return (
<div className="googlesitekit-publisher-win__desc">
<div className={ className }>
<p>
<span
dangerouslySetInnerHTML={ sanitizeHTML( text, {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**
* Site Kit by Google, Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* External dependencies
*/
import classNames from 'classnames';

/**
* Internal dependencies
*/
import {
BREAKPOINT_SMALL,
BREAKPOINT_TABLET,
useBreakpoint,
} from '../../../../hooks/useBreakpoint';
import { Cell, Grid, Row } from '../../../../material-components';

export default function NotificationWithSVG( {
id,
title,
description,
actions,
SVG,
} ) {
const breakpoint = useBreakpoint();

// Desktop breakpoint.
let svgSizeProps = { mdSize: 8, lgSize: 6 };
// Tablet breakpoint.
if ( breakpoint === BREAKPOINT_TABLET ) {
svgSizeProps = { mdSize: 8 };
}
// Mobile breakpoint.
if ( breakpoint === BREAKPOINT_SMALL ) {
svgSizeProps = { smSize: 12 };
}

return (
<div className="googlesitekit-widget-context">
<Grid className="googlesitekit-widget-area">
<Row>
<Cell size={ 12 }>
<div
className={ classNames(
'googlesitekit-widget',
'googlesitekit-widget--no-padding',
'googlesitekit-setup-cta-banner',
`googlesitekit-setup-cta-banner--${ id }`
) }
>
<div className="googlesitekit-widget__body">
<Grid collapsed>
<Row>
<Cell
smSize={ 12 }
mdSize={ 8 }
lgSize={ 6 }
className="googlesitekit-setup-cta-banner__primary-cell"
>
<h3 className="googlesitekit-setup-cta-banner__title">
{ title }
</h3>

{ description }

{ actions }
</Cell>
<Cell
alignBottom
className={ `googlesitekit-setup-cta-banner__svg-wrapper--${ id }` }
{ ...svgSizeProps }
>
<SVG />
</Cell>
</Row>
</Grid>
</div>
</div>
</Cell>
</Row>
</Grid>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,34 +196,36 @@ function ReaderRevenueManagerSetupCTABanner( { Widget, WidgetNull } ) {
'google-site-kit'
) }
</h4>
<p className="googlesitekit-setup-cta-banner__description">
{ createInterpolateElement(
__(
'Turn casual visitors into loyal readers and earn more from your content with voluntary contributions, surveys, newsletter sign-ups and reader insight tools. <a>Learn more</a>',
'google-site-kit'
),
{
a: (
<Link
href={
readerRevenueManagerDocumentationURL
}
external
aria-label={ __(
'Learn more about reader revenue manager',
'google-site-kit'
) }
/>
<div className="googlesitekit-setup-cta-banner__description">
<p>
{ createInterpolateElement(
__(
'Turn casual visitors into loyal readers and earn more from your content with voluntary contributions, surveys, newsletter sign-ups and reader insight tools. <a>Learn more</a>',
'google-site-kit'
),
}
) }
<br />
<br />
{ __(
'* Support for subscriptions coming soon',
'google-site-kit'
) }
</p>
{
a: (
<Link
href={
readerRevenueManagerDocumentationURL
}
external
aria-label={ __(
'Learn more about reader revenue manager',
'google-site-kit'
) }
/>
),
}
) }
<br />
<br />
{ __(
'* Support for subscriptions coming soon',
'google-site-kit'
) }
</p>
</div>

<div className="googlesitekit-setup-cta-banner__actions-wrapper">
<Button
Expand Down
Loading

0 comments on commit 5ebbb60

Please sign in to comment.