mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 13:44:42 +08:00
♻️ Migrate InputSettings to ControlTextInput
This commit is contained in:
parent
2f79a9fe4d
commit
f90ab656f5
6 changed files with 62 additions and 71 deletions
|
@ -0,0 +1,18 @@
|
||||||
|
import { TextControl } from '@wordpress/components';
|
||||||
|
|
||||||
|
import { Action } from '../Elements';
|
||||||
|
|
||||||
|
const ControlTextInput = ( { value, onChange, placeholder = '' } ) => {
|
||||||
|
return (
|
||||||
|
<Action>
|
||||||
|
<TextControl
|
||||||
|
className="ppcp-r-vertical-text-control"
|
||||||
|
placeholder={ placeholder }
|
||||||
|
value={ value }
|
||||||
|
onChange={ onChange }
|
||||||
|
/>
|
||||||
|
</Action>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ControlTextInput;
|
|
@ -1,37 +0,0 @@
|
||||||
import { TextControl } from '@wordpress/components';
|
|
||||||
|
|
||||||
import SettingsBlock from '../SettingsBlock';
|
|
||||||
import { Title, Action, Description, TitleExtra } from '../Elements';
|
|
||||||
|
|
||||||
const InputSettingsBlock = ( {
|
|
||||||
title,
|
|
||||||
description,
|
|
||||||
supplementaryLabel,
|
|
||||||
showDescriptionFirst = false,
|
|
||||||
value,
|
|
||||||
onChange,
|
|
||||||
placeholder = '',
|
|
||||||
} ) => {
|
|
||||||
const TheDescription = <Description>{ description }</Description>;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<SettingsBlock className="ppcp-r-settings-block__input">
|
|
||||||
<Title>
|
|
||||||
{ title }
|
|
||||||
<TitleExtra>{ supplementaryLabel }</TitleExtra>
|
|
||||||
</Title>
|
|
||||||
{ showDescriptionFirst && TheDescription }
|
|
||||||
<Action>
|
|
||||||
<TextControl
|
|
||||||
className="ppcp-r-vertical-text-control"
|
|
||||||
placeholder={ placeholder }
|
|
||||||
value={ value }
|
|
||||||
onChange={ onChange }
|
|
||||||
/>
|
|
||||||
</Action>
|
|
||||||
{ ! showDescriptionFirst && TheDescription }
|
|
||||||
</SettingsBlock>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default InputSettingsBlock;
|
|
|
@ -1,8 +1,9 @@
|
||||||
export { default as ButtonSettingsBlock } from './ButtonSettingsBlock';
|
export { default as ButtonSettingsBlock } from './ButtonSettingsBlock';
|
||||||
export { default as InputSettingsBlock } from './InputSettingsBlock';
|
|
||||||
export { default as SelectSettingsBlock } from './SelectSettingsBlock';
|
export { default as SelectSettingsBlock } from './SelectSettingsBlock';
|
||||||
export { default as AccordionSettingsBlock } from './AccordionSettingsBlock';
|
export { default as AccordionSettingsBlock } from './AccordionSettingsBlock';
|
||||||
export { default as ToggleSettingsBlock } from './ToggleSettingsBlock';
|
export { default as ToggleSettingsBlock } from './ToggleSettingsBlock';
|
||||||
export { default as RadioSettingsBlock } from './RadioSettingsBlock';
|
export { default as RadioSettingsBlock } from './RadioSettingsBlock';
|
||||||
export { default as PaymentMethodsBlock } from './PaymentMethodsBlock';
|
export { default as PaymentMethodsBlock } from './PaymentMethodsBlock';
|
||||||
export { default as PaymentMethodItemBlock } from './PaymentMethodItemBlock';
|
export { default as PaymentMethodItemBlock } from './PaymentMethodItemBlock';
|
||||||
|
|
||||||
|
export { default as ControlTextInput } from './ControlTextInput';
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Button } from '@wordpress/components';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AccordionSettingsBlock,
|
AccordionSettingsBlock,
|
||||||
InputSettingsBlock,
|
ControlTextInput,
|
||||||
RadioSettingsBlock,
|
RadioSettingsBlock,
|
||||||
} from '../../../../ReusableComponents/SettingsBlocks';
|
} from '../../../../ReusableComponents/SettingsBlocks';
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ const generateOptions = ( config, settings, updateFormValue ) => [
|
||||||
),
|
),
|
||||||
additionalContent: (
|
additionalContent: (
|
||||||
<>
|
<>
|
||||||
<InputSettingsBlock
|
<ControlTextInput
|
||||||
title={ config.clientIdTitle }
|
title={ config.clientIdTitle }
|
||||||
// Input field props.
|
// Input field props.
|
||||||
value={ settings[ `${ config.mode }ClientId` ] }
|
value={ settings[ `${ config.mode }ClientId` ] }
|
||||||
|
@ -90,7 +90,7 @@ const generateOptions = ( config, settings, updateFormValue ) => [
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
) }
|
) }
|
||||||
/>
|
/>
|
||||||
<InputSettingsBlock
|
<ControlTextInput
|
||||||
title={ config.secretKeyTitle }
|
title={ config.secretKeyTitle }
|
||||||
// Input field props.
|
// Input field props.
|
||||||
value={ settings[ `${ config.mode }SecretKey` ] }
|
value={ settings[ `${ config.mode }SecretKey` ] }
|
||||||
|
|
|
@ -3,9 +3,10 @@ import {
|
||||||
AccordionSettingsBlock,
|
AccordionSettingsBlock,
|
||||||
RadioSettingsBlock,
|
RadioSettingsBlock,
|
||||||
ToggleSettingsBlock,
|
ToggleSettingsBlock,
|
||||||
InputSettingsBlock,
|
ControlTextInput,
|
||||||
SelectSettingsBlock,
|
SelectSettingsBlock,
|
||||||
} from '../../../../ReusableComponents/SettingsBlocks';
|
} from '../../../../ReusableComponents/SettingsBlocks';
|
||||||
|
import SettingsBlock from '../../../../ReusableComponents/SettingsBlock';
|
||||||
|
|
||||||
const PaypalSettings = ( { updateFormValue, settings } ) => {
|
const PaypalSettings = ( { updateFormValue, settings } ) => {
|
||||||
return (
|
return (
|
||||||
|
@ -81,37 +82,39 @@ const PaypalSettings = ( { updateFormValue, settings } ) => {
|
||||||
} }
|
} }
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<InputSettingsBlock
|
<SettingsBlock
|
||||||
title={ __( 'Brand name', 'woocommerce-paypal-payments' ) }
|
title={ __( 'Brand name', 'woocommerce-paypal-payments' ) }
|
||||||
description={ __(
|
headerDescription={ __(
|
||||||
'What business name to show to your buyers during checkout and on receipts.',
|
'What business name to show to your buyers during checkout and on receipts.',
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
) }
|
) }
|
||||||
showDescriptionFirst={ true }
|
>
|
||||||
// Input field props.
|
<ControlTextInput
|
||||||
value={ settings.brandName }
|
value={ settings.brandName }
|
||||||
onChange={ updateFormValue }
|
onChange={ updateFormValue }
|
||||||
placeholder={ __(
|
placeholder={ __(
|
||||||
'Brand name',
|
'Brand name',
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
) }
|
) }
|
||||||
/>
|
/>
|
||||||
|
</SettingsBlock>
|
||||||
|
|
||||||
<InputSettingsBlock
|
<SettingsBlock
|
||||||
title={ __( 'Soft Descriptor', 'woocommerce-paypal-payments' ) }
|
title={ __( 'Soft Descriptor', 'woocommerce-paypal-payments' ) }
|
||||||
description={ __(
|
headerDescription={ __(
|
||||||
"The dynamic text used to construct the statement descriptor that appears on a payer's card statement. Applies to PayPal and Credit Card transactions. Max value of 22 characters.",
|
"The dynamic text used to construct the statement descriptor that appears on a payer's card statement. Applies to PayPal and Credit Card transactions. Max value of 22 characters.",
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
) }
|
) }
|
||||||
showDescriptionFirst={ true }
|
>
|
||||||
// Input field props.
|
<ControlTextInput
|
||||||
value={ settings.softDescriptor }
|
value={ settings.softDescriptor }
|
||||||
onChange={ updateFormValue }
|
onChange={ updateFormValue }
|
||||||
placeholder={ __(
|
placeholder={ __(
|
||||||
'Soft Descriptor',
|
'Soft Descriptor',
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
) }
|
) }
|
||||||
/>
|
/>
|
||||||
|
</SettingsBlock>
|
||||||
|
|
||||||
<RadioSettingsBlock
|
<RadioSettingsBlock
|
||||||
title={ __(
|
title={ __(
|
||||||
|
|
|
@ -1,23 +1,29 @@
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { InputSettingsBlock } from '../../../../../ReusableComponents/SettingsBlocks';
|
import { ControlTextInput } from '../../../../../ReusableComponents/SettingsBlocks';
|
||||||
import { SettingsHooks } from '../../../../../../data';
|
import { SettingsHooks } from '../../../../../../data';
|
||||||
|
import SettingsBlock from '../../../../../ReusableComponents/SettingsBlock';
|
||||||
|
|
||||||
const InvoicePrefix = () => {
|
const InvoicePrefix = () => {
|
||||||
const { invoicePrefix, setInvoicePrefix } = SettingsHooks.useSettings();
|
const { invoicePrefix, setInvoicePrefix } = SettingsHooks.useSettings();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InputSettingsBlock
|
<SettingsBlock
|
||||||
title="Invoice Prefix"
|
title="Invoice Prefix"
|
||||||
supplementaryLabel={ __(
|
supplementaryLabel={ __(
|
||||||
'(Recommended)',
|
'(Recommended)',
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
) }
|
) }
|
||||||
description="Add a unique prefix to invoice numbers for site-specific tracking (recommended)."
|
description="Add a unique prefix to invoice numbers for site-specific tracking (recommended)."
|
||||||
// Input field props.
|
>
|
||||||
placeholder={ __( 'Input prefix', 'woocommerce-paypal-payments' ) }
|
<ControlTextInput
|
||||||
onChange={ setInvoicePrefix }
|
placeholder={ __(
|
||||||
value={ invoicePrefix }
|
'Input prefix',
|
||||||
/>
|
'woocommerce-paypal-payments'
|
||||||
|
) }
|
||||||
|
onChange={ setInvoicePrefix }
|
||||||
|
value={ invoicePrefix }
|
||||||
|
/>
|
||||||
|
</SettingsBlock>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue