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/style.scss b/projects/js-packages/connection/components/connect-screen/basic/style.scss index d8aad6506f52..0f3bcebd2b61 100644 --- a/projects/js-packages/connection/components/connect-screen/basic/style.scss +++ b/projects/js-packages/connection/components/connect-screen/basic/style.scss @@ -17,25 +17,16 @@ } } - .jp-action-button { + // Structural-only: top spacing + responsive width. All other treatment + // (colors, padding, border-radius, font-weight) honors the + // @wordpress/ui Button defaults. + .jp-connection__connect-screen__action-button { margin-top: 40px; + max-width: 100%; - &--button { - border-radius: 4px; - font-weight: 600; - } - - button { - max-width: 100%; - - &:disabled { - color: hsla(0, 0%, 100%, 0.4); - } - - @media ( max-width: breakpoints.$break-medium ) { - max-width: none; - width: 100%; - } + @media ( max-width: breakpoints.$break-medium ) { + max-width: none; + width: 100%; } } 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..9bb11cd568df 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,20 @@ const ConnectScreenVisual: FC< Props > = ( {
- + loading={ buttonIsLoading } + disabled={ isOfflineMode } + > + { buttonLabel } + + { ( 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..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 @@ -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,31 @@ 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' ) } +

+ ) } 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 } ) => {