2024-10-09 16:38:11 +02:00
|
|
|
import { useMemo } from '@wordpress/element';
|
|
|
|
import { combineStyles } from '../../../../../ppcp-button/resources/js/modules/Helper/PaymentButtonHelpers';
|
|
|
|
|
2024-11-07 01:00:53 +01:00
|
|
|
const useButtonStyles = ( buttonConfig, ppcpConfig, buttonAttributes ) => {
|
2024-10-09 16:38:11 +02:00
|
|
|
return useMemo( () => {
|
|
|
|
const styles = combineStyles(
|
|
|
|
ppcpConfig?.button || {},
|
|
|
|
buttonConfig?.button || {}
|
|
|
|
);
|
|
|
|
|
2024-11-07 01:00:53 +01:00
|
|
|
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' ) {
|
2024-10-09 16:38:11 +02:00
|
|
|
styles.MiniCart.type = 'pay';
|
|
|
|
}
|
|
|
|
|
|
|
|
return styles;
|
2024-11-07 01:00:53 +01:00
|
|
|
}, [ buttonConfig, ppcpConfig, buttonAttributes ] );
|
2024-10-09 16:38:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default useButtonStyles;
|