From b44cbd5e859909b01a695a1360f69fc0470daa82 Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Thu, 30 May 2024 17:42:12 +0300 Subject: [PATCH] Hide presets when there are less or exactly one presets available (#62074) * hide the presets panel for when there are less or exactly one presets available * tweak logic to return null if there is only one variation (the default). --------- Co-authored-by: draganescu Co-authored-by: richtabor Co-authored-by: MaggieCabrera Co-authored-by: bgardner Co-authored-by: hbhalodia --- .../components/global-styles/variations/variations-color.js | 3 ++- .../global-styles/variations/variations-typography.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/variations/variations-color.js b/packages/edit-site/src/components/global-styles/variations/variations-color.js index 28469fccab0ad5..2b3758e92a5123 100644 --- a/packages/edit-site/src/components/global-styles/variations/variations-color.js +++ b/packages/edit-site/src/components/global-styles/variations/variations-color.js @@ -14,7 +14,8 @@ import Variation from './variation'; export default function ColorVariations( { title, gap = 2 } ) { const colorVariations = useColorVariations(); - if ( ! colorVariations?.length ) { + // Return null if there is only one variation (the default). + if ( colorVariations?.length <= 1 ) { return null; } diff --git a/packages/edit-site/src/components/global-styles/variations/variations-typography.js b/packages/edit-site/src/components/global-styles/variations/variations-typography.js index 6ee7be561e6114..208ed822b5a6f6 100644 --- a/packages/edit-site/src/components/global-styles/variations/variations-typography.js +++ b/packages/edit-site/src/components/global-styles/variations/variations-typography.js @@ -19,7 +19,8 @@ import Subtitle from '../subtitle'; export default function TypographyVariations( { title, gap = 2 } ) { const typographyVariations = useTypographyVariations(); - if ( ! typographyVariations?.length ) { + // Return null if there is only one variation (the default). + if ( typographyVariations?.length <= 1 ) { return null; }