mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
♻️ Restructure Styling component files
This commit is contained in:
parent
0673e5d813
commit
2112769de9
14 changed files with 171 additions and 124 deletions
|
@ -0,0 +1,21 @@
|
||||||
|
import { __ } from '@wordpress/i18n';
|
||||||
|
|
||||||
|
import { StylingHooks } from '../../../../../../data';
|
||||||
|
import { SelectStylingSection } from '../Layout';
|
||||||
|
|
||||||
|
const SectionButtonColor = ( { location } ) => {
|
||||||
|
const { color, setColor, colorChoices } =
|
||||||
|
StylingHooks.useStylingProps( location );
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SelectStylingSection
|
||||||
|
title={ __( 'Button Color', 'woocommerce-paypal-payments' ) }
|
||||||
|
className="button-color"
|
||||||
|
options={ colorChoices }
|
||||||
|
value={ color }
|
||||||
|
onChange={ setColor }
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SectionButtonColor;
|
|
@ -0,0 +1,21 @@
|
||||||
|
import { __ } from '@wordpress/i18n';
|
||||||
|
|
||||||
|
import { StylingHooks } from '../../../../../../data';
|
||||||
|
import { SelectStylingSection } from '../Layout';
|
||||||
|
|
||||||
|
const SectionButtonLabel = ( { location } ) => {
|
||||||
|
const { label, setLabel, labelChoices } =
|
||||||
|
StylingHooks.useStylingProps( location );
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SelectStylingSection
|
||||||
|
title={ __( 'Button Label', 'woocommerce-paypal-payments' ) }
|
||||||
|
className="button-label"
|
||||||
|
options={ labelChoices }
|
||||||
|
value={ label }
|
||||||
|
onChange={ setLabel }
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SectionButtonLabel;
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { __ } from '@wordpress/i18n';
|
||||||
|
|
||||||
|
import { StylingHooks } from '../../../../../../data';
|
||||||
|
import { RadiobuttonStylingSection } from '../Layout';
|
||||||
|
|
||||||
|
const SectionButtonLayout = ( { location } ) => {
|
||||||
|
const { supportsLayout, layout, setLayout, layoutChoices } =
|
||||||
|
StylingHooks.useStylingProps( location );
|
||||||
|
|
||||||
|
if ( ! supportsLayout ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<RadiobuttonStylingSection
|
||||||
|
className="button-layout"
|
||||||
|
title={ __( 'Button Layout', 'woocommerce-paypal-payments' ) }
|
||||||
|
options={ layoutChoices }
|
||||||
|
selected={ layout }
|
||||||
|
onChange={ setLayout }
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SectionButtonLayout;
|
|
@ -0,0 +1,21 @@
|
||||||
|
import { __ } from '@wordpress/i18n';
|
||||||
|
|
||||||
|
import { StylingHooks } from '../../../../../../data';
|
||||||
|
import { RadiobuttonStylingSection } from '../Layout';
|
||||||
|
|
||||||
|
const SectionButtonShape = ( { location } ) => {
|
||||||
|
const { shape, setShape, shapeChoices } =
|
||||||
|
StylingHooks.useStylingProps( location );
|
||||||
|
|
||||||
|
return (
|
||||||
|
<RadiobuttonStylingSection
|
||||||
|
title={ __( 'Shape', 'woocommerce-paypal-payments' ) }
|
||||||
|
className="button-shape"
|
||||||
|
options={ shapeChoices }
|
||||||
|
selected={ shape }
|
||||||
|
onChange={ setShape }
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SectionButtonShape;
|
|
@ -1,9 +1,8 @@
|
||||||
import { __, sprintf } from '@wordpress/i18n';
|
import { __, sprintf } from '@wordpress/i18n';
|
||||||
|
|
||||||
import { StylingHooks } from '../../../../../data';
|
import { StylingHooks } from '../../../../../../data';
|
||||||
import { Description } from '../../../../ReusableComponents/SettingsBlocks';
|
import { Description } from '../../../../../ReusableComponents/SettingsBlocks';
|
||||||
import StylingSection from './StylingSection';
|
import { SelectStylingSection, StylingSection } from '../Layout';
|
||||||
import StylingSectionWithSelect from './StylingSectionWithSelect';
|
|
||||||
|
|
||||||
const LocationSelector = ( { location, setLocation } ) => {
|
const LocationSelector = ( { location, setLocation } ) => {
|
||||||
const { locationChoices, locationDetails } =
|
const { locationChoices, locationDetails } =
|
||||||
|
@ -22,9 +21,9 @@ const LocationSelector = ( { location, setLocation } ) => {
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
) }
|
) }
|
||||||
></StylingSection>
|
></StylingSection>
|
||||||
<StylingSectionWithSelect
|
<SelectStylingSection
|
||||||
className="location-selector"
|
className="location-selector"
|
||||||
title={ __( 'Locations', 'woocommerce-paypal-payments' ) }
|
title={ __( 'Location', 'woocommerce-paypal-payments' ) }
|
||||||
separatorAndGap={ false }
|
separatorAndGap={ false }
|
||||||
options={ locationChoices }
|
options={ locationChoices }
|
||||||
value={ location }
|
value={ location }
|
||||||
|
@ -33,7 +32,7 @@ const LocationSelector = ( { location, setLocation } ) => {
|
||||||
<Description asHtml={ true }>
|
<Description asHtml={ true }>
|
||||||
{ locationDescription }
|
{ locationDescription }
|
||||||
</Description>
|
</Description>
|
||||||
</StylingSectionWithSelect>
|
</SelectStylingSection>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
|
@ -0,0 +1,21 @@
|
||||||
|
import { __ } from '@wordpress/i18n';
|
||||||
|
|
||||||
|
import { StylingHooks } from '../../../../../../data';
|
||||||
|
import { CheckboxStylingSection } from '../Layout';
|
||||||
|
|
||||||
|
const SectionPaymentMethods = ( { location } ) => {
|
||||||
|
const { paymentMethods, setPaymentMethods, paymentMethodChoices } =
|
||||||
|
StylingHooks.useStylingProps( location );
|
||||||
|
|
||||||
|
return (
|
||||||
|
<CheckboxStylingSection
|
||||||
|
title={ __( 'Payment Methods', 'woocommerce-paypal-payments' ) }
|
||||||
|
className="payment-methods"
|
||||||
|
options={ paymentMethodChoices }
|
||||||
|
value={ paymentMethods }
|
||||||
|
onChange={ setPaymentMethods }
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SectionPaymentMethods;
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { __ } from '@wordpress/i18n';
|
||||||
|
|
||||||
|
import { StylingHooks } from '../../../../../../data';
|
||||||
|
import { CheckboxStylingSection } from '../Layout';
|
||||||
|
|
||||||
|
const SectionTagline = ( { location } ) => {
|
||||||
|
const { supportsTagline, tagline, setTagline, taglineChoices } =
|
||||||
|
StylingHooks.useStylingProps( location );
|
||||||
|
|
||||||
|
if ( ! supportsTagline ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<CheckboxStylingSection
|
||||||
|
title={ __( 'Tagline', 'woocommerce-paypal-payments' ) }
|
||||||
|
className="tagline"
|
||||||
|
options={ taglineChoices }
|
||||||
|
value={ tagline }
|
||||||
|
onChange={ setTagline }
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SectionTagline;
|
|
@ -0,0 +1,7 @@
|
||||||
|
export { default as LocationSelector } from './LocationSelector';
|
||||||
|
export { default as ButtonColor } from './ButtonColor';
|
||||||
|
export { default as ButtonLabel } from './ButtonLabel';
|
||||||
|
export { default as ButtonLayout } from './ButtonLayout';
|
||||||
|
export { default as ButtonShape } from './ButtonShape';
|
||||||
|
export { default as PaymentMethods } from './PaymentMethods';
|
||||||
|
export { default as TagLine } from './TagLine';
|
|
@ -1,9 +1,9 @@
|
||||||
import SettingsBlock from '../../../../ReusableComponents/SettingsBlocks/SettingsBlock';
|
import SettingsBlock from '../../../../../ReusableComponents/SettingsBlocks/SettingsBlock';
|
||||||
import {
|
import {
|
||||||
Description,
|
Description,
|
||||||
Header,
|
Header,
|
||||||
Title,
|
Title,
|
||||||
} from '../../../../ReusableComponents/SettingsBlocks';
|
} from '../../../../../ReusableComponents/SettingsBlocks';
|
||||||
|
|
||||||
const StylingSection = ( {
|
const StylingSection = ( {
|
||||||
title,
|
title,
|
|
@ -1,7 +1,7 @@
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import { CheckboxGroup } from '../../../../ReusableComponents/Fields';
|
import { CheckboxGroup } from '../../../../../ReusableComponents/Fields';
|
||||||
import HStack from '../../../../ReusableComponents/HStack';
|
import HStack from '../../../../../ReusableComponents/HStack';
|
||||||
import StylingSection from './StylingSection';
|
import StylingSection from './StylingSection';
|
||||||
|
|
||||||
const StylingSectionWithCheckboxes = ( {
|
const StylingSectionWithCheckboxes = ( {
|
|
@ -1,7 +1,7 @@
|
||||||
import { RadioControl } from '@wordpress/components';
|
import { RadioControl } from '@wordpress/components';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import HStack from '../../../../ReusableComponents/HStack';
|
import HStack from '../../../../../ReusableComponents/HStack';
|
||||||
import StylingSection from './StylingSection';
|
import StylingSection from './StylingSection';
|
||||||
|
|
||||||
const StylingSectionWithRadiobuttons = ( {
|
const StylingSectionWithRadiobuttons = ( {
|
|
@ -0,0 +1,4 @@
|
||||||
|
export { default as StylingSection } from './StylingSection';
|
||||||
|
export { default as CheckboxStylingSection } from './StylingSectionWithCheckboxes';
|
||||||
|
export { default as RadiobuttonStylingSection } from './StylingSectionWithRadiobuttons';
|
||||||
|
export { default as SelectStylingSection } from './StylingSectionWithSelect';
|
|
@ -1,10 +1,13 @@
|
||||||
import { __ } from '@wordpress/i18n';
|
|
||||||
|
|
||||||
import { StylingHooks } from '../../../../../data';
|
import { StylingHooks } from '../../../../../data';
|
||||||
import LocationSelector from './LocationSelector';
|
import {
|
||||||
import StylingSectionWithSelect from './StylingSectionWithSelect';
|
LocationSelector,
|
||||||
import StylingSectionWithCheckboxes from './StylingSectionWithCheckboxes';
|
PaymentMethods,
|
||||||
import StylingSectionWithRadiobuttons from './StylingSectionWithRadiobuttons';
|
ButtonLayout,
|
||||||
|
ButtonShape,
|
||||||
|
ButtonLabel,
|
||||||
|
ButtonColor,
|
||||||
|
TagLine,
|
||||||
|
} from './Content';
|
||||||
|
|
||||||
const SettingsPanel = () => {
|
const SettingsPanel = () => {
|
||||||
const { location, setLocation } = StylingHooks.useStylingLocation();
|
const { location, setLocation } = StylingHooks.useStylingLocation();
|
||||||
|
@ -15,114 +18,14 @@ const SettingsPanel = () => {
|
||||||
location={ location }
|
location={ location }
|
||||||
setLocation={ setLocation }
|
setLocation={ setLocation }
|
||||||
/>
|
/>
|
||||||
<SectionPaymentMethods location={ location } />
|
<PaymentMethods location={ location } />
|
||||||
<SectionButtonLayout location={ location } />
|
<ButtonLayout location={ location } />
|
||||||
<SectionButtonShape location={ location } />
|
<ButtonShape location={ location } />
|
||||||
<SectionButtonLabel location={ location } />
|
<ButtonLabel location={ location } />
|
||||||
<SectionButtonColor location={ location } />
|
<ButtonColor location={ location } />
|
||||||
<SectionButtonTagline location={ location } />
|
<TagLine location={ location } />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SettingsPanel;
|
export default SettingsPanel;
|
||||||
|
|
||||||
// -----
|
|
||||||
|
|
||||||
const SectionPaymentMethods = ( { location } ) => {
|
|
||||||
const { paymentMethods, setPaymentMethods, paymentMethodChoices } =
|
|
||||||
StylingHooks.useStylingProps( location );
|
|
||||||
|
|
||||||
return (
|
|
||||||
<StylingSectionWithCheckboxes
|
|
||||||
title={ __( 'Payment Methods', 'woocommerce-paypal-payments' ) }
|
|
||||||
className="payment-methods"
|
|
||||||
options={ paymentMethodChoices }
|
|
||||||
value={ paymentMethods }
|
|
||||||
onChange={ setPaymentMethods }
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const SectionButtonLayout = ( { location } ) => {
|
|
||||||
const { supportsLayout, layout, setLayout, layoutChoices } =
|
|
||||||
StylingHooks.useStylingProps( location );
|
|
||||||
|
|
||||||
if ( ! supportsLayout ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<StylingSectionWithRadiobuttons
|
|
||||||
className="button-layout"
|
|
||||||
title={ __( 'Button Layout', 'woocommerce-paypal-payments' ) }
|
|
||||||
options={ layoutChoices }
|
|
||||||
selected={ layout }
|
|
||||||
onChange={ setLayout }
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const SectionButtonShape = ( { location } ) => {
|
|
||||||
const { shape, setShape, shapeChoices } =
|
|
||||||
StylingHooks.useStylingProps( location );
|
|
||||||
|
|
||||||
return (
|
|
||||||
<StylingSectionWithRadiobuttons
|
|
||||||
title={ __( 'Shape', 'woocommerce-paypal-payments' ) }
|
|
||||||
className="button-shape"
|
|
||||||
options={ shapeChoices }
|
|
||||||
selected={ shape }
|
|
||||||
onChange={ setShape }
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const SectionButtonLabel = ( { location } ) => {
|
|
||||||
const { label, setLabel, labelChoices } =
|
|
||||||
StylingHooks.useStylingProps( location );
|
|
||||||
|
|
||||||
return (
|
|
||||||
<StylingSectionWithSelect
|
|
||||||
title={ __( 'Button Label', 'woocommerce-paypal-payments' ) }
|
|
||||||
className="button-label"
|
|
||||||
options={ labelChoices }
|
|
||||||
value={ label }
|
|
||||||
onChange={ setLabel }
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const SectionButtonColor = ( { location } ) => {
|
|
||||||
const { color, setColor, colorChoices } =
|
|
||||||
StylingHooks.useStylingProps( location );
|
|
||||||
|
|
||||||
return (
|
|
||||||
<StylingSectionWithSelect
|
|
||||||
title={ __( 'Button Color', 'woocommerce-paypal-payments' ) }
|
|
||||||
className="button-color"
|
|
||||||
options={ colorChoices }
|
|
||||||
value={ color }
|
|
||||||
onChange={ setColor }
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const SectionButtonTagline = ( { location } ) => {
|
|
||||||
const { supportsTagline, tagline, setTagline, taglineChoices } =
|
|
||||||
StylingHooks.useStylingProps( location );
|
|
||||||
|
|
||||||
if ( ! supportsTagline ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<StylingSectionWithCheckboxes
|
|
||||||
title={ __( 'Tagline', 'woocommerce-paypal-payments' ) }
|
|
||||||
className="tagline"
|
|
||||||
options={ taglineChoices }
|
|
||||||
value={ tagline }
|
|
||||||
onChange={ setTagline }
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue