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 and ntsekouras committed Feb 7, 2023
1 parent c98e7f5 commit b13b4a5
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 @@ -38,6 +38,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 @@ -228,6 +229,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

0 comments on commit b13b4a5

Please sign in to comment.