From c424499a8d88955e3c08d132c5bb9894f43016b6 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Tue, 28 Feb 2023 09:42:04 +0100 Subject: [PATCH 1/2] Site Editor: update the edit button --- .../sidebar-navigation-screen-navigation-item/index.js | 8 ++++---- .../sidebar-navigation-screen-template/index.js | 8 ++++---- .../src/components/sidebar-navigation-screen/style.scss | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-item/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-item/index.js index a65e540a8ad756..c340f5c7c86162 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-item/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-item/index.js @@ -9,6 +9,7 @@ import { } from '@wordpress/components'; import { store as coreStore } from '@wordpress/core-data'; import { decodeEntities } from '@wordpress/html-entities'; +import { pencil } from '@wordpress/icons'; /** * Internal dependencies @@ -44,12 +45,11 @@ export default function SidebarNavigationScreenNavigationItem() { title={ post ? decodeEntities( post?.title?.rendered ) : null } actions={ + label={ __( 'Edit' ) } + icon={ pencil } + /> } content={ post ? decodeEntities( post?.description?.rendered ) : null diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js index 2282c03a781511..40aebeedc67ade 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js @@ -4,6 +4,7 @@ import { __ } from '@wordpress/i18n'; import { useDispatch } from '@wordpress/data'; import { Button } from '@wordpress/components'; +import { pencil } from '@wordpress/icons'; /** * Internal dependencies @@ -28,12 +29,11 @@ export default function SidebarNavigationScreenTemplate() { title={ getTitle() } actions={ + label={ __( 'Edit' ) } + icon={ pencil } + /> } content={ description ?

{ description }

: undefined } /> diff --git a/packages/edit-site/src/components/sidebar-navigation-screen/style.scss b/packages/edit-site/src/components/sidebar-navigation-screen/style.scss index 3fbc7491ea0271..6aa03f3492fea0 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen/style.scss +++ b/packages/edit-site/src/components/sidebar-navigation-screen/style.scss @@ -32,6 +32,7 @@ .edit-site-sidebar-navigation-screen__edit { flex-shrink: 0; + color: inherit; } .edit-site-sidebar-navigation-screen__back { From c28933d078e7f862dbc17ce58ea7da3bafcb3d9c Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Tue, 28 Feb 2023 12:47:02 +0100 Subject: [PATCH 2/2] Unify all sidebar buttons --- .../components/src/dropdown-menu/index.js | 9 ++++--- .../add-new-template/new-template-part.js | 7 ++--- .../src/components/sidebar-button/index.js | 21 +++++++++++++++ .../src/components/sidebar-button/style.scss | 23 ++++++++++++++++ .../index.js | 9 +++---- .../index.js | 5 ++-- .../index.js | 4 +-- .../style.scss | 5 ---- .../sidebar-navigation-screen/index.js | 7 +++-- .../sidebar-navigation-screen/style.scss | 26 ------------------- packages/edit-site/src/style.scss | 1 + 11 files changed, 65 insertions(+), 52 deletions(-) create mode 100644 packages/edit-site/src/components/sidebar-button/index.js create mode 100644 packages/edit-site/src/components/sidebar-button/style.scss diff --git a/packages/components/src/dropdown-menu/index.js b/packages/components/src/dropdown-menu/index.js index 481d84a6589f48..481e87cd102b7d 100644 --- a/packages/components/src/dropdown-menu/index.js +++ b/packages/components/src/dropdown-menu/index.js @@ -91,6 +91,9 @@ function DropdownMenu( dropdownMenuProps ) { onToggle(); } }; + const { as: Toggle = Button, ...restToggleProps } = + toggleProps ?? {}; + const mergedToggleProps = mergeProps( { className: classnames( @@ -100,11 +103,11 @@ function DropdownMenu( dropdownMenuProps ) { } ), }, - toggleProps + restToggleProps ); return ( - + ); } } renderContent={ ( props ) => { diff --git a/packages/edit-site/src/components/add-new-template/new-template-part.js b/packages/edit-site/src/components/add-new-template/new-template-part.js index 8c3aa84b11974f..82e90f248b4f97 100644 --- a/packages/edit-site/src/components/add-new-template/new-template-part.js +++ b/packages/edit-site/src/components/add-new-template/new-template-part.js @@ -86,11 +86,12 @@ export default function NewTemplatePart( { setIsModalOpen( false ); } } + const { as: Toggle = Button, ...restToggleProps } = toggleProps ?? {}; return ( <> - + { isModalOpen && ( setIsModalOpen( false ) } diff --git a/packages/edit-site/src/components/sidebar-button/index.js b/packages/edit-site/src/components/sidebar-button/index.js new file mode 100644 index 00000000000000..9da8492c37c799 --- /dev/null +++ b/packages/edit-site/src/components/sidebar-button/index.js @@ -0,0 +1,21 @@ +/** + * External dependencies + */ +import classnames from 'classnames'; + +/** + * WordPress dependencies + */ +import { Button } from '@wordpress/components'; + +export default function SidebarButton( props ) { + return ( +