mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Add loading spinner
This commit is contained in:
parent
9ded2bfa17
commit
d8ff7f79e6
1 changed files with 6 additions and 1 deletions
|
@ -1,12 +1,15 @@
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
|
import { useState } from '@wordpress/element';
|
||||||
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
|
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
|
||||||
import { PanelBody, SelectControl } from '@wordpress/components';
|
import { PanelBody, SelectControl, Spinner } from '@wordpress/components';
|
||||||
import { PayPalScriptProvider, PayPalMessages } from "@paypal/react-paypal-js";
|
import { PayPalScriptProvider, PayPalMessages } from "@paypal/react-paypal-js";
|
||||||
|
|
||||||
export default function Edit( { attributes, setAttributes } ) {
|
export default function Edit( { attributes, setAttributes } ) {
|
||||||
const { layout, logo, position, color, flexColor, flexRatio } = attributes;
|
const { layout, logo, position, color, flexColor, flexRatio } = attributes;
|
||||||
const isFlex = layout === 'flex';
|
const isFlex = layout === 'flex';
|
||||||
|
|
||||||
|
const [loaded, setLoaded] = useState(false);
|
||||||
|
|
||||||
const previewStyle = {
|
const previewStyle = {
|
||||||
layout,
|
layout,
|
||||||
logo: {
|
logo: {
|
||||||
|
@ -102,10 +105,12 @@ export default function Edit( { attributes, setAttributes } ) {
|
||||||
<PayPalMessages
|
<PayPalMessages
|
||||||
style={previewStyle}
|
style={previewStyle}
|
||||||
forceReRender={[previewStyle]}
|
forceReRender={[previewStyle]}
|
||||||
|
onRender={() => setLoaded(true)}
|
||||||
/>
|
/>
|
||||||
</PayPalScriptProvider>
|
</PayPalScriptProvider>
|
||||||
</div>
|
</div>
|
||||||
<div className={'ppcp-overlay-child ppcp-unclicable-overlay'}> {/* make the message not clickable */}
|
<div className={'ppcp-overlay-child ppcp-unclicable-overlay'}> {/* make the message not clickable */}
|
||||||
|
{!loaded && (<Spinner/>)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue