Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the LoadingMask component from WooCommerce Blocks for PRB loading status in the Cart and Checkout Blocks #2248

Merged
merged 3 commits into from
Dec 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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