Add conditional logic to layout & tagline

This commit is contained in:
Philipp Stracker 2025-01-17 15:35:21 +01:00
parent 00c00bf9b1
commit a7be75b55e
No known key found for this signature in database

View file

@ -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 ),
};