From 6c6dc704c04c93e072cef5888c6a96ab0ce4d6dc Mon Sep 17 00:00:00 2001 From: Juzar Bharmal <53657281+Juzar10@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:45:28 +0530 Subject: [PATCH] feat: refactored the setting panel of the featured-image post --- .../src/post-featured-image/edit.js | 103 ++++++++++++------ 1 file changed, 71 insertions(+), 32 deletions(-) diff --git a/packages/block-library/src/post-featured-image/edit.js b/packages/block-library/src/post-featured-image/edit.js index 95441a5a55cfd0..eeae078baf0512 100644 --- a/packages/block-library/src/post-featured-image/edit.js +++ b/packages/block-library/src/post-featured-image/edit.js @@ -11,11 +11,12 @@ import { useEntityProp, store as coreStore } from '@wordpress/core-data'; import { useSelect, useDispatch } from '@wordpress/data'; import { ToggleControl, - PanelBody, Placeholder, Button, Spinner, TextControl, + __experimentalToolsPanel as ToolsPanel, + __experimentalToolsPanelItem as ToolsPanelItem, } from '@wordpress/components'; import { InspectorControls, @@ -201,45 +202,83 @@ export default function PostFeaturedImageEdit( { /> - - setAttributes( { isLink: ! isLink } ) } - checked={ isLink } - /> + { + setAttributes( { + isLink: true, + linkTarget: '_self', + rel: '', + } ); + } } + > + ! isLink } + onDeselect={ () => setAttributes( { isLink: true } ) } + > + + setAttributes( { isLink: ! isLink } ) + } + checked={ isLink } + /> + { isLink && ( <> - - setAttributes( { - linkTarget: value ? '_blank' : '_self', - } ) + isShownByDefault + hasValue={ () => linkTarget === '_blank' } + onDeselect={ () => + setAttributes( { linkTarget: '_self' } ) } - checked={ linkTarget === '_blank' } - /> - + + setAttributes( { + linkTarget: value + ? '_blank' + : '_self', + } ) + } + checked={ linkTarget === '_blank' } + /> + + - setAttributes( { rel: newRel } ) + isShownByDefault + hasValue={ () => !! rel } + onDeselect={ () => + setAttributes( { rel: '' } ) } - /> + > + + setAttributes( { rel: newRel } ) + } + /> + ) } - + );