From a7be75b55e41691dbd545005fbd53f52f7d18939 Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Fri, 17 Jan 2025 15:35:21 +0100
Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20conditional=20logic=20to=20la?=
=?UTF-8?q?yout=20&=20tagline?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../resources/js/data/styling/hooks.js | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/modules/ppcp-settings/resources/js/data/styling/hooks.js b/modules/ppcp-settings/resources/js/data/styling/hooks.js
index 2767698d5..439b0ec2a 100644
--- a/modules/ppcp-settings/resources/js/data/styling/hooks.js
+++ b/modules/ppcp-settings/resources/js/data/styling/hooks.js
@@ -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 ),
};