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 c885ca97ba7893..ce689c095d7eb5 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 @@ -108,30 +108,10 @@ function SidebarNavigationScreenGlobalStylesContent() { ); } -function SidebarNavigationScreenGlobalStylesFooter( { onClickRevisions } ) { - const { revisions, isLoading } = useGlobalStylesRevisions(); - const { revisionsCount } = useSelect( ( select ) => { - const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = - select( coreStore ); - - const globalStylesId = __experimentalGetCurrentGlobalStylesId(); - const globalStyles = globalStylesId - ? getEntityRecord( 'root', 'globalStyles', globalStylesId ) - : undefined; - - return { - revisionsCount: - globalStyles?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0, - }; - }, [] ); - - const hasRevisions = revisionsCount >= 2; - const modified = revisions?.[ 0 ]?.modified; - - if ( ! hasRevisions || isLoading || ! modified ) { - return null; - } - +function SidebarNavigationScreenGlobalStylesFooter( { + modifiedDateTime, + onClickRevisions, +} ) { return ( - @@ -162,6 +142,8 @@ function SidebarNavigationScreenGlobalStylesFooter( { onClickRevisions } ) { } export default function SidebarNavigationScreenGlobalStyles() { + const { revisions, isLoading: isLoadingRevisions } = + useGlobalStylesRevisions(); const { openGeneralSidebar, setIsListViewOpened } = useDispatch( editSiteStore ); const isMobileViewport = useViewportMatch( 'medium', '<' ); @@ -171,15 +153,28 @@ export default function SidebarNavigationScreenGlobalStyles() { const { createNotice } = useDispatch( noticesStore ); const { set: setPreference } = useDispatch( preferencesStore ); const { get: getPreference } = useSelect( preferencesStore ); - const { isViewMode, isStyleBookOpened } = useSelect( ( select ) => { - const { getCanvasMode, getEditorCanvasContainerView } = unlock( - select( editSiteStore ) - ); - return { - isViewMode: 'view' === getCanvasMode(), - isStyleBookOpened: 'style-book' === getEditorCanvasContainerView(), - }; - }, [] ); + const { isViewMode, isStyleBookOpened, revisionsCount } = useSelect( + ( select ) => { + const { getCanvasMode, getEditorCanvasContainerView } = unlock( + select( editSiteStore ) + ); + const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = + select( coreStore ); + const globalStylesId = __experimentalGetCurrentGlobalStylesId(); + const globalStyles = globalStylesId + ? getEntityRecord( 'root', 'globalStyles', globalStylesId ) + : undefined; + return { + isViewMode: 'view' === getCanvasMode(), + isStyleBookOpened: + 'style-book' === getEditorCanvasContainerView(), + revisionsCount: + globalStyles?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? + 0, + }; + }, + [] + ); const turnOffDistractionFreeMode = useCallback( () => { const isDistractionFree = getPreference( @@ -226,6 +221,12 @@ export default function SidebarNavigationScreenGlobalStyles() { setEditorCanvasContainerView( 'global-styles-revisions' ); }, [ openGlobalStyles, setEditorCanvasContainerView ] ); + // If there are no revisions, do not render a footer. + const hasRevisions = revisionsCount >= 2; + const modifiedDateTime = revisions?.[ 0 ]?.modified; + const shouldShowGlobalStylesFooter = + hasRevisions && ! isLoadingRevisions && modifiedDateTime; + return ( <> } footer={ - + shouldShowGlobalStylesFooter && ( + + ) } actions={ <> diff --git a/packages/edit-site/src/components/sidebar-navigation-screen/index.js b/packages/edit-site/src/components/sidebar-navigation-screen/index.js index d26cc4c7d62a09..f8824332f51528 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen/index.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import classnames from 'classnames'; + /** * WordPress dependencies */ @@ -51,7 +56,12 @@ export default function SidebarNavigationScreen( { return ( <> 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 26a30da286fc84..65fe323157b9a1 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen/style.scss +++ b/packages/edit-site/src/components/sidebar-navigation-screen/style.scss @@ -9,6 +9,10 @@ // Ensure the sidebar is always at least as tall as the viewport. // This allows the footer section to be sticky at the bottom of the viewport. flex-grow: 1; + margin-bottom: $grid-unit-20; + &.has-footer { + margin-bottom: 0; + } } .edit-site-sidebar-navigation-screen__content {