diff --git a/packages/edit-site/src/components/global-styles/screen-css.js b/packages/edit-site/src/components/global-styles/screen-css.js index 570ac7abef269d..2fc8fdfecb7a37 100644 --- a/packages/edit-site/src/components/global-styles/screen-css.js +++ b/packages/edit-site/src/components/global-styles/screen-css.js @@ -18,9 +18,6 @@ const { useGlobalStyle, AdvancedPanel: StylesAdvancedPanel } = unlock( ); function ScreenCSS() { - const description = __( - 'Add your own CSS to customize the appearance and layout of your site.' - ); const [ style ] = useGlobalStyle( '', undefined, 'user', { shouldDecodeEncode: false, } ); @@ -35,10 +32,12 @@ function ScreenCSS() { return ( <> - { description } + { __( + 'You can add custom CSS to further customize the appearance and layout of your site.' + ) }
{ - const { - getEntityRecord, - __experimentalGetCurrentGlobalStylesId, - __experimentalGetCurrentThemeGlobalStylesVariations, - } = select( coreStore ); - - const globalStylesId = __experimentalGetCurrentGlobalStylesId(); - const globalStyles = globalStylesId - ? getEntityRecord( 'root', 'globalStyles', globalStylesId ) - : undefined; - - return { - hasVariations: - !! __experimentalGetCurrentThemeGlobalStylesVariations() - ?.length, - canEditCSS: !! globalStyles?._links?.[ 'wp:action-edit-css' ], - }; + const hasVariations = useSelect( ( select ) => { + const { __experimentalGetCurrentThemeGlobalStylesVariations } = + select( coreStore ); + return !! __experimentalGetCurrentThemeGlobalStylesVariations()?.length; }, [] ); return ( @@ -92,7 +78,7 @@ function ScreenRoot() { * the nav button inset should be looked at before reusing further. */ paddingX="13px" - marginBottom={ 4 } + marginBottom={ 2 } > { __( 'Customize the appearance of specific blocks for the whole site.' @@ -109,38 +95,6 @@ function ScreenRoot() { - - { canEditCSS && ( - <> - - - - { __( - 'Add your own CSS to customize the appearance and layout of your site.' - ) } - - - - - - { __( 'Additional CSS' ) } - - - - - - - - ) } ); } diff --git a/packages/edit-site/src/components/sidebar-global-styles-wrapper/index.js b/packages/edit-site/src/components/sidebar-global-styles-wrapper/index.js index de12bbe466bf3b..cb8a46a1f66f45 100644 --- a/packages/edit-site/src/components/sidebar-global-styles-wrapper/index.js +++ b/packages/edit-site/src/components/sidebar-global-styles-wrapper/index.js @@ -2,12 +2,20 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { useSelect } from '@wordpress/data'; +import { store as coreStore } from '@wordpress/core-data'; import { useMemo, useState } from '@wordpress/element'; import { privateApis as routerPrivateApis } from '@wordpress/router'; import { useViewportMatch } from '@wordpress/compose'; -import { Button } from '@wordpress/components'; +import { + Button, + __experimentalHStack as HStack, + DropdownMenu, + MenuGroup, + MenuItem, +} from '@wordpress/components'; import { addQueryArgs, removeQueryArgs } from '@wordpress/url'; -import { seen } from '@wordpress/icons'; +import { seen, moreVertical } from '@wordpress/icons'; /** * Internal dependencies @@ -24,21 +32,59 @@ const GlobalStylesPageActions = ( { path, } ) => { const history = useHistory(); + const canEditCSS = useSelect( ( select ) => { + const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = + select( coreStore ); + const globalStylesId = __experimentalGetCurrentGlobalStylesId(); + const globalStyles = globalStylesId + ? getEntityRecord( 'root', 'globalStyles', globalStylesId ) + : undefined; + return !! globalStyles?._links?.[ 'wp:action-edit-css' ]; + }, [] ); + return ( -