Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Activation screen: migrate the license activation buttons and support links to @wordpress/ui primitives.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import jetpackAnalytics from '@automattic/jetpack-analytics';
import { JetpackLogo } from '@automattic/jetpack-components';
import { Button, TextControl, SelectControl, Spinner } from '@wordpress/components';
import { TextControl, SelectControl } from '@wordpress/components';
import { createInterpolateElement } from '@wordpress/element';
import { sprintf, __ } from '@wordpress/i18n';
import { Button } from '@wordpress/ui';
import PropTypes from 'prop-types';
import { useCallback, useEffect, useMemo, useState } from 'react';
import ActivationScreenError from '../activation-screen-error';
Expand Down Expand Up @@ -213,9 +214,11 @@ const ActivationScreenControls = props => {
<Button
className="jp-license-activation-screen-controls--button"
onClick={ activateLicense }
disabled={ ! license }
disabled={ ! license || isActivating }
loading={ isActivating }
loadingAnnouncement={ __( 'Activating license…', 'jetpack-licensing' ) }
>
{ isActivating ? <Spinner /> : __( 'Activate', 'jetpack-licensing' ) }
{ __( 'Activate', 'jetpack-licensing' ) }
</Button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,47 +83,11 @@
}
}

.jp-license-activation-screen-controls--button,
.jp-license-activation-screen-controls--button:active {
background-color: var(--jp-black);
border-radius: 4px;
color: var(--jp-white);
display: flex;
font-size: 16px;
font-size: var(--font-body);
font-style: normal;
font-weight: 600;
justify-content: center;
line-height: 24px;
margin-top: 24px;
min-height: 48px;
min-width: 158px;
padding: 13.5px 45px 13.5px 45px;
width: 100%;

@media screen and (min-width: 480px) {
width: auto;
}

&.components-button:hover {
background-color: var(--jp-black-80);
color: var(--jp-white);
}

&:focus {
background-color: var(--jp-black-80);
border: 1px solid var(--jp-white);
color: var(--jp-white);
}

&[disabled],
&:disabled {
background-color: var(--jp-gray);
color: var(--jp-gray-20);
}

.components-spinner {
width: 100%;
}
.jp-license-activation-screen-controls--button {
font-weight: var(--wpds-typography-font-weight-medium);
font-size: var(--wpds-typography-font-size-lg);
width: auto;
padding-inline: var(--wpds-dimension-padding-3xl);
padding-block: var(--wpds-dimension-padding-lg);
Comment on lines +18 to +22

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need these style overrides? Ideally, we'd use the design system as-is without overrides, which are unwieldy to maintain.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looks quite off without them, there is not variant for size. Good thing is they are all under a single class, we can easily remove them. Let me get screenshots before calling for some design advise.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yah it might just need a design change/decision or keep as custom but good to make that decision intentionally rather than just leave be because that's how it was before. 🙂

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@
ol > li::marker {
font-weight: 700;
}

a {
color: var(--jp-green-50);
}

a:hover,
a:active {
color: var(--jp-green-70);
}
}

.jp-license-activation-screen-controls {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getRedirectUrl } from '@automattic/jetpack-components';
import { createInterpolateElement } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { Link } from '@wordpress/ui';
import PropTypes from 'prop-types';

import './style.scss';
Expand All @@ -25,7 +26,14 @@ const ActivationScreenIllustration = props => {
{ createInterpolateElement(
__( 'Do you need help? <a>Contact us.</a>', 'jetpack-licensing' ),
{
a: <a href={ getRedirectUrl( 'jetpack-support-license-activation' ) } />,
a: (
<Link
openInNewTab
href={ getRedirectUrl( 'jetpack-support-license-activation' ) }
rel="noopener noreferrer"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can remove rel here; it's not needed in modern browsers. We just removed it in ExternalLink, too.

children={ null }
/>
),
}
) }
</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getRedirectUrl } from '@automattic/jetpack-components';
import { Button, Spinner } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { Button } from '@wordpress/ui';
import PropTypes from 'prop-types';
import useActivePlugins from '../../../hooks/use-active-plugins';
import { getProductGroup } from '../../activation-screen/utils';
Expand All @@ -21,27 +21,36 @@ const PrimaryLink = props => {
productGroup === 'jetpack_social_advanced' || productGroup === 'jetpack_social_basic';
const isJetpackProtectActive = isPluginActive( 'Jetpack Protect' );

// The success-screen CTAs only navigate the current tab. Using onClick keeps
// a native @wordpress/ui <button> (so its styles render untouched) rather
// than rendering it as an anchor.
const navigateTo = url => () => {
window.location.href = url;
};

if ( isFetching ) {
return (
<Button className="jp-license-activation-screen-success-info--button">
<Spinner />
</Button>
<Button
className="jp-license-activation-screen-success-info--button"
loading
loadingAnnouncement={ __( 'Loading…', 'jetpack-licensing' ) }
/>
);
}

if ( isJetpackSocialProduct && ( isJetpackActive || isJetpackSocialActive ) ) {
return (
<Button
className="jp-license-activation-screen-success-info--button"
href={
onClick={ navigateTo(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Flagging the need for recently added LinkButton, which will be available in the next @wordpress/ui release.

siteAdminUrl +
( isJetpackActive
? 'admin.php?page=jetpack#/recommendations/' +
( productGroup === 'jetpack_social_advanced'
? 'welcome-social-advanced'
: 'welcome-social-basic' )
: 'admin.php?page=jetpack-social' )
}
( isJetpackActive
? 'admin.php?page=jetpack#/recommendations/' +
( productGroup === 'jetpack_social_advanced'
? 'welcome-social-advanced'
: 'welcome-social-basic' )
: 'admin.php?page=jetpack-social' )
) }
>
{ __( 'Configure my site', 'jetpack-licensing' ) }
</Button>
Expand All @@ -53,7 +62,10 @@ const PrimaryLink = props => {
? siteAdminUrl + 'admin.php?page=jetpack-protect'
: getRedirectUrl( 'jetpack-license-activation-success-scan', { site: siteRawUrl } );
return (
<Button className="jp-license-activation-screen-success-info--button" href={ redirectSource }>
<Button
className="jp-license-activation-screen-success-info--button"
onClick={ navigateTo( redirectSource ) }
Comment on lines +66 to +68

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can also be switched to LinkButton later.

>
{ __( 'View scan results', 'jetpack-licensing' ) }
</Button>
);
Expand All @@ -64,7 +76,7 @@ const PrimaryLink = props => {
return (
<Button
className="jp-license-activation-screen-success-info--button"
href={ siteAdminUrl + 'admin.php?page=jetpack#/recommendations' }
onClick={ navigateTo( siteAdminUrl + 'admin.php?page=jetpack#/recommendations' ) }
>
{ __( 'Configure my site', 'jetpack-licensing' ) }
</Button>
Expand All @@ -74,7 +86,9 @@ const PrimaryLink = props => {
return (
<Button
className="jp-license-activation-screen-success-info--button"
href={ getRedirectUrl( 'license-activation-view-my-plans', { site: siteRawUrl } ) }
onClick={ navigateTo(
getRedirectUrl( 'license-activation-view-my-plans', { site: siteRawUrl } )
) }
Comment on lines +90 to +92

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can also be switched to LinkButton later.

>
{ __( 'View my plans', 'jetpack-licensing' ) }
</Button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,13 @@
@use "@automattic/jetpack-base-styles/style";

.components-button {

&.jp-license-activation-screen-success-info--button,
&.jp-license-activation-screen-success-info--button:active,
&.jp-license-activation-screen-success-info--button:visited {
background-color: var(--jp-black);
border-radius: 4px;
color: var(--jp-white);
font-size: 16px;
font-size: var(--font-body);
font-style: normal;
font-weight: 600;
justify-content: center;
line-height: 24px;
min-height: 48px;
min-width: 158px;
padding: 13.5px 45px 13.5px 45px;
width: 100%;
margin: 0 40px 20px 0;

@media screen and (min-width: 480px) {
width: auto;
}

&:hover {
background-color: var(--jp-black-80);
color: var(--jp-white);
}

&:focus {
background-color: var(--jp-black-80);
border: 1px solid var(--jp-white);
color: var(--jp-white);
}

&[disabled],
&:disabled {
background-color: var(--jp-gray);
color: var(--jp-gray-20);
}

.components-spinner {
width: 100%;
}
// Scoped under the container to reach specificity (0,2,0), matching the
// Activate button's rule. A bare `--button` selector (0,1,0) only ties
// @wordpress/ui's runtime-injected button reset and loses on source order.
.jp-license-activation-screen-success-info {

.jp-license-activation-screen-success-info--button {
font-weight: var(--wpds-typography-font-weight-medium);
font-size: var(--wpds-typography-font-size-lg);
width: auto;
padding-inline: var(--wpds-dimension-padding-3xl);
padding-block: var(--wpds-dimension-padding-lg);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
.jp-license-activation-screen-success-info--external-link {
text-decoration: underline !important;
color: var(--jp-black);
font-size: 16px;
font-style: normal;
font-weight: 600;
white-space: nowrap;
// Match the primary button's font so the link reads as its pair. Scoped under
// the container to reach 0,2,0 and override @wordpress/ui's injected reset
// (same reason as the button rule).
.jp-license-activation-screen-success-info {

.jp-license-activation-screen-success-info--external-link {
font-weight: var(--wpds-typography-font-weight-medium);
font-size: var(--wpds-typography-font-size-lg);
white-space: nowrap;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@
}

.jp-license-activation-screen-success-info--buttons {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--wpds-dimension-gap-lg) var(--wpds-dimension-gap-3xl);

@media screen and (max-width: 480px) {
text-align: center;
justify-content: center;
}
}
}
Loading