From 747b30d8e038d9114aeb8b3fb85285cd408d1634 Mon Sep 17 00:00:00 2001 From: Rinkal Pagdar <92097119+rinkalpagdar@users.noreply.github.com> Date: Fri, 13 Dec 2024 17:13:53 +0530 Subject: [PATCH 1/5] Refactor Settings panel of Next Post block to use ToolsPanel instead of PanelBody --- .../src/post-navigation-link/edit.js | 115 ++++++++++-------- 1 file changed, 65 insertions(+), 50 deletions(-) diff --git a/packages/block-library/src/post-navigation-link/edit.js b/packages/block-library/src/post-navigation-link/edit.js index e27d094feb79ab..e6284a30a2d33e 100644 --- a/packages/block-library/src/post-navigation-link/edit.js +++ b/packages/block-library/src/post-navigation-link/edit.js @@ -11,7 +11,8 @@ import { __experimentalToggleGroupControlOption as ToggleGroupControlOption, ToggleControl, SelectControl, - PanelBody, + __experimentalToolsPanel as ToolsPanel, + __experimentalToolsPanelItem as ToolsPanelItem, } from '@wordpress/components'; import { InspectorControls, @@ -94,20 +95,26 @@ export default function PostNavigationLinkEdit( { return ( <> - - - setAttributes( { - showTitle: ! showTitle, - } ) - } - /> + + !!showTitle} + label={__('Display the title as a link')} + onDeselect={() => setAttributes({ showTitle: false })} + > + + setAttributes({ + showTitle: !showTitle, + }) + } + /> + { showTitle && ( ) } - { - setAttributes( { arrow: value } ); - } } - help={ __( - 'A decorative arrow for the next and previous link.' - ) } - isBlock + !!arrow} + label={__('Arrow')} + onDeselect={() => setAttributes({ arrow: 'none' })} > - - - - - + { + setAttributes({ arrow: value }); + }} + help={__( + 'A decorative arrow for the next and previous link.' + )} + isBlock + > + + + + + + + + Date: Mon, 16 Dec 2024 11:01:49 +0530 Subject: [PATCH 2/5] property added --- packages/block-library/src/post-navigation-link/edit.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/block-library/src/post-navigation-link/edit.js b/packages/block-library/src/post-navigation-link/edit.js index e6284a30a2d33e..e8724b6a57615f 100644 --- a/packages/block-library/src/post-navigation-link/edit.js +++ b/packages/block-library/src/post-navigation-link/edit.js @@ -127,6 +127,7 @@ export default function PostNavigationLinkEdit( { linkLabel: ! linkLabel, } ) } + isShownByDefault /> ) } Date: Tue, 17 Dec 2024 13:08:50 +0530 Subject: [PATCH 3/5] lint fix --- .../src/post-navigation-link/edit.js | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/packages/block-library/src/post-navigation-link/edit.js b/packages/block-library/src/post-navigation-link/edit.js index e8724b6a57615f..4d144397299889 100644 --- a/packages/block-library/src/post-navigation-link/edit.js +++ b/packages/block-library/src/post-navigation-link/edit.js @@ -95,23 +95,25 @@ export default function PostNavigationLinkEdit( { return ( <> - + !!showTitle} - label={__('Display the title as a link')} - onDeselect={() => setAttributes({ showTitle: false })} + hasValue={ () => !! showTitle } + label={ __( 'Display the title as a link' ) } + onDeselect={ () => + setAttributes( { showTitle: false } ) + } > - setAttributes({ - showTitle: !showTitle, - }) + ) } + checked={ !! showTitle } + onChange={ () => + setAttributes( { + showTitle: ! showTitle, + } ) } /> @@ -131,49 +133,47 @@ export default function PostNavigationLinkEdit( { /> ) } !!arrow} - label={__('Arrow')} - onDeselect={() => setAttributes({ arrow: 'none' })} + hasValue={ () => !! arrow } + label={ __( 'Arrow' ) } + onDeselect={ () => setAttributes( { arrow: 'none' } ) } > { - setAttributes({ arrow: value }); - }} - help={__( + label={ __( 'Arrow' ) } + value={ arrow } + onChange={ ( value ) => { + setAttributes( { arrow: value } ); + } } + help={ __( 'A decorative arrow for the next and previous link.' - )} + ) } isBlock > - - Date: Mon, 13 Jan 2025 17:50:16 +0530 Subject: [PATCH 4/5] Feedback changes --- .../block-library/src/post-navigation-link/edit.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/post-navigation-link/edit.js b/packages/block-library/src/post-navigation-link/edit.js index 4d144397299889..6e8a73396db595 100644 --- a/packages/block-library/src/post-navigation-link/edit.js +++ b/packages/block-library/src/post-navigation-link/edit.js @@ -25,6 +25,11 @@ import { __, _x } from '@wordpress/i18n'; import { useSelect } from '@wordpress/data'; import { store as coreStore } from '@wordpress/core-data'; +/** + * Internal dependencies + */ +import { useToolsPanelDropdownMenuProps } from '../utils/hooks'; + export default function PostNavigationLinkEdit( { context: { postType }, attributes: { @@ -48,6 +53,7 @@ export default function PostNavigationLinkEdit( { }; const displayArrow = arrowMap[ arrow ]; + const dropdownMenuProps = useToolsPanelDropdownMenuProps(); if ( showTitle ) { placeholder = isNext @@ -95,13 +101,17 @@ export default function PostNavigationLinkEdit( { return ( <> - + !! showTitle } label={ __( 'Display the title as a link' ) } onDeselect={ () => setAttributes( { showTitle: false } ) } + isShownByDefault > !! arrow } label={ __( 'Arrow' ) } onDeselect={ () => setAttributes( { arrow: 'none' } ) } + isShownByDefault > Date: Wed, 15 Jan 2025 09:48:15 +0530 Subject: [PATCH 5/5] ToolsPanelItem updated --- .../src/post-navigation-link/edit.js | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/packages/block-library/src/post-navigation-link/edit.js b/packages/block-library/src/post-navigation-link/edit.js index 6e8a73396db595..f0da48e48cf1a9 100644 --- a/packages/block-library/src/post-navigation-link/edit.js +++ b/packages/block-library/src/post-navigation-link/edit.js @@ -128,19 +128,27 @@ export default function PostNavigationLinkEdit( { /> { showTitle && ( - - setAttributes( { - linkLabel: ! linkLabel, - } ) - } - isShownByDefault - /> + !! linkLabel } + label={ __( 'Include the label as part of the link' ) } + onDeselect={ () => setAttributes( { linkLabel: false } ) } + > + + + setAttributes( { + linkLabel: ! linkLabel, + } ) + } + isShownByDefault + /> + + ) } !! arrow }