From 89c137a378174a28ae7c8222bf92b2c84e74be04 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Thu, 24 Oct 2024 15:54:40 +0200 Subject: [PATCH 01/12] Remove Additional CSS button from ellipsis menu and always show in main panel. --- .../components/global-styles/screen-root.js | 22 ++++++++++------ .../src/components/global-styles/ui.js | 25 ------------------- 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/screen-root.js b/packages/edit-site/src/components/global-styles/screen-root.js index ffa85b046ead71..e07b56806782f6 100644 --- a/packages/edit-site/src/components/global-styles/screen-root.js +++ b/packages/edit-site/src/components/global-styles/screen-root.js @@ -14,9 +14,8 @@ import { } from '@wordpress/components'; import { isRTL, __ } from '@wordpress/i18n'; import { chevronLeft, chevronRight } from '@wordpress/icons'; -import { useSelect } from '@wordpress/data'; +import { useSelect, useDispatch } from '@wordpress/data'; import { store as coreStore } from '@wordpress/core-data'; -import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor'; /** * Internal dependencies @@ -25,13 +24,10 @@ import { IconWithCurrentColor } from './icon-with-current-color'; import { NavigationButtonAsItem } from './navigation-button'; import RootMenu from './root-menu'; import PreviewStyles from './preview-styles'; +import { store as editSiteStore } from '../../store'; import { unlock } from '../../lock-unlock'; -const { useGlobalStyle } = unlock( blockEditorPrivateApis ); - function ScreenRoot() { - const [ customCSS ] = useGlobalStyle( 'css' ); - const { hasVariations, canEditCSS } = useSelect( ( select ) => { const { getEntityRecord, @@ -52,6 +48,13 @@ function ScreenRoot() { }; }, [] ); + const { setEditorCanvasContainerView } = unlock( + useDispatch( editSiteStore ) + ); + const loadAdditionalCSSView = () => { + setEditorCanvasContainerView( 'global-styles-css' ); + }; + return ( - { canEditCSS && !! customCSS && ( + { canEditCSS && ( <> @@ -130,7 +133,10 @@ function ScreenRoot() { ) } - + { __( 'Additional CSS' ) } diff --git a/packages/edit-site/src/components/global-styles/ui.js b/packages/edit-site/src/components/global-styles/ui.js index 22ebad383884e9..8f762ec9ff8665 100644 --- a/packages/edit-site/src/components/global-styles/ui.js +++ b/packages/edit-site/src/components/global-styles/ui.js @@ -18,7 +18,6 @@ import { import { __ } from '@wordpress/i18n'; import { store as preferencesStore } from '@wordpress/preferences'; import { moreVertical } from '@wordpress/icons'; -import { store as coreStore } from '@wordpress/core-data'; import { useEffect } from '@wordpress/element'; import { usePrevious } from '@wordpress/compose'; @@ -56,25 +55,6 @@ const { Slot: GlobalStylesMenuSlot, Fill: GlobalStylesMenuFill } = function GlobalStylesActionMenu() { const [ canReset, onReset ] = useGlobalStylesReset(); const { toggle } = useDispatch( preferencesStore ); - const { canEditCSS } = useSelect( ( select ) => { - const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = - select( coreStore ); - - const globalStylesId = __experimentalGetCurrentGlobalStylesId(); - const globalStyles = globalStylesId - ? getEntityRecord( 'root', 'globalStyles', globalStylesId ) - : undefined; - - return { - canEditCSS: !! globalStyles?._links?.[ 'wp:action-edit-css' ], - }; - }, [] ); - const { setEditorCanvasContainerView } = unlock( - useDispatch( editSiteStore ) - ); - const loadCustomCSS = () => { - setEditorCanvasContainerView( 'global-styles-css' ); - }; return ( @@ -86,11 +66,6 @@ function GlobalStylesActionMenu() { { ( { onClose } ) => ( <> - { canEditCSS && ( - - { __( 'Additional CSS' ) } - - ) } { toggle( From 6719e904c8aa1fa6292468d80f7834475d591b51 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Thu, 24 Oct 2024 16:34:58 +0200 Subject: [PATCH 02/12] Remove descriptions and group navigation buttons. --- .../components/global-styles/screen-root.js | 68 +++++-------------- 1 file changed, 16 insertions(+), 52 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/screen-root.js b/packages/edit-site/src/components/global-styles/screen-root.js index e07b56806782f6..a58c2bca98efc5 100644 --- a/packages/edit-site/src/components/global-styles/screen-root.js +++ b/packages/edit-site/src/components/global-styles/screen-root.js @@ -4,7 +4,6 @@ import { __experimentalItemGroup as ItemGroup, __experimentalHStack as HStack, - __experimentalSpacer as Spacer, __experimentalVStack as VStack, FlexItem, CardBody, @@ -91,22 +90,7 @@ function ScreenRoot() { - - { __( - 'Customize the appearance of specific blocks for the whole site.' - ) } - - + { __( 'Blocks' ) } @@ -115,43 +99,23 @@ function ScreenRoot() { /> + { canEditCSS && ( + + + { __( 'Additional CSS' ) } + + + + ) } - - { canEditCSS && ( - <> - - - - { __( - 'Add your own CSS to customize the appearance and layout of your site.' - ) } - - - - - - { __( 'Additional CSS' ) } - - - - - - - - ) } ); } From bddd1030f4df4c73a250749b3d7fbd6fd4d5f03e Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Fri, 25 Oct 2024 14:26:19 +0200 Subject: [PATCH 03/12] Move Styles revisions button from panel header into panel. --- .../components/global-styles-sidebar/index.js | 47 +------ .../components/global-styles/screen-root.js | 124 +++++++++++++++--- 2 files changed, 108 insertions(+), 63 deletions(-) diff --git a/packages/edit-site/src/components/global-styles-sidebar/index.js b/packages/edit-site/src/components/global-styles-sidebar/index.js index 02a29dac5c0b7d..4e9c47c51f1d3c 100644 --- a/packages/edit-site/src/components/global-styles-sidebar/index.js +++ b/packages/edit-site/src/components/global-styles-sidebar/index.js @@ -3,7 +3,7 @@ */ import { FlexItem, Flex, Button } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; -import { styles, seen, backup } from '@wordpress/icons'; +import { styles, seen } from '@wordpress/icons'; import { useSelect, useDispatch } from '@wordpress/data'; import { useEffect, useRef } from '@wordpress/element'; import { store as preferencesStore } from '@wordpress/preferences'; @@ -21,7 +21,6 @@ import { GlobalStylesUI } from '../global-styles'; import { store as editSiteStore } from '../../store'; import { GlobalStylesMenuSlot } from '../global-styles/ui'; import { unlock } from '../../lock-unlock'; -import { store as coreStore } from '@wordpress/core-data'; import DefaultSidebar from './default-sidebar'; const { interfaceStore } = unlock( editorPrivateApis ); @@ -34,7 +33,6 @@ export default function GlobalStylesSidebar() { shouldClearCanvasContainerView, isStyleBookOpened, showListViewByDefault, - hasRevisions, isRevisionsOpened, isRevisionsStyleBookOpened, } = useSelect( @@ -51,13 +49,6 @@ export default function GlobalStylesSidebar() { 'core', 'showListViewByDefault' ); - const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = - select( coreStore ); - - const globalStylesId = __experimentalGetCurrentGlobalStylesId(); - const globalStyles = globalStylesId - ? getEntityRecord( 'root', 'globalStyles', globalStylesId ) - : undefined; return { isStyleBookOpened: 'style-book' === canvasContainerView, @@ -67,9 +58,6 @@ export default function GlobalStylesSidebar() { ! _isVisualEditorMode || ! _isEditCanvasMode, showListViewByDefault: _showListViewByDefault, - hasRevisions: - !! globalStyles?._links?.[ 'version-history' ]?.[ 0 ] - ?.count, isRevisionsStyleBookOpened: 'global-styles-revisions:style-book' === canvasContainerView, @@ -92,25 +80,6 @@ export default function GlobalStylesSidebar() { const { setIsListViewOpened } = useDispatch( editorStore ); - const toggleRevisions = () => { - setIsListViewOpened( false ); - if ( isRevisionsStyleBookOpened ) { - setEditorCanvasContainerView( 'style-book' ); - return; - } - if ( isRevisionsOpened ) { - setEditorCanvasContainerView( undefined ); - return; - } - - if ( isStyleBookOpened ) { - setEditorCanvasContainerView( - 'global-styles-revisions:style-book' - ); - } else { - setEditorCanvasContainerView( 'global-styles-revisions' ); - } - }; const toggleStyleBook = () => { if ( isRevisionsOpened ) { setEditorCanvasContainerView( @@ -181,20 +150,6 @@ export default function GlobalStylesSidebar() { /> ) } - -