mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
✨ Add conditional logic to layout & tagline
This commit is contained in:
parent
00c00bf9b1
commit
a7be75b55e
1 changed files with 10 additions and 6 deletions
|
@ -139,10 +139,11 @@ export const useLabelProps = ( location ) => {
|
||||||
export const useLayoutProps = ( location ) => {
|
export const useLayoutProps = ( location ) => {
|
||||||
const { getLocationProp, setLocationProp } = useHooks();
|
const { getLocationProp, setLocationProp } = useHooks();
|
||||||
const { details } = useLocationProps( location );
|
const { details } = useLocationProps( location );
|
||||||
|
const isAvailable = false !== details.props.layout;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
choices: Object.values( STYLING_LAYOUTS ),
|
choices: Object.values( STYLING_LAYOUTS ),
|
||||||
isAvailable: false !== details.props.layout,
|
isAvailable,
|
||||||
layout: getLocationProp( location, 'layout' ),
|
layout: getLocationProp( location, 'layout' ),
|
||||||
setLayout: ( layout ) => setLocationProp( location, 'layout', layout ),
|
setLayout: ( layout ) => setLocationProp( location, 'layout', layout ),
|
||||||
};
|
};
|
||||||
|
@ -152,6 +153,12 @@ export const useTaglineProps = ( location ) => {
|
||||||
const { getLocationProp, setLocationProp } = useHooks();
|
const { getLocationProp, setLocationProp } = useHooks();
|
||||||
const { details } = useLocationProps( location );
|
const { details } = useLocationProps( location );
|
||||||
|
|
||||||
|
// Tagline is only available for horizontal layouts.
|
||||||
|
const isAvailable =
|
||||||
|
false !== details.props.tagline &&
|
||||||
|
STYLING_LAYOUTS.horizontal.value ===
|
||||||
|
getLocationProp( location, 'layout' );
|
||||||
|
|
||||||
return {
|
return {
|
||||||
choices: [
|
choices: [
|
||||||
{
|
{
|
||||||
|
@ -162,11 +169,8 @@ export const useTaglineProps = ( location ) => {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
isAvailable:
|
isAvailable,
|
||||||
false !== details.props.tagline &&
|
tagline: isAvailable ? getLocationProp( location, 'tagline' ) : false,
|
||||||
STYLING_LAYOUTS.horizontal.value ===
|
|
||||||
getLocationProp( location, 'layout' ),
|
|
||||||
tagline: getLocationProp( location, 'tagline' ),
|
|
||||||
setTagline: ( tagline ) =>
|
setTagline: ( tagline ) =>
|
||||||
setLocationProp( location, 'tagline', tagline ),
|
setLocationProp( location, 'tagline', tagline ),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue