From cf2d0ad723cbe23c799873bd0ed32b01a1094e42 Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Fri, 22 May 2026 11:33:55 -0300 Subject: [PATCH 1/4] Connection: migrate ActionButton, Button, and Text to @wordpress/ui Drop the last 5 migration-relevant @automattic/jetpack-components imports in js-packages/connection. ActionButton's isLoading/displayError/errorMessage behavior is preserved by mapping isLoading -> @wordpress/ui Button's loading prop and rendering the error message as a sibling paragraph with the same jp-action-button__error class. The default error string matches ActionButton's default, so existing tests pass unchanged. Keepers (DecorativeCard, getRedirectUrl, JetpackLogo, PricingCard, TermsOfService) remain on @automattic/jetpack-components; the package dependency stays. Follows #48150 (Publicize), #48489 (My Jetpack interstitials), #49098 (Partner Coupon), and #48909 (CUT migration). --- .../migrate-jetpack-components-to-wp-ui | 4 +++ .../components/connect-button/index.jsx | 18 ++++++---- .../connect-screen/basic/visual.tsx | 20 ++++++----- .../connect-screen/required-plan/visual.jsx | 35 +++++++++---------- .../manage-connection-dialog/index.jsx | 7 ++-- 5 files changed, 46 insertions(+), 38 deletions(-) create mode 100644 projects/js-packages/connection/changelog/migrate-jetpack-components-to-wp-ui diff --git a/projects/js-packages/connection/changelog/migrate-jetpack-components-to-wp-ui b/projects/js-packages/connection/changelog/migrate-jetpack-components-to-wp-ui new file mode 100644 index 000000000000..04bb0cf8a488 --- /dev/null +++ b/projects/js-packages/connection/changelog/migrate-jetpack-components-to-wp-ui @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Connection: Migrate ActionButton, Button, and Text consumers off @automattic/jetpack-components to @wordpress/ui equivalents; brings the package to zero migration-relevant jetpack-components imports. diff --git a/projects/js-packages/connection/components/connect-button/index.jsx b/projects/js-packages/connection/components/connect-button/index.jsx index a7ea9e0cd73d..c0c71a26829d 100644 --- a/projects/js-packages/connection/components/connect-button/index.jsx +++ b/projects/js-packages/connection/components/connect-button/index.jsx @@ -1,5 +1,5 @@ -import { ActionButton } from '@automattic/jetpack-components'; import { __ } from '@wordpress/i18n'; +import { Button } from '@wordpress/ui'; import PropTypes from 'prop-types'; import useConnection from '../use-connection'; @@ -39,12 +39,16 @@ const ConnectButton = props => { return ( <> { ( ! isRegistered || ! isUserConnected ) && ( - + <> + + { registrationError && ( +

+ { __( 'An error occurred. Please try again.', 'jetpack-connection-js' ) } +

