From 1db44f85a6bb6e7946d3d8e391df8bad06bcbc49 Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Tue, 28 May 2024 17:43:09 +0300 Subject: [PATCH 1/2] hide the presets panel for when there are less or exactly one presets available --- .../src/components/global-styles/variations/variations-color.js | 2 +- .../global-styles/variations/variations-typography.js | 2 +- 2 files changed, 2 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..c720a7c21736f2 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,7 @@ import Variation from './variation'; export default function ColorVariations( { title, gap = 2 } ) { const colorVariations = useColorVariations(); - if ( ! colorVariations?.length ) { + 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..9c5a7878412062 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,7 @@ import Subtitle from '../subtitle'; export default function TypographyVariations( { title, gap = 2 } ) { const typographyVariations = useTypographyVariations(); - if ( ! typographyVariations?.length ) { + if ( ! typographyVariations?.length <= 1 ) { return null; } From 811eaddb4f5106336852dda6de709bdd1b8e0206 Mon Sep 17 00:00:00 2001 From: Rich Tabor Date: Wed, 29 May 2024 09:37:14 -0400 Subject: [PATCH 2/2] tweak logic to return null if there is only one variation (the default). --- .../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 c720a7c21736f2..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 <= 1 ) { + // 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 9c5a7878412062..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 <= 1 ) { + // Return null if there is only one variation (the default). + if ( typographyVariations?.length <= 1 ) { return null; }