Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shadow: move shadow into own panel #47634

Merged
merged 3 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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