1
+ import { __ } from '@wordpress/i18n' ;
1
2
import {
2
3
Elements ,
3
4
PaymentRequestButtonElement ,
@@ -38,6 +39,7 @@ import { getBlocksConfiguration } from 'wcstripe/blocks/utils';
38
39
*/
39
40
const PaymentRequestExpressComponent = ( {
40
41
billing,
42
+ components,
41
43
shippingData,
42
44
onClick,
43
45
onClose,
@@ -91,49 +93,41 @@ const PaymentRequestExpressComponent = ( {
91
93
return null ;
92
94
}
93
95
96
+ const { LoadingMask } = components ;
97
+
94
98
if ( isCustom ) {
95
99
return (
96
- < div
97
- className = {
98
- isUpdatingPaymentRequest
99
- ? 'wc-block-components-loading-mask'
100
- : ' '
101
- }
100
+ < LoadingMask
101
+ isLoading = { isUpdatingPaymentRequest }
102
+ screenReaderLabel = { __ (
103
+ 'Loading payment request…' ,
104
+ 'woocommerce-gateway-stripe '
105
+ ) }
102
106
>
103
107
< CustomButton
104
- className = {
105
- isUpdatingPaymentRequest
106
- ? 'wc-block-components-loading-mask__children'
107
- : ''
108
- }
109
108
onButtonClicked = { ( evt ) => {
110
109
onPaymentRequestButtonClick ( evt , paymentRequest ) ;
111
110
} }
112
111
/>
113
- </ div >
112
+ </ LoadingMask >
114
113
) ;
115
114
}
116
115
117
116
if ( isBranded && shouldUseGooglePayBrand ( ) ) {
118
117
return (
119
- < div
120
- className = {
121
- isUpdatingPaymentRequest
122
- ? 'wc-block-components-loading-mask'
123
- : ' '
124
- }
118
+ < LoadingMask
119
+ isLoading = { isUpdatingPaymentRequest }
120
+ screenReaderLabel = { __ (
121
+ 'Loading payment request…' ,
122
+ 'woocommerce-gateway-stripe '
123
+ ) }
125
124
>
126
125
< GooglePayButton
127
- className = {
128
- isUpdatingPaymentRequest
129
- ? 'wc-block-components-loading-mask__children'
130
- : ''
131
- }
132
126
onButtonClicked = { ( evt ) => {
133
127
onPaymentRequestButtonClick ( evt , paymentRequest ) ;
134
128
} }
135
129
/>
136
- </ div >
130
+ </ LoadingMask >
137
131
) ;
138
132
}
139
133
@@ -146,30 +140,21 @@ const PaymentRequestExpressComponent = ( {
146
140
}
147
141
148
142
return (
149
- // The classNames here manually trigger the loading state for the PRB. Hopefully we'll
150
- // see an API introduced to WooCommerce Blocks that will let us control this without
151
- // relying on a CSS class.
152
- // - @reykjalin
153
- < div
154
- className = {
155
- isUpdatingPaymentRequest
156
- ? 'wc-block-components-loading-mask'
157
- : ''
158
- }
143
+ < LoadingMask
144
+ isLoading = { isUpdatingPaymentRequest }
145
+ screenReaderLabel = { __ (
146
+ 'Loading payment request…' ,
147
+ 'woocommerce-gateway-stripe'
148
+ ) }
159
149
>
160
150
< PaymentRequestButtonElement
161
- className = {
162
- isUpdatingPaymentRequest
163
- ? 'wc-block-components-loading-mask__children'
164
- : ''
165
- }
166
151
onClick = { onPaymentRequestButtonClick }
167
152
options = { {
168
153
style : paymentRequestButtonStyle ,
169
154
paymentRequest,
170
155
} }
171
156
/>
172
- </ div >
157
+ </ LoadingMask >
173
158
) ;
174
159
} ;
175
160
0 commit comments