Skip to content

Commit

Permalink
Draft moving Cover overlay color and opacity controls to color panel
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed May 17, 2022
1 parent 78375e9 commit 700c423
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/block-editor/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export { default as __experimentalTextTransformControl } from './text-transform-
export { default as __experimentalColorGradientControl } from './colors-gradients/control';
export { default as __experimentalColorGradientSettingsDropdown } from './colors-gradients/dropdown';
export { default as __experimentalPanelColorGradientSettings } from './colors-gradients/panel-color-gradient-settings';
export { default as __experimentalUseMultipleOriginColorsAndGradients } from './colors-gradients/use-multiple-origin-colors-and-gradients';
export {
default as __experimentalImageEditor,
ImageEditingProvider as __experimentalImageEditingProvider,
Expand Down
43 changes: 37 additions & 6 deletions packages/block-library/src/cover/edit/inspector-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import { useInstanceId } from '@wordpress/compose';
import {
InspectorControls,
useSetting,
__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,
__experimentalUseGradient,
__experimentalPanelColorGradientSettings as PanelColorGradientSettings,
__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,
} from '@wordpress/block-editor';
import { __ } from '@wordpress/i18n';

Expand Down Expand Up @@ -138,6 +139,9 @@ export default function CoverInspectorControls( {
: [ coverRef.current.style, 'backgroundPosition' ];
styleOfRef[ property ] = mediaPosition( value );
};

const colorGradientSettings = useMultipleOriginColorsAndGradients();

return (
<>
<InspectorControls>
Expand Down Expand Up @@ -220,20 +224,47 @@ export default function CoverInspectorControls( {
</PanelRow>
</PanelBody>
) }
<PanelColorGradientSettings
</InspectorControls>
<InspectorControls __experimentalGroup="color">
<ColorGradientSettingsDropdown
__experimentalHasMultipleOrigins
__experimentalIsItemGroup={ false }
__experimentalIsRenderedInSidebar
title={ __( 'Overlay' ) }
initialOpen={ true }
settings={ [
{
colorValue: overlayColor.color,
gradientValue,
label: __( 'Overlay' ),
onColorChange: setOverlayColor,
onGradientChange: setGradient,
label: __( 'Color' ),
isShownByDefault: true,
hasValue: () =>
!! overlayColor.color || !! gradientValue,
onDeselect: () => {
setOverlayColor( undefined );
setGradient( undefined );
},
resetAllFilter: () => ( {
overlayColor: undefined,
customOverlayColor: undefined,
gradient: undefined,
customGradient: undefined,
} ),
},
] }
panelId={ clientId }
enableAlpha={ true }
{ ...colorGradientSettings }
/>
<ToolsPanelItem
hasValue={ () => !! dimRatio }
label={ __( 'Opacity' ) }
onDeselect={ () =>
setAttributes( { dimRatio: undefined } )
}
resetAllFilter={ () => ( { dimRatio: undefined } ) }
isShownByDefault={ true }
panelId={ clientId }
>
<RangeControl
label={ __( 'Opacity' ) }
Expand All @@ -248,7 +279,7 @@ export default function CoverInspectorControls( {
step={ 10 }
required
/>
</PanelColorGradientSettings>
</ToolsPanelItem>
</InspectorControls>
<InspectorControls __experimentalGroup="dimensions">
<ToolsPanelItem
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/cover/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,7 @@
.block-editor-block-patterns-list__list-item .has-parallax.wp-block-cover {
background-attachment: scroll;
}

.color-block-support-panel__inner-wrapper > :not(.block-editor-tools-panel-color-gradient-settings__item) {
margin-top: $grid-unit-30;
}

0 comments on commit 700c423

Please sign in to comment.