From 294b98e600c20d78d8a80f5fb59b7b5ee0a56167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor?= <27339341+priethor@users.noreply.github.com> Date: Mon, 15 Jul 2024 13:22:03 +0200 Subject: [PATCH] Query Loop block: Convert the post content type setting to a ToggleGroupControl if there are few items (#63375) Co-authored-by: priethor Co-authored-by: youknowriad Co-authored-by: richtabor Co-authored-by: jasmussen --- .../edit/inspector-controls/author-control.js | 1 + .../query/edit/inspector-controls/index.js | 51 ++++++++++++++----- .../edit/inspector-controls/order-control.js | 1 + .../edit/inspector-controls/sticky-control.js | 1 + .../inspector-controls/taxonomy-controls.js | 1 + 5 files changed, 43 insertions(+), 12 deletions(-) diff --git a/packages/block-library/src/query/edit/inspector-controls/author-control.js b/packages/block-library/src/query/edit/inspector-controls/author-control.js index 5b154346f0a76..1d33ae96f13e8 100644 --- a/packages/block-library/src/query/edit/inspector-controls/author-control.js +++ b/packages/block-library/src/query/edit/inspector-controls/author-control.js @@ -76,6 +76,7 @@ function AuthorControl( { value, onChange } ) { suggestions={ authorsInfo.names } onChange={ onAuthorChange } __experimentalShowHowTo={ false } + __next40pxDefaultSize /> ); } diff --git a/packages/block-library/src/query/edit/inspector-controls/index.js b/packages/block-library/src/query/edit/inspector-controls/index.js index e71b2d09af4b8..4c3500f4bd23f 100644 --- a/packages/block-library/src/query/edit/inspector-controls/index.js +++ b/packages/block-library/src/query/edit/inspector-controls/index.js @@ -7,6 +7,8 @@ import { SelectControl, RangeControl, ToggleControl, + __experimentalToggleGroupControl as ToggleGroupControl, + __experimentalToggleGroupControlOption as ToggleGroupControlOption, Notice, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem, @@ -101,6 +103,10 @@ export default function QueryInspectorControls( props ) { const showInheritControl = isControlAllowed( allowedControls, 'inherit' ); const showPostTypeControl = ! inherit && isControlAllowed( allowedControls, 'postType' ); + const postTypeControlLabel = __( 'Content type' ); + const postTypeControlHelp = __( + 'WordPress contains different types of content you can filter by. Posts and pages are the default types, but plugins could add more.' + ); const showColumnsControl = false; const showOrderControl = ! inherit && isControlAllowed( allowedControls, 'order' ); @@ -152,22 +158,42 @@ export default function QueryInspectorControls( props ) { } /> ) } - { showPostTypeControl && ( - - ) } + { showPostTypeControl && + ( postTypesSelectOptions.length > 2 ? ( + + ) : ( + + { postTypesSelectOptions.map( ( option ) => ( + + ) ) } + + ) ) } + { showColumnsControl && ( <> @@ -262,6 +288,7 @@ export default function QueryInspectorControls( props ) { > );