+ ) } + ) } ); diff --git a/projects/js-packages/connection/components/connect-screen/basic/visual.tsx b/projects/js-packages/connection/components/connect-screen/basic/visual.tsx index ced409b3d80b..d0a929a5a973 100644 --- a/projects/js-packages/connection/components/connect-screen/basic/visual.tsx +++ b/projects/js-packages/connection/components/connect-screen/basic/visual.tsx @@ -1,6 +1,7 @@ -import { ActionButton, TermsOfService, getRedirectUrl } from '@automattic/jetpack-components'; +import { TermsOfService, getRedirectUrl } from '@automattic/jetpack-components'; import { createInterpolateElement } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; +import { Button } from '@wordpress/ui'; import ConnectScreenLayout from '../layout'; import type { Props as ConnectScreenProps } from '../basic'; import type { WithRequired } from '../types'; @@ -102,14 +103,15 @@ const ConnectScreenVisual: FC< Props > = ( {
- + + { ( displayButtonError || isOfflineMode ) && ( +

+ { getErrorMessage( errorCode, isOfflineMode ) || + __( 'An error occurred. Please try again.', 'jetpack-connection-js' ) } +

+ ) } { buttonIsLoading ? loadingLabel || __( 'Loading', 'jetpack-connection-js' ) : '' } diff --git a/projects/js-packages/connection/components/connect-screen/required-plan/visual.jsx b/projects/js-packages/connection/components/connect-screen/required-plan/visual.jsx index 3ea0d9243deb..c0c8c62da39c 100644 --- a/projects/js-packages/connection/components/connect-screen/required-plan/visual.jsx +++ b/projects/js-packages/connection/components/connect-screen/required-plan/visual.jsx @@ -1,11 +1,7 @@ -import { - ActionButton, - getRedirectUrl, - PricingCard, - TermsOfService, -} from '@automattic/jetpack-components'; +import { getRedirectUrl, PricingCard, TermsOfService } from '@automattic/jetpack-components'; import { createInterpolateElement } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; +import { Button } from '@wordpress/ui'; import clsx from 'clsx'; import debugFactory from 'debug'; import PropTypes from 'prop-types'; @@ -45,11 +41,9 @@ const ConnectScreenRequiredPlanVisual = props => { __( 'Already have a subscription? ', 'jetpack-connection-js' ), { connectButton: ( - + ), } ); @@ -92,14 +86,19 @@ const ConnectScreenRequiredPlanVisual = props => { priceAfter={ priceAfter } > - + loading={ buttonIsLoading } + disabled={ isOfflineMode } + > + { buttonLabel } + + { ( displayButtonError || isOfflineMode ) && ( +

+ { errorMessage || + __( 'An error occurred. Please try again.', 'jetpack-connection-js' ) } +

+ ) } diff --git a/projects/js-packages/connection/components/manage-connection-dialog/index.jsx b/projects/js-packages/connection/components/manage-connection-dialog/index.jsx index 578c38ac16ef..7932435d751d 100644 --- a/projects/js-packages/connection/components/manage-connection-dialog/index.jsx +++ b/projects/js-packages/connection/components/manage-connection-dialog/index.jsx @@ -3,13 +3,13 @@ */ import jetpackAnalytics from '@automattic/jetpack-analytics'; import restApi from '@automattic/jetpack-api'; -import { Button, getRedirectUrl, Text } from '@automattic/jetpack-components'; +import { getRedirectUrl } from '@automattic/jetpack-components'; import { isWoASite } from '@automattic/jetpack-script-data'; import { Modal } from '@wordpress/components'; import { createInterpolateElement } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { Icon, chevronRight, external } from '@wordpress/icons'; -import { Link } from '@wordpress/ui'; +import { Button, Link, Text } from '@wordpress/ui'; import clsx from 'clsx'; import PropTypes from 'prop-types'; import { useCallback, useEffect, useState, useMemo } from 'react'; @@ -316,8 +316,7 @@ const HelpFooter = ( { onClose, disabled } ) => {
- { ( displayButtonError || isOfflineMode ) && ( -

- { getErrorMessage( errorCode, isOfflineMode ) || - __( 'An error occurred. Please try again.', 'jetpack-connection-js' ) } -

- ) } + { buttonIsLoading ? loadingLabel || __( 'Loading', 'jetpack-connection-js' ) : '' } diff --git a/projects/js-packages/connection/components/connect-screen/required-plan/visual.jsx b/projects/js-packages/connection/components/connect-screen/required-plan/visual.jsx index c0c8c62da39c..3ea0d9243deb 100644 --- a/projects/js-packages/connection/components/connect-screen/required-plan/visual.jsx +++ b/projects/js-packages/connection/components/connect-screen/required-plan/visual.jsx @@ -1,7 +1,11 @@ -import { getRedirectUrl, PricingCard, TermsOfService } from '@automattic/jetpack-components'; +import { + ActionButton, + getRedirectUrl, + PricingCard, + TermsOfService, +} from '@automattic/jetpack-components'; import { createInterpolateElement } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; -import { Button } from '@wordpress/ui'; import clsx from 'clsx'; import debugFactory from 'debug'; import PropTypes from 'prop-types'; @@ -41,9 +45,11 @@ const ConnectScreenRequiredPlanVisual = props => { __( 'Already have a subscription? ', 'jetpack-connection-js' ), { connectButton: ( - + ), } ); @@ -86,19 +92,14 @@ const ConnectScreenRequiredPlanVisual = props => { priceAfter={ priceAfter } > - - { ( displayButtonError || isOfflineMode ) && ( -

- { errorMessage || - __( 'An error occurred. Please try again.', 'jetpack-connection-js' ) } -

- ) } + displayError={ displayButtonError || isOfflineMode } + errorMessage={ errorMessage } + isLoading={ buttonIsLoading } + isDisabled={ isOfflineMode } + />
From e9fa5c6c7fe86895b5df3337e066d84a931d9f8d Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Fri, 22 May 2026 13:43:47 -0300 Subject: [PATCH 3/4] Connection: re-migrate ConnectScreen Basic + RequiredPlan to @wordpress/ui with default styling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This supersedes the previous revert (d10b42671fc) and ships the proper @wordpress/ui migration for the three call sites that had been reverted because their SCSS rules were tightly coupled to the old class hooks (`.jp-action-button--button.components-button` and friends). Visual contract follows the user's clarified migration philosophy: default @wordpress/ui Button styling for colors / padding / font-size / border-radius / spinner, with consumer-side SCSS ONLY for structural exceptions (full-width inside the PricingCard, top margin on the basic-screen CTA, responsive max-width). The previous Jetpack-brand overrides (`background: var(--jp-black) !important`, `color: var(--jp-white) !important`) are dropped — WPDS handles those. * **"Get Jetpack Backup" inside PricingCard** (required-plan/visual.jsx): - `@wordpress/ui` Button (default solid + brand), `loading` prop for in-flight feedback (WPDS-styled spinner shows correctly because the button keeps its default chrome). - New stable className `jp-connection__connect-screen__action-button` targeting only `width: 100%` and the vertical rhythm margin. * **"Log in to get started" inline button** (required-plan/visual.jsx): - `@wordpress/ui` Button `variant="unstyled"` styled as an inline text link via SCSS (`.jp-connection__connect-screen__inline-action`). ` + { ( displayButtonError || isOfflineMode ) && ( +

+ { getErrorMessage( errorCode, isOfflineMode ) || + __( 'An error occurred. Please try again.', 'jetpack-connection-js' ) } +

+ ) } { buttonIsLoading ? loadingLabel || __( 'Loading', 'jetpack-connection-js' ) : '' } diff --git a/projects/js-packages/connection/components/connect-screen/required-plan/style.scss b/projects/js-packages/connection/components/connect-screen/required-plan/style.scss index 89c53b2084fa..6e771e085904 100644 --- a/projects/js-packages/connection/components/connect-screen/required-plan/style.scss +++ b/projects/js-packages/connection/components/connect-screen/required-plan/style.scss @@ -43,23 +43,12 @@ right: calc(var(--spacing-base) * 12); } - .jp-action-button--button.components-button { + // Structural-only: span the pricing card width and keep the vertical + // rhythm inside the card. All other treatment (colors, padding, + // font-size, border-radius) honors the @wordpress/ui Button defaults. + .jp-connection__connect-screen__action-button { width: 100%; - height: auto; - font-size: 18px; - font-weight: 500; - background: var(--jp-black) !important; - color: var(--jp-white) !important; - border-radius: var(--jp-border-radius); - padding: 14px 24px; - margin: 24px 0 32px; - justify-content: center; - align-items: center; - - &:disabled { - background: var(--jp-gray) !important; - color: var(--jp-gray-20) !important; - } + margin: 24px 0; } .terms-of-service { @@ -77,33 +66,29 @@ gap: 1ch; line-height: 1; - .jp-action-button--button.components-button.is-primary { - display: inline; - color: var(--jp-black) !important; - background: inherit !important; + // Inline button styled as a text link inside the surrounding sentence. + // `variant="unstyled"` strips @wordpress/ui Button's chrome so we can + // flow it inline with the prefix copy; we keep ` ), } ); @@ -92,14 +93,20 @@ const ConnectScreenRequiredPlanVisual = props => { priceAfter={ priceAfter } > - + loading={ buttonIsLoading } + disabled={ isOfflineMode } + > + { buttonLabel } + + { ( displayButtonError || isOfflineMode ) && ( +

+ { errorMessage || + __( 'An error occurred. Please try again.', 'jetpack-connection-js' ) } +

+ ) } From 0b1cca5ef7ba62501043a29599523a7cee4b6d85 Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Fri, 22 May 2026 15:50:56 -0300 Subject: [PATCH 4/4] Connection: stabilize inline-action width to prevent text-row reflow on loading Adds `min-width: calc(var(--spacing-base) * 8)` and `justify-content: center` to `.jp-connection__connect-screen__inline-action` so the button reserves a fixed minimum width and centers its content. Without this, swapping the children between the (longer) label and the (narrower) spinner during loading caused the surrounding sentence row to reflow visibly. Tracking the user-applied tweak in this commit. --- .../components/connect-screen/required-plan/style.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/js-packages/connection/components/connect-screen/required-plan/style.scss b/projects/js-packages/connection/components/connect-screen/required-plan/style.scss index 6e771e085904..c9aa79784d06 100644 --- a/projects/js-packages/connection/components/connect-screen/required-plan/style.scss +++ b/projects/js-packages/connection/components/connect-screen/required-plan/style.scss @@ -82,6 +82,8 @@ text-decoration: underline; font: inherit; padding: 0; + min-width: calc(var(--spacing-base) * 8); + justify-content: center; // @wordpress/components Spinner ships with `margin: 5px 11px 0` // for use inside button chrome we no longer have. Zero it out