mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 10:55:00 +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 ) => {
|
||||
const { getLocationProp, setLocationProp } = useHooks();
|
||||
const { details } = useLocationProps( location );
|
||||
const isAvailable = false !== details.props.layout;
|
||||
|
||||
return {
|
||||
choices: Object.values( STYLING_LAYOUTS ),
|
||||
isAvailable: false !== details.props.layout,
|
||||
isAvailable,
|
||||
layout: getLocationProp( location, 'layout' ),
|
||||
setLayout: ( layout ) => setLocationProp( location, 'layout', layout ),
|
||||
};
|
||||
|
@ -152,6 +153,12 @@ export const useTaglineProps = ( location ) => {
|
|||
const { getLocationProp, setLocationProp } = useHooks();
|
||||
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 {
|
||||
choices: [
|
||||
{
|
||||
|
@ -162,11 +169,8 @@ export const useTaglineProps = ( location ) => {
|
|||
),
|
||||
},
|
||||
],
|
||||
isAvailable:
|
||||
false !== details.props.tagline &&
|
||||
STYLING_LAYOUTS.horizontal.value ===
|
||||
getLocationProp( location, 'layout' ),
|
||||
tagline: getLocationProp( location, 'tagline' ),
|
||||
isAvailable,
|
||||
tagline: isAvailable ? getLocationProp( location, 'tagline' ) : false,
|
||||
setTagline: ( tagline ) =>
|
||||
setLocationProp( location, 'tagline', tagline ),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue