woocommerce-paypal-payments/modules/ppcp-googlepay/resources/js/Block/hooks/useButtonStyles.js
2024-11-07 01:00:53 +01:00

26 lines
773 B
JavaScript

import { useMemo } from '@wordpress/element';
import { combineStyles } from '../../../../../ppcp-button/resources/js/modules/Helper/PaymentButtonHelpers';
const useButtonStyles = ( buttonConfig, ppcpConfig, buttonAttributes ) => {
return useMemo( () => {
const styles = combineStyles(
ppcpConfig?.button || {},
buttonConfig?.button || {}
);
if ( buttonAttributes && styles.Default ) {
styles.Default.height =
buttonAttributes.height || styles.Default.height;
styles.Default.borderRadius =
buttonAttributes.borderRadius || styles.Default.borderRadius;
}
if ( styles.MiniCart?.type === 'buy' ) {
styles.MiniCart.type = 'pay';
}
return styles;
}, [ buttonConfig, ppcpConfig, buttonAttributes ] );
};
export default useButtonStyles;