Skip to content

Commit 6185cd4

Browse files
authored
Documents page to use the wp.components available in the WordPress installation (#10953)
1 parent b92aa4d commit 6185cd4

File tree

9 files changed

+82
-10
lines changed

9 files changed

+82
-10
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: update
3+
4+
Update documents page to use WP components available in the WordPress installation.

client/components/test-mode-notice/index.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { __, _n, sprintf } from '@wordpress/i18n';
1010
import { getPaymentSettingsUrl, isInTestMode } from 'utils';
1111
import BannerNotice from '../banner-notice';
1212
import interpolateComponents from '@automattic/interpolate-components';
13-
import { Link } from '@woocommerce/components';
13+
import { ExternalLink } from 'wcpay/components/wp-components-wrapped/components/external-link';
1414
import { recordEvent } from 'wcpay/tracks';
1515

1616
type CurrentPage =
@@ -86,13 +86,10 @@ const getNoticeContent = (
8686
learnMoreLink: (
8787
// Link content is in the format string above. Consider disabling jsx-a11y/anchor-has-content.
8888
// eslint-disable-next-line jsx-a11y/anchor-has-content
89-
<Link
89+
<ExternalLink
9090
href={
9191
'https://woocommerce.com/document/woopayments/testing-and-troubleshooting/sandbox-mode/'
9292
}
93-
target="_blank"
94-
rel="noreferrer"
95-
type="external"
9693
onClick={ () =>
9794
recordEvent(
9895
'wcpay_overview_test_mode_learn_more_clicked'

client/components/test-mode-notice/test/__snapshots__/index.tsx.snap

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ exports[`Test mode notification Returns valid component for loans page 1`] = `
9595
`;
9696

9797
exports[`Test mode notification Returns valid component for overview page 1`] = `
98+
.emotion-2 {
99+
width: 1em;
100+
height: 1em;
101+
margin: 0;
102+
vertical-align: middle;
103+
fill: currentColor;
104+
}
105+
98106
<div>
99107
<div
100108
class="wcpay-banner-notice is-warning"
@@ -107,12 +115,33 @@ exports[`Test mode notification Returns valid component for overview page 1`] =
107115
</strong>
108116
All transactions will be simulated.
109117
<a
110-
data-link-type="external"
118+
class="components-external-link"
111119
href="https://woocommerce.com/document/woopayments/testing-and-troubleshooting/sandbox-mode/"
112-
rel="noreferrer"
120+
rel="external noreferrer noopener"
113121
target="_blank"
114122
>
115123
Learn more
124+
<span
125+
class="components-visually-hidden emotion-0 emotion-1"
126+
data-wp-c16t="true"
127+
data-wp-component="VisuallyHidden"
128+
style="border: 0px; clip: rect(1px, 1px, 1px, 1px); clip-path: inset( 50% ); height: 1px; margin: -1px; overflow: hidden; padding: 0px; position: absolute; width: 1px; word-wrap: normal;"
129+
>
130+
(opens in a new tab)
131+
</span>
132+
<svg
133+
aria-hidden="true"
134+
class="components-external-link__icon emotion-2 emotion-3"
135+
focusable="false"
136+
height="24"
137+
viewBox="0 0 24 24"
138+
width="24"
139+
xmlns="http://www.w3.org/2000/svg"
140+
>
141+
<path
142+
d="M18.2 17c0 .7-.6 1.2-1.2 1.2H7c-.7 0-1.2-.6-1.2-1.2V7c0-.7.6-1.2 1.2-1.2h3.2V4.2H7C5.5 4.2 4.2 5.5 4.2 7v10c0 1.5 1.2 2.8 2.8 2.8h10c1.5 0 2.8-1.2 2.8-2.8v-3.6h-1.5V17zM14.9 3v1.5h3.7l-6.4 6.4 1.1 1.1 6.4-6.4v3.7h1.5V3h-6.3z"
143+
/>
144+
</svg>
116145
</a>
117146
</div>
118147
</div>

client/documents/list/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import React, { useCallback, useEffect, useState } from 'react';
77
import { __, _n, sprintf } from '@wordpress/i18n';
88
import { TableCard, TableCardColumn } from '@woocommerce/components';
99
import { onQueryChange, getQuery } from '@woocommerce/navigation';
10-
import { Button } from 'wcpay/components/wp-components-wrapped/components/button';
1110

1211
/**
1312
* Internal dependencies
1413
*/
14+
import { Button } from 'wcpay/components/wp-components-wrapped/components/button';
1515
import { displayType } from 'documents/strings';
1616
import { Document, useDocuments, useDocumentsSummary } from 'data/index';
1717
import './style.scss';
@@ -198,6 +198,7 @@ export const DocumentsList = (): JSX.Element => {
198198
document.type
199199
)
200200
}
201+
__next40pxDefaultSize
201202
>
202203
{ __( 'Download', 'woocommerce-payments' ) }
203204
</Button>

client/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,13 @@ addFilter(
293293
} );
294294
if ( wcpaySettings && wcpaySettings.featureFlags.documents ) {
295295
pages.push( {
296-
container: DocumentsPage,
296+
container: () => (
297+
<WordPressComponentsContext.Provider
298+
value={ wp.components }
299+
>
300+
<DocumentsPage />
301+
</WordPressComponentsContext.Provider>
302+
),
297303
path: '/payments/documents',
298304
wpOpenMenu: menuID,
299305
breadcrumbs: [

client/vat/form-modal/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
* External dependencies
55
*/
66
import React from 'react';
7-
import { Modal } from 'wcpay/components/wp-components-wrapped/components/modal';
87
import { __ } from '@wordpress/i18n';
98

109
/**
1110
* Internal dependencies
1211
*/
12+
import { Modal } from 'wcpay/components/wp-components-wrapped/components/modal';
1313
import VatForm from '../form';
1414
import { VatFormOnCompleted } from '../types';
1515

client/vat/form/style.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,25 @@
22
margin: 0;
33
margin-top: 15px;
44
}
5+
6+
// This matches the styling of the VatNumberTask component before __nextHasNoMarginBottom was added in a few internal components.
7+
.wcpay-vat-number-task {
8+
&__checkbox {
9+
margin-bottom: 16px;
10+
}
11+
12+
&__text-control {
13+
margin-bottom: 16px;
14+
}
15+
}
16+
17+
// This matches the styling of the CompanyDataTask component before __nextHasNoMarginBottom was added in a few internal components.
18+
.wcpay-company-data-task {
19+
&__text-control {
20+
margin-bottom: 16px;
21+
}
22+
23+
&__textarea-control {
24+
margin-bottom: 16px;
25+
}
26+
}

client/vat/form/tasks/company-data-task.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,29 @@ export const CompanyDataTask = ( {
9797
>
9898
<CollapsibleBody>
9999
<TextControl
100+
className="wcpay-company-data-task__text-control"
100101
label={ __( 'Business name', 'woocommerce-payments' ) }
101102
value={ companyName }
102103
onChange={ setCompanyName }
104+
__nextHasNoMarginBottom
105+
__next40pxDefaultSize
103106
/>
104107

105108
<TextareaControl
109+
className="wcpay-company-data-task__textarea-control"
106110
label={ __( 'Address', 'woocommerce-payments' ) }
107111
value={ companyAddress }
108112
onChange={ setCompanyAddress }
113+
__nextHasNoMarginBottom
114+
__next40pxDefaultSize
109115
/>
110116

111117
<Button
112118
isPrimary
113119
disabled={ isConfirmButtonDisabled || isLoading }
114120
isBusy={ isLoading }
115121
onClick={ submit }
122+
__next40pxDefaultSize
116123
>
117124
{ __( 'Confirm', 'woocommerce-payments' ) }
118125
</Button>

client/vat/form/tasks/vat-number-task.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ export const VatNumberTask = ( {
218218

219219
<CollapsibleBody>
220220
<CheckboxControl
221+
className="wcpay-vat-number-task__checkbox"
221222
checked={ isVatRegistered }
222223
onChange={ setVatRegistered }
223224
label={ sprintf(
@@ -229,15 +230,19 @@ export const VatNumberTask = ( {
229230
getVatTaxIDName()
230231
) }
231232
help={ getVatTaxIDRequirementHint() }
233+
__nextHasNoMarginBottom
232234
/>
233235
{ isVatRegistered && (
234236
// Note: this TextControl is heavily parameterised to support different regions (VAT vs GST vs Corporate Number).
235237
// Long term, if we implement a dedicated WizardTaskItem component for each tax region, then this component will be simpler.
236238
<TextControl
239+
className="wcpay-vat-number-task__text-control"
237240
label={ getVatTaxIDName() }
238241
help={ getVatTaxIDValidationHint() }
239242
value={ vatNumber }
240243
onChange={ setVatNumber }
244+
__nextHasNoMarginBottom
245+
__next40pxDefaultSize
241246
/>
242247
) }
243248

@@ -246,6 +251,7 @@ export const VatNumberTask = ( {
246251
disabled={ isVatButtonDisabled || isLoading }
247252
isBusy={ isLoading }
248253
onClick={ submit }
254+
__next40pxDefaultSize
249255
>
250256
{ __( 'Continue', 'woocommerce-payments' ) }
251257
</Button>

0 commit comments

Comments
 (0)