/** * External dependencies */ import { InspectorControls, useBlockProps } from '@wordpress/block-editor'; import { PanelBody, RadioControl, ToggleControl, Notice, TextControl, } from '@wordpress/components'; import ExternalLinkCard from '@woocommerce/editor-components/external-link-card'; import { ADMIN_URL } from '@woocommerce/settings'; import { useExpressPaymentMethods } from '@woocommerce/base-context/hooks'; import { __ } from '@wordpress/i18n'; import clsx from 'clsx'; /** * Internal dependencies */ import Block from './block'; import './editor.scss'; import { ExpressCheckoutAttributes } from './types'; import { ExpressCheckoutContext } from './context'; export const Edit = ( { attributes, setAttributes, }: { attributes: ExpressCheckoutAttributes; setAttributes: ( attributes: Record< string, unknown > ) => undefined; } ): JSX.Element | null => { const { paymentMethods, isInitialized } = useExpressPaymentMethods(); const hasExpressPaymentMethods = Object.keys( paymentMethods ).length > 0; const blockProps = useBlockProps( { className: clsx( { 'wp-block-woocommerce-checkout-express-payment-block--has-express-payment-methods': hasExpressPaymentMethods, }, attributes?.className ), attributes, } ); if ( ! isInitialized || ! hasExpressPaymentMethods ) { return null; } const { buttonHeight, buttonBorderRadius, showButtonStyles } = attributes; const buttonStyleControls = ( <> setAttributes( { buttonHeight: newValue } ) } />
setAttributes( { buttonBorderRadius: newValue, } ) } /> px
); const showControls = () => { if ( showButtonStyles ) { return buttonStyleControls; } return (

{ __( 'You can change the appearance of individual buttons in the respective payment extension settings page', 'woocommerce' ) }

); }; return (

{ __( 'These settings will override the plugin specific styles for these buttons', 'woocommerce' ) }

setAttributes( { showButtonStyles: ! showButtonStyles, } ) } /> { showControls() }
); }; export const Save = (): JSX.Element => { return
; };