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