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

Enhancement/9335 SiWG Setup Banner CTA #9560

Merged
merged 45 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3400e19
Scaffold basic banner component.
jimmymadon Oct 24, 2024
2cc6c60
Register basic SiWG setup CTA notification banner.
jimmymadon Oct 24, 2024
3b50de1
Scaffold SiWG notifications registration.
jimmymadon Oct 24, 2024
8331c77
Merge branch 'develop' into enhancement/9335-siwg-banner-cta.
jimmymadon Oct 24, 2024
2e4a887
Add skeleton of new Notification layout with a large SVG.
jimmymadon Oct 24, 2024
ed1180f
Use new layout in SiWG Setup CTA Banner.
jimmymadon Oct 24, 2024
b434064
Add description and learn more link.
jimmymadon Oct 25, 2024
7c1990c
Fix widget body and class.
jimmymadon Oct 25, 2024
bae2ef2
Add desktop SVG.
jimmymadon Oct 25, 2024
b7dc295
Add mobile SVG.
jimmymadon Oct 25, 2024
10a0faf
Add tablet SVG.
jimmymadon Oct 25, 2024
9c7d34c
Fix title styling.
jimmymadon Oct 25, 2024
752e6e7
Add desktop, tablet and mobile versions of SVGs.
jimmymadon Oct 25, 2024
4501e0b
Fix setup banner title styles on tablet width.
jimmymadon Oct 25, 2024
91d7d25
Fix styles for setup banner description.
jimmymadon Oct 25, 2024
9fc7ccc
Allow Description components className to be modified.
jimmymadon Oct 25, 2024
b7fc278
Use new description styles.
jimmymadon Oct 25, 2024
2ccf7b4
Prevent CTALink from erroring when link is absent.
jimmymadon Oct 25, 2024
b07e844
Prevent ActionsCTALinkDismiss component from erroring when link is ab…
jimmymadon Oct 25, 2024
49ae608
Fix title in new setup banner layout.
jimmymadon Oct 25, 2024
fc367db
Add action buttons to SiWG setup banner CTA.
jimmymadon Oct 25, 2024
12e76df
Allow action buttons to accept different class names.
jimmymadon Oct 27, 2024
a0153d9
Register SiWG setup CTA notification only if feature is enabled.
jimmymadon Oct 27, 2024
709ddb5
Add requirements for SiWG setup cta.
jimmymadon Oct 27, 2024
8197a3a
Allow CTALink to work without a link.
jimmymadon Oct 27, 2024
6760c33
Add ability to pass onCTAClick event to composite component.
jimmymadon Oct 27, 2024
b973c6f
Consolidate SignInWithGoogle storybook folders.
jimmymadon Oct 28, 2024
91ed246
Add storybook story for SignInWithGoogleSetupCTABanner.
jimmymadon Oct 28, 2024
5aed12c
Standardise naming of notification ID.
jimmymadon Oct 28, 2024
86fbcc3
Export components from new folder.
jimmymadon Oct 28, 2024
78e6e73
Remove unnecessary styles for the Notification SVG.
jimmymadon Oct 28, 2024
7d9e0c9
Remove unnecessary SVG image splitting for breakpoints.
jimmymadon Oct 28, 2024
085135f
Rename VRT reference images to consolidate SiWG VRTs.
jimmymadon Oct 28, 2024
9306ce8
Standardise description within all Setup CTA banners to be in line wi…
jimmymadon Oct 28, 2024
9f3fbd9
Make new SVG notification layout dynamic for unique CSS classes.
jimmymadon Oct 28, 2024
c7f8100
Pass notification id to the layout to allow it to be used for CSS sty…
jimmymadon Oct 28, 2024
410f8f5
Create unique styles for SiWG SVG banner.
jimmymadon Oct 28, 2024
1837264
Revert setup CTA styles to prevent changes in existing components.
jimmymadon Oct 28, 2024
b05aeec
Revert minor changes that affect existing components.
jimmymadon Oct 29, 2024
eefddb4
Add a VRt for the SiWG Setup Banner CTA.
jimmymadon Oct 29, 2024
5007f73
Revert changes to other components.
jimmymadon Oct 29, 2024
d2b1001
Add VRT reference images for SiWG banner setup CTA.
jimmymadon Oct 29, 2024
0857a1b
Fix VRTs after standardising titles and description fonts for tablet …
jimmymadon Oct 29, 2024
fc87f14
Merge branch 'develop' into enhancement/9335-siwg-banner-cta
tofumatt Oct 31, 2024
3a3caf2
Fix typo in SCSS documentation.
jimmymadon Nov 3, 2024
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
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 }>
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't allow developers to replace the existing class name, I'd think… so we should do this instead:

Suggested change
<div className={ className }>
<div className={ classnames( 'googlesitekit-publisher-win__actions', className ) }>

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I understand, but here, the class name is essentially a flag for the version we need to use for this component. Unfortunately, googlesitekit-publisher-win__actions and googlesitekit-setup-cta-banner__actions-wrapper are conflicting with each other - so we can either apply one or the other. If we were to use classnames, we would have to create another flag like type or something solely for styling. Type could then be banner-notification or setup-cta. And then we'd have to switch the classname based on the type. Ideally, we should be refactoring the legacy banner notifications (viz. all classes with googlesitekit-publisher-win*) soon.

So is this worth add the whole type flag, etc or should I leave this as is?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess in that case we can leave it as-is, fair enough.

<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 }>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here; let's use classnames()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same reasoning as above.

<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,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Capital prop names are a bit odd. I'm guessing it's done so you can use <SVG /> below…

Looks like we do this elsewhere too, so no need to change it, but I guess leaving my comment here so it's recognised 😆

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, this just clearly screams that we need a component as a prop here - similar to how we use pass Widget, WidgetNull, Notification, etc as well.

} ) {
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 @@ -194,34 +194,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
Loading