Repository navigation
My Jetpack: migrate Add License activation screen to @wordpress/ui buttons and links #50343
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
Changes from 1 commit
acf5bdf
21d8d97
03732aa
466b8b9
2b289ab
3882294
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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,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'; | ||
|
|
@@ -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" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can remove |
||
| children={ null } | ||
| /> | ||
| ), | ||
| } | ||
| ) } | ||
| </p> | ||
|
|
||
| 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'; | ||
|
|
@@ -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( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Flagging the need for recently added |
||
| 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> | ||
|
|
@@ -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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can also be switched to |
||
| > | ||
| { __( 'View scan results', 'jetpack-licensing' ) } | ||
| </Button> | ||
| ); | ||
|
|
@@ -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> | ||
|
|
@@ -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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can also be switched to |
||
| > | ||
| { __( 'View my plans', 'jetpack-licensing' ) } | ||
| </Button> | ||
|
|
||
| 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; | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. 🙂