From 6b9bd081c7c0c17d220ab0be924c983eaa5197ce Mon Sep 17 00:00:00 2001 From: apeatling Date: Wed, 22 Nov 2023 13:57:00 -0800 Subject: [PATCH 1/8] Remove dropdown menu --- .../src/components/global-styles/ui.js | 141 +++++++++--------- 1 file changed, 69 insertions(+), 72 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/ui.js b/packages/edit-site/src/components/global-styles/ui.js index 2e33d4b599b7b..d345574916f3e 100644 --- a/packages/edit-site/src/components/global-styles/ui.js +++ b/packages/edit-site/src/components/global-styles/ui.js @@ -1,7 +1,7 @@ -/** - * External dependencies - */ -import classnames from 'classnames'; +// /** +// * External dependencies +// */ +// import classnames from 'classnames'; /** * WordPress dependencies @@ -55,6 +55,7 @@ const { Slot: GlobalStylesMenuSlot, Fill: GlobalStylesMenuFill } = createSlotFill( SLOT_FILL_NAME ); function GlobalStylesActionMenu() { + const [ canReset, onReset ] = useGlobalStylesReset(); const { toggle } = useDispatch( preferencesStore ); const { canEditCSS } = useSelect( ( select ) => { const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = @@ -76,42 +77,56 @@ function GlobalStylesActionMenu() { { ( { onClose } ) => ( - - { canEditCSS && ( - - { __( 'Additional CSS' ) } + <> + + { canEditCSS && ( + + { __( 'Additional CSS' ) } + + ) } + { + toggle( + 'core/edit-site', + 'welcomeGuideStyles' + ); + onClose(); + } } + > + { __( 'Welcome Guide' ) } + + + + { + onReset(); + onClose(); + } } + disabled={ ! canReset } + > + { __( 'Reset styles' ) } - ) } - { - toggle( - 'core/edit-site', - 'welcomeGuideStyles' - ); - onClose(); - } } - > - { __( 'Welcome Guide' ) } - - + + ) } ); } -function RevisionsCountBadge( { className, children } ) { - return ( - - { children } - - ); -} +// function RevisionsCountBadge( { className, children } ) { +// return ( +// +// { children } +// +// ); +// } + function GlobalStylesRevisionsMenu() { const { setIsListViewOpened } = useDispatch( editSiteStore ); const { revisionsCount } = useSelect( ( select ) => { @@ -128,56 +143,38 @@ function GlobalStylesRevisionsMenu() { globalStyles?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0, }; }, [] ); - const [ canReset, onReset ] = useGlobalStylesReset(); const { goTo } = useNavigator(); const { setEditorCanvasContainerView } = unlock( useDispatch( editSiteStore ) ); const loadRevisions = () => { setIsListViewOpened( false ); - goTo( '/revisions' ); - setEditorCanvasContainerView( 'global-styles-revisions' ); + + if ( ! isRevisionsOpened ) { + goTo( '/revisions' ); + setEditorCanvasContainerView( 'global-styles-revisions' ); + } else { + goTo( '/' ); + setEditorCanvasContainerView( '' ); + } }; const hasRevisions = revisionsCount > 0; + const isRevisionsOpened = useSelect( + ( select ) => + 'global-styles-revisions' === + unlock( select( editSiteStore ) ).getEditorCanvasContainerView(), + [] + ); return ( - { canReset || hasRevisions ? ( - - { ( { onClose } ) => ( - - { hasRevisions && ( - - { revisionsCount } - - } - > - { __( 'Revision history' ) } - - ) } - { - onReset(); - onClose(); - } } - disabled={ ! canReset } - > - { __( 'Reset to defaults' ) } - - - ) } - - ) : ( -