diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-global-styles/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-global-styles/index.js index 7e6bb2359d222e..b2009a6e41d2b5 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-global-styles/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-global-styles/index.js @@ -16,6 +16,7 @@ import { unlock } from '../../private-apis'; import { store as editSiteStore } from '../../store'; import SidebarButton from '../sidebar-button'; import SidebarNavigationItem from '../sidebar-navigation-item'; +import StyleBook from '../style-book'; export function SidebarNavigationItemGlobalStyles( props ) { const { openGeneralSidebar } = useDispatch( editSiteStore ); @@ -49,12 +50,32 @@ export function SidebarNavigationItemGlobalStyles( props ) { ); } +function GlobalStylesStyleBook( { onSelect } ) { + return ( + false } + onSelect={ async ( blockName ) => { + await onSelect( blockName ); + } } + /> + ); +} + export default function SidebarNavigationScreenGlobalStyles() { const { openGeneralSidebar } = useDispatch( editSiteStore ); const { setCanvasMode, setEditorCanvasContainerView } = unlock( useDispatch( editSiteStore ) ); + const { isStyleBookOpened } = useSelect( ( select ) => { + const { getEditorCanvasContainerView } = unlock( + select( editSiteStore ) + ); + return { + isStyleBookOpened: 'style-book' === getEditorCanvasContainerView(), + }; + }, [] ); + const openGlobalStyles = async () => Promise.all( [ setCanvasMode( 'edit' ), @@ -62,32 +83,48 @@ export default function SidebarNavigationScreenGlobalStyles() { ] ); return ( - + } + actions={ +
+ { + if ( ! isStyleBookOpened ) { + setEditorCanvasContainerView( + 'style-book' + ); + } else { + setEditorCanvasContainerView( undefined ); + } + } } + isPressed={ isStyleBookOpened } + /> + await openGlobalStyles() } + /> +
+ } + /> + { isStyleBookOpened && ( + { + await openGlobalStyles(); + // Open the Style Book once the canvas mode is set to edit, + // and the global styles sidebar is open. This ensures that + // the Style Book is not prematurely closed. + setEditorCanvasContainerView( 'style-book' ); + } } + /> ) } - content={ } - actions={ -
- { - await openGlobalStyles(); - // Open the Style Book once the canvas mode is set to edit, - // and the global styles sidebar is open. This ensures that - // the Style Book is not prematurely closed. - setEditorCanvasContainerView( 'style-book' ); - } } - /> - await openGlobalStyles() } - /> -
- } - /> + ); }