Skip to content

Commit

Permalink
Use the LoadingMask component from WooCommerce Blocks for PRB loading…
Browse files Browse the repository at this point in the history
… status in the Cart and Checkout Blocks (#2248)
  • Loading branch information
reykjalin authored Dec 29, 2021
1 parent a86630b commit 4f47751
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 40 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Tweak - Redirect to the settings tab after an account is connected.
* Tweak - Prompt message when navigating out Stripe settings with unsaved changes
* Tweak - Show toast when payment methods list is updated with new payment methods.
* Tweak - Use the newly exposed LoadableMask component provided by WooCommerce Blocks to trigger the loading state for Payment Request Buttons.
* Fix - JS error on checkout when Boleto method was not active.
* Fix - Fixed bug that show "Use new payment method" on pay order page when there were no saved card was.
* Tweak - Autocomplete for account keys and webhooks fields were disabled.
Expand Down
65 changes: 25 additions & 40 deletions client/blocks/payment-request/payment-request-express.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { __ } from '@wordpress/i18n';
import {
Elements,
PaymentRequestButtonElement,
Expand Down Expand Up @@ -38,6 +39,7 @@ import { getBlocksConfiguration } from 'wcstripe/blocks/utils';
*/
const PaymentRequestExpressComponent = ( {
billing,
components,
shippingData,
onClick,
onClose,
Expand Down Expand Up @@ -91,49 +93,41 @@ const PaymentRequestExpressComponent = ( {
return null;
}

const { LoadingMask } = components;

if ( isCustom ) {
return (
<div
className={
isUpdatingPaymentRequest
? 'wc-block-components-loading-mask'
: ''
}
<LoadingMask
isLoading={ isUpdatingPaymentRequest }
screenReaderLabel={ __(
'Loading payment request…',
'woocommerce-gateway-stripe'
) }
>
<CustomButton
className={
isUpdatingPaymentRequest
? 'wc-block-components-loading-mask__children'
: ''
}
onButtonClicked={ ( evt ) => {
onPaymentRequestButtonClick( evt, paymentRequest );
} }
/>
</div>
</LoadingMask>
);
}

if ( isBranded && shouldUseGooglePayBrand() ) {
return (
<div
className={
isUpdatingPaymentRequest
? 'wc-block-components-loading-mask'
: ''
}
<LoadingMask
isLoading={ isUpdatingPaymentRequest }
screenReaderLabel={ __(
'Loading payment request…',
'woocommerce-gateway-stripe'
) }
>
<GooglePayButton
className={
isUpdatingPaymentRequest
? 'wc-block-components-loading-mask__children'
: ''
}
onButtonClicked={ ( evt ) => {
onPaymentRequestButtonClick( evt, paymentRequest );
} }
/>
</div>
</LoadingMask>
);
}

Expand All @@ -146,30 +140,21 @@ const PaymentRequestExpressComponent = ( {
}

return (
// The classNames here manually trigger the loading state for the PRB. Hopefully we'll
// see an API introduced to WooCommerce Blocks that will let us control this without
// relying on a CSS class.
// - @reykjalin
<div
className={
isUpdatingPaymentRequest
? 'wc-block-components-loading-mask'
: ''
}
<LoadingMask
isLoading={ isUpdatingPaymentRequest }
screenReaderLabel={ __(
'Loading payment request…',
'woocommerce-gateway-stripe'
) }
>
<PaymentRequestButtonElement
className={
isUpdatingPaymentRequest
? 'wc-block-components-loading-mask__children'
: ''
}
onClick={ onPaymentRequestButtonClick }
options={ {
style: paymentRequestButtonStyle,
paymentRequest,
} }
/>
</div>
</LoadingMask>
);
};

Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ If you get stuck, you can ask for help in the Plugin Forum.
= 6.x.x - 2022-xx-xx =
* Fix - Fixed capitalization for payment method names: iDEAL, giropay, and Sofort.
* Add - Text to explain how to enable webhooks when manually entering your API keys in the new Stripe settings.
* Tweak - Use the newly exposed LoadableMask component provided by WooCommerce Blocks to trigger the loading state for Payment Request Buttons.
* Tweak - Redirect to the settings tab after an account is connected
* Tweak - Prompt message when navigating out Stripe settings with unsaved changes
* Tweak - Show toast when payment methods list is updated with new payment methods.
Expand Down

0 comments on commit 4f47751

Please sign in to comment.