mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
✨ Provide means to update styling of a button
Before this, we needed to create a new button instance to display changes in button style. This allows updating an existing button instance
This commit is contained in:
parent
3538a69402
commit
722289a545
4 changed files with 69 additions and 38 deletions
|
@ -185,8 +185,6 @@ class GooglepayButton extends PaymentButton {
|
|||
|
||||
this.allowedPaymentMethods = this.googlePayConfig.allowedPaymentMethods;
|
||||
this.baseCardPaymentMethod = this.allowedPaymentMethods[ 0 ];
|
||||
|
||||
this.log( 'CONFIG', transactionInfo );
|
||||
}
|
||||
|
||||
init() {
|
||||
|
@ -231,10 +229,6 @@ class GooglepayButton extends PaymentButton {
|
|||
}
|
||||
|
||||
reinit() {
|
||||
if ( ! this.isInitialized ) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.reinit();
|
||||
this.init();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,13 @@ import GooglepayButton from './GooglepayButton';
|
|||
* A single GooglePay preview button instance.
|
||||
*/
|
||||
export default class GooglePayPreviewButton extends PreviewButton {
|
||||
/**
|
||||
* Instance of the preview button.
|
||||
*
|
||||
* @type {?PaymentButton}
|
||||
*/
|
||||
#button = null;
|
||||
|
||||
constructor( args ) {
|
||||
super( args );
|
||||
|
||||
|
@ -36,20 +43,23 @@ export default class GooglePayPreviewButton extends PreviewButton {
|
|||
null
|
||||
);
|
||||
|
||||
/* Intentionally using `new` keyword, instead of the `.createButton()` factory,
|
||||
* as the factory is designed to only create a single button per context, while a single
|
||||
* page can contain multiple instances of a preview button.
|
||||
*/
|
||||
const button = new GooglepayButton(
|
||||
'preview',
|
||||
null,
|
||||
buttonConfig,
|
||||
this.ppcpConfig,
|
||||
contextHandler
|
||||
);
|
||||
if ( ! this.#button ) {
|
||||
/* Intentionally using `new` keyword, instead of the `.createButton()` factory,
|
||||
* as the factory is designed to only create a single button per context, while a single
|
||||
* page can contain multiple instances of a preview button.
|
||||
*/
|
||||
this.#button = new GooglepayButton(
|
||||
'preview',
|
||||
null,
|
||||
buttonConfig,
|
||||
this.ppcpConfig,
|
||||
contextHandler
|
||||
);
|
||||
}
|
||||
|
||||
button.configure( this.apiConfig, null );
|
||||
button.init();
|
||||
this.#button.configure( this.apiConfig, null );
|
||||
this.#button.applyButtonStyles( buttonConfig, this.ppcpConfig );
|
||||
this.#button.reinit();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue