Skip to content
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
10 changes: 10 additions & 0 deletions assets/js/components/Banner/CTAButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import PropTypes from 'prop-types';
* Internal dependencies
*/
import { SpinnerButton } from 'googlesitekit-components';
import ExternalIcon from '@/svg/icons/external.svg';

export default function CTAButton( {
label,
Expand All @@ -31,11 +32,18 @@ export default function CTAButton( {
inProgress,
onClick,
href,
external = false,
hideExternalIndicator = false,
} ) {
if ( ! label || ( ! onClick && ! href ) ) {
return null;
}

let trailingIconToUse;
if ( external && ! hideExternalIndicator ) {
trailingIconToUse = <ExternalIcon width={ 14 } height={ 14 } />;
}

return (
<SpinnerButton
className="googlesitekit-banner__cta"
Expand All @@ -44,6 +52,8 @@ export default function CTAButton( {
isSaving={ inProgress }
onClick={ onClick }
href={ href }
target={ external ? '_blank' : undefined }
trailingIcon={ trailingIconToUse }
>
{ label }
</SpinnerButton>
Expand Down
3 changes: 2 additions & 1 deletion assets/js/components/Banner/index.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function Template() {
an ad blocker the option to allow ads on
your site. Site Kit will place an ad
blocking recovery tag on your site.{ ' ' }
<Link>Learn more</Link>
<Link external>Learn more</Link>
</p>
<p>
Publishers see up to 1 in 5 users choose to
Expand Down Expand Up @@ -225,6 +225,7 @@ function Template() {
ctaButton={ {
label: 'Go to AdSense',
onClick: () => {},
external: true,
} }
dismissButton={ {
label: 'Maybe later',
Expand Down
6 changes: 3 additions & 3 deletions assets/js/components/Notice/CTAButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export default function CTAButton( {
inProgress,
onClick,
href,
external,
hideExternalIndicator,
external = false,
hideExternalIndicator = false,
} ) {
let trailingIconToUse;
if ( external && ! hideExternalIndicator ) {
Expand All @@ -45,7 +45,7 @@ export default function CTAButton( {
isSaving={ inProgress }
onClick={ onClick }
href={ href }
target={ external ? '_blank' : '_self' }
target={ external ? '_blank' : undefined }
trailingIcon={ trailingIconToUse }
>
{ label }
Expand Down
10 changes: 9 additions & 1 deletion assets/js/components/NotificationFromServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,17 @@ function NotificationFromServer( {
ctaButton={ {
label: ctaLabel,
href: ctaURL,
target: ctaTarget,
onClick: onCTAClick,
dismissOptions,
// In the case of notifications, other `target="_blank"` CTA URLs
// are external, and adding a new, more explicit/clear `external`
// prop would be a refactor of the service, JS, and PHP code all
// for mildly more "intuitive" prop names/API.
//
// In this case it's not worth the refactor (as of writing this
// logic), so we allow for any "open in a new window" URLs
// to also be "external".
external: ctaTarget === '_blank',
} }
dismissButton={
dismissible
Expand Down
1 change: 1 addition & 0 deletions assets/sass/components/banner/_googlesitekit-banner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@

// Setting the margin top on each button so that when they stack on mobile the spacing is consistent.
.googlesitekit-notice__action > .mdc-button {
gap: 0 6px;
margin-right: 10px;
margin-top: 20px;
}
Expand Down
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the banner I'm referring to: "Recover revenue lost to ad blockers" has a "Learn more" link that isn't marked as external, but should be.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, this was confusing because this isn't a real component. I've updated it anyway so this isn't confusing in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, thanks! Was just going to say that they are just rough dummies based on real components which makes this confusing. They were designed from Figma with real content instead of 'lorem ipsum' / dummy text.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading