Skip to content

Commit

Permalink
Shadow: move shadow to own panel (#47634)
Browse files Browse the repository at this point in the history
* move shadow into newly created effects panel

* rename effects to shadow

* rename label shadows to shadow in popover
  • Loading branch information
madhusudhand authored Feb 2, 2023
1 parent d113597 commit 5535a3a
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 8 deletions.
16 changes: 14 additions & 2 deletions packages/edit-site/src/components/global-styles/context-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import {
typography,
border,
shadow,
color,
layout,
chevronLeft,
Expand All @@ -32,11 +33,13 @@ import { useHasVariationsPanel } from './variations-panel';
import { NavigationButtonAsItem } from './navigation-button';
import { IconWithCurrentColor } from './icon-with-current-color';
import { ScreenVariations } from './screen-variations';
import { useHasShadowControl } from './shadow-panel';

function ContextMenu( { name, parentMenu = '' } ) {
const hasTypographyPanel = useHasTypographyPanel( name );
const hasColorPanel = useHasColorPanel( name );
const hasBorderPanel = useHasBorderPanel( name );
const hasEffectsPanel = useHasShadowControl( name );
const hasDimensionsPanel = useHasDimensionsPanel( name );
const hasLayoutPanel = hasDimensionsPanel;
const hasVariationsPanel = useHasVariationsPanel( name, parentMenu );
Expand Down Expand Up @@ -85,9 +88,18 @@ function ContextMenu( { name, parentMenu = '' } ) {
<NavigationButtonAsItem
icon={ border }
path={ parentMenu + '/border' }
aria-label={ __( 'Border & shadow styles' ) }
aria-label={ __( 'Border' ) }
>
{ __( 'Border & Shadow' ) }
{ __( 'Border' ) }
</NavigationButtonAsItem>
) }
{ hasEffectsPanel && (
<NavigationButtonAsItem
icon={ shadow }
path={ parentMenu + '/effects' }
aria-label={ __( 'Shadow' ) }
>
{ __( 'Shadow' ) }
</NavigationButtonAsItem>
) }
{ hasLayoutPanel && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,17 @@ import ScreenHeader from './header';
import BorderPanel, { useHasBorderPanel } from './border-panel';
import BlockPreviewPanel from './block-preview-panel';
import { getVariationClassName } from './utils';
import ShadowPanel, { useHasShadowControl } from './shadow-panel';

function ScreenBorder( { name, variation = '' } ) {
const hasBorderPanel = useHasBorderPanel( name );
const variationClassName = getVariationClassName( variation );
const hasShadowPanel = useHasShadowControl( name );
return (
<>
<ScreenHeader title={ __( 'Border & Shadow' ) } />
<BlockPreviewPanel name={ name } variation={ variationClassName } />
{ hasBorderPanel && (
<BorderPanel name={ name } variation={ variation } />
) }
{ hasShadowPanel && (
<ShadowPanel name={ name } variation={ variation } />
) }
</>
);
}
Expand Down
28 changes: 28 additions & 0 deletions packages/edit-site/src/components/global-styles/screen-effects.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import ScreenHeader from './header';
import BlockPreviewPanel from './block-preview-panel';
import { getVariationClassName } from './utils';
import ShadowPanel, { useHasShadowControl } from './shadow-panel';

function ScreenEffects( { name, variation = '' } ) {
const variationClassName = getVariationClassName( variation );
const hasShadowPanel = useHasShadowControl( name );
return (
<>
<ScreenHeader title={ __( 'Shadow' ) } />
<BlockPreviewPanel name={ name } variation={ variationClassName } />
{ hasShadowPanel && (
<ShadowPanel name={ name } variation={ variation } />
) }
</>
);
}

export default ScreenEffects;
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function ShadowPopoverContainer( { shadow, onShadowChange } ) {
return (
<div className="edit-site-global-styles__shadow-panel">
<VStack spacing={ 4 }>
<Heading level={ 5 }>{ __( 'Shadows' ) }</Heading>
<Heading level={ 5 }>{ __( 'Shadow' ) }</Heading>
<ShadowPresets
presets={ shadows }
activeShadow={ shadow }
Expand Down
5 changes: 5 additions & 0 deletions packages/edit-site/src/components/global-styles/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import ScreenBorder from './screen-border';
import StyleBook from '../style-book';
import ScreenCSS from './screen-css';
import { unlock } from '../../experiments';
import ScreenEffects from './screen-effects';

const SLOT_FILL_NAME = 'GlobalStylesMenu';
const { Slot: GlobalStylesMenuSlot, Fill: GlobalStylesMenuFill } =
Expand Down Expand Up @@ -209,6 +210,10 @@ function ContextScreens( { name, parentMenu = '', variation = '' } ) {
<ScreenBorder name={ name } variation={ variation } />
</GlobalStylesNavigationScreen>

<GlobalStylesNavigationScreen path={ parentMenu + '/effects' }>
<ScreenEffects name={ name } variation={ variation } />
</GlobalStylesNavigationScreen>

<GlobalStylesNavigationScreen path={ parentMenu + '/layout' }>
<ScreenLayout name={ name } variation={ variation } />
</GlobalStylesNavigationScreen>
Expand Down

1 comment on commit 5535a3a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 5535a3a.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4076521673
📝 Reported issues:

Please sign in to comment.