Skip to content

Commit

Permalink
Don't show custom css option if no custom css entered yet
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz committed Jan 24, 2023
1 parent 3fe5ebf commit ea23a82
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { isRTL, __ } from '@wordpress/i18n';
import { chevronLeft, chevronRight } from '@wordpress/icons';
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
import { experiments as blockEditorExperiments } from '@wordpress/block-editor';

/**
* Internal dependencies
Expand All @@ -24,8 +25,12 @@ import { IconWithCurrentColor } from './icon-with-current-color';
import { NavigationButtonAsItem } from './navigation-button';
import ContextMenu from './context-menu';
import StylesPreview from './preview';
import { unlock } from '../../experiments';

function ScreenRoot() {
const { useGlobalStyle } = unlock( blockEditorExperiments );
const [ customCSS ] = useGlobalStyle( 'css' );

const { variations, canEditCSS } = useSelect( ( select ) => {
const {
getEntityRecord,
Expand Down Expand Up @@ -110,7 +115,7 @@ function ScreenRoot() {
</ItemGroup>
</CardBody>

{ canEditCSS && (
{ canEditCSS && customCSS && (
<>
<CardDivider />
<CardBody>
Expand Down
19 changes: 14 additions & 5 deletions packages/edit-site/src/components/global-styles/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ const { Slot: GlobalStylesMenuSlot, Fill: GlobalStylesMenuFill } =

function GlobalStylesMenu() {
const { toggle } = useDispatch( preferencesStore );
const { useGlobalStylesReset } = unlock( blockEditorExperiments );
const { useGlobalStylesReset, useGlobalStyle } = unlock(
blockEditorExperiments
);
const [ canReset, onReset ] = useGlobalStylesReset();
const [ customCSS ] = useGlobalStyle( 'css' );
const { goTo } = useNavigator();
const loadCustomCSS = () => goTo( '/css' );
return (
Expand All @@ -59,10 +62,14 @@ function GlobalStylesMenu() {
onClick: onReset,
isDisabled: ! canReset,
},
{
title: __( 'Additional CSS' ),
onClick: loadCustomCSS,
},
...( ! customCSS
? [
{
title: __( 'Additional CSS' ),
onClick: loadCustomCSS,
},
]
: [] ),
{
title: __( 'Welcome Guide' ),
onClick: () =>
Expand Down Expand Up @@ -331,9 +338,11 @@ function GlobalStylesUI( { isStyleBookOpened, onCloseStyleBook } ) {
{ isStyleBookOpened && (
<GlobalStylesStyleBook onClose={ onCloseStyleBook } />
) }

<GlobalStylesNavigationScreen path="/css">
<ScreenCSS />
</GlobalStylesNavigationScreen>

<GlobalStylesMenu />
</NavigatorProvider>
);
Expand Down

0 comments on commit ea23a82

Please sign in to comment.