Skip to content

Commit

Permalink
Remove: __experimentalHasMultipleOrigins property from color and grad…
Browse files Browse the repository at this point in the history
…ient related components.
  • Loading branch information
jorgefilipecosta committed Dec 21, 2022
1 parent c05d7c5 commit 8468806
Show file tree
Hide file tree
Showing 32 changed files with 25 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function ColorGradientControlInner( {
gradients,
disableCustomColors,
disableCustomGradients,
__experimentalHasMultipleOrigins,
__experimentalIsRenderedInSidebar,
className,
label,
Expand Down Expand Up @@ -80,9 +79,6 @@ function ColorGradientControlInner( {
: onColorChange
}
{ ...{ colors, disableCustomColors } }
__experimentalHasMultipleOrigins={
__experimentalHasMultipleOrigins
}
__experimentalIsRenderedInSidebar={
__experimentalIsRenderedInSidebar
}
Expand All @@ -103,9 +99,6 @@ function ColorGradientControlInner( {
: onGradientChange
}
{ ...{ gradients, disableCustomGradients } }
__experimentalHasMultipleOrigins={
__experimentalHasMultipleOrigins
}
__experimentalIsRenderedInSidebar={
__experimentalIsRenderedInSidebar
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export default function ColorGradientSettingsDropdown( {
enableAlpha,
gradients,
settings,
__experimentalHasMultipleOrigins,
__experimentalIsRenderedInSidebar,
...props
} ) {
Expand Down Expand Up @@ -140,7 +139,6 @@ export default function ColorGradientSettingsDropdown( {
onColorChange: setting.onColorChange,
onGradientChange: setting.onGradientChange,
showTitle: false,
__experimentalHasMultipleOrigins,
__experimentalIsRenderedInSidebar,
...setting,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import { useInstanceId } from '@wordpress/compose';
* Internal dependencies
*/
import ColorGradientSettingsDropdown from './dropdown';
import useSetting from '../use-setting';
import useCommonSingleMultipleSelects from './use-common-single-multiple-selects';
import useMultipleOriginColorsAndGradients from './use-multiple-origin-colors-and-gradients';
import useColorsAndGradientsPalettes from './use-multiple-origin-colors-and-gradients';

const colorsAndGradientKeys = [
'colors',
Expand All @@ -39,7 +37,6 @@ export const PanelColorGradientSettingsInner = ( {
settings,
title,
showTitle = true,
__experimentalHasMultipleOrigins,
__experimentalIsRenderedInSidebar,
enableAlpha,
} ) => {
Expand Down Expand Up @@ -100,7 +97,6 @@ export const PanelColorGradientSettingsInner = ( {
gradients,
disableCustomColors,
disableCustomGradients,
__experimentalHasMultipleOrigins,
__experimentalIsRenderedInSidebar,
enableAlpha,
} }
Expand All @@ -114,19 +110,8 @@ export const PanelColorGradientSettingsInner = ( {
);
};

const PanelColorGradientSettingsSingleSelect = ( props ) => {
const colorGradientSettings = useCommonSingleMultipleSelects();
colorGradientSettings.colors = useSetting( 'color.palette' );
colorGradientSettings.gradients = useSetting( 'color.gradients' );
return (
<PanelColorGradientSettingsInner
{ ...{ ...colorGradientSettings, ...props } }
/>
);
};

const PanelColorGradientSettingsMultipleSelect = ( props ) => {
const colorGradientSettings = useMultipleOriginColorsAndGradients();
const PanelColorGradientSettingsSelect = ( props ) => {
const colorGradientSettings = useColorsAndGradientsPalettes();
return (
<PanelColorGradientSettingsInner
{ ...{ ...colorGradientSettings, ...props } }
Expand All @@ -140,10 +125,7 @@ const PanelColorGradientSettings = ( props ) => {
) {
return <PanelColorGradientSettingsInner { ...props } />;
}
if ( props.__experimentalHasMultipleOrigins ) {
return <PanelColorGradientSettingsMultipleSelect { ...props } />;
}
return <PanelColorGradientSettingsSingleSelect { ...props } />;
return <PanelColorGradientSettingsSelect { ...props } />;
};

export default PanelColorGradientSettings;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { _x } from '@wordpress/i18n';
* Internal dependencies
*/
import useSetting from '../use-setting';
import useCommonSingleMultipleSelects from './use-common-single-multiple-selects';

/**
* Retrieves color and gradient related settings.
Expand All @@ -19,7 +18,10 @@ import useCommonSingleMultipleSelects from './use-common-single-multiple-selects
* @return {Object} Color and gradient related settings.
*/
export default function useMultipleOriginColorsAndGradients() {
const colorGradientSettings = useCommonSingleMultipleSelects();
const colorGradientSettings = {
disableCustomColors: ! useSetting( 'color.custom' ),
disableCustomGradients: ! useSetting( 'color.customGradient' ),
};
const customColors = useSetting( 'color.palette.custom' );
const themeColors = useSetting( 'color.palette.theme' );
const defaultColors = useSetting( 'color.palette.default' );
Expand Down
1 change: 0 additions & 1 deletion packages/block-editor/src/hooks/border.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ export function BorderPanel( props ) {
popoverPlacement="left-start"
size="__unstable-large"
value={ hydratedBorder }
__experimentalHasMultipleOrigins={ true }
__experimentalIsRenderedInSidebar={ true }
/>
</ToolsPanelItem>
Expand Down
1 change: 0 additions & 1 deletion packages/block-editor/src/hooks/color-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export default function ColorPanel( {
panelId={ clientId }
settings={ settings }
__experimentalIsItemGroup={ false }
__experimentalHasMultipleOrigins
__experimentalIsRenderedInSidebar
{ ...colorGradientSettings }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ export default function CoverInspectorControls( {
</InspectorControls>
<InspectorControls __experimentalGroup="color">
<ColorGradientSettingsDropdown
__experimentalHasMultipleOrigins
__experimentalIsRenderedInSidebar
settings={ [
{
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/navigation/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,6 @@ function Navigation( {
{ hasColorSettings && (
<>
<ColorGradientSettingsDropdown
__experimentalHasMultipleOrigins
__experimentalIsRenderedInSidebar
settings={ [
{
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/post-featured-image/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const Overlay = ( {
) }
<InspectorControls __experimentalGroup="color">
<ColorGradientSettingsDropdown
__experimentalHasMultipleOrigins
__experimentalIsRenderedInSidebar
settings={ [
{
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/social-links/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ export function SocialLinksEdit( props ) {
( { onChange, label, value, resetAllFilter } ) => (
<ColorGradientSettingsDropdown
key={ `social-links-color-${ label }` }
__experimentalHasMultipleOrigins
__experimentalIsRenderedInSidebar
settings={ [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const BorderBoxControlSplitControls = (
rightAlignedClassName,
size = 'default',
value,
__experimentalHasMultipleOrigins,
__experimentalIsRenderedInSidebar,
...otherProps
} = useBorderBoxControlSplitControls( props );
Expand Down Expand Up @@ -65,7 +64,6 @@ const BorderBoxControlSplitControls = (
enableAlpha,
enableStyle,
isCompact: true,
__experimentalHasMultipleOrigins,
__experimentalIsRenderedInSidebar,
size,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export function useBorderBoxControlSplitControls(
enableAlpha = false,
enableStyle = true,
size = 'default',
__experimentalHasMultipleOrigins = false,
__experimentalIsRenderedInSidebar = false,
...otherProps
} = useContextSystem( props, 'BorderBoxControlSplitControls' );
Expand Down Expand Up @@ -49,7 +48,6 @@ export function useBorderBoxControlSplitControls(
enableStyle,
rightAlignedClassName,
size,
__experimentalHasMultipleOrigins,
__experimentalIsRenderedInSidebar,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ const UnconnectedBorderBoxControl = (
splitValue,
toggleLinked,
wrapperClassName,
__experimentalHasMultipleOrigins,
__experimentalIsRenderedInSidebar,
...otherProps
} = useBorderBoxControl( props );
Expand Down Expand Up @@ -116,9 +115,6 @@ const UnconnectedBorderBoxControl = (
width={
size === '__unstable-large' ? '116px' : '110px'
}
__experimentalHasMultipleOrigins={
__experimentalHasMultipleOrigins
}
__experimentalIsRenderedInSidebar={
__experimentalIsRenderedInSidebar
}
Expand All @@ -134,9 +130,6 @@ const UnconnectedBorderBoxControl = (
popoverPlacement={ popoverPlacement }
popoverOffset={ popoverOffset }
value={ splitValue }
__experimentalHasMultipleOrigins={
__experimentalHasMultipleOrigins
}
__experimentalIsRenderedInSidebar={
__experimentalIsRenderedInSidebar
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export function useBorderBoxControl(
enableStyle = true,
size = 'default',
value,
__experimentalHasMultipleOrigins = false,
__experimentalIsRenderedInSidebar = false,
...otherProps
} = useContextSystem( props, 'BorderBoxControl' );
Expand Down Expand Up @@ -136,7 +135,6 @@ export function useBorderBoxControl(
size,
splitValue,
wrapperClassName,
__experimentalHasMultipleOrigins,
__experimentalIsRenderedInSidebar,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ import type { ColorProps, DropdownProps } from '../types';

const getColorObject = (
colorValue: CSSProperties[ 'borderColor' ],
colors: ColorProps[ 'colors' ] | undefined,
hasMultipleColorOrigins: boolean
colors: ColorProps[ 'colors' ] | undefined
) => {
if ( ! colorValue || ! colors ) {
if ( ! colorValue || ! colors || colors.length === 0 ) {
return;
}

if ( hasMultipleColorOrigins ) {
if ( ( colors as PaletteObject[] )[ 0 ].colors !== undefined ) {
let matchedColor;

( colors as PaletteObject[] ).some( ( origin ) =>
Expand Down Expand Up @@ -126,7 +125,6 @@ const BorderControlDropdown = (
forwardedRef: React.ForwardedRef< any >
) => {
const {
__experimentalHasMultipleOrigins,
__experimentalIsRenderedInSidebar,
border,
colors,
Expand All @@ -147,11 +145,7 @@ const BorderControlDropdown = (
} = useBorderControlDropdown( props );

const { color, style } = border || {};
const colorObject = getColorObject(
color,
colors,
!! __experimentalHasMultipleOrigins
);
const colorObject = getColorObject( color, colors );

const toggleAriaLabel = getToggleAriaLabel(
color,
Expand Down Expand Up @@ -207,9 +201,6 @@ const BorderControlDropdown = (
value={ color }
onChange={ onColorChange }
{ ...{ colors, disableCustomColors } }
__experimentalHasMultipleOrigins={
__experimentalHasMultipleOrigins
}
__experimentalIsRenderedInSidebar={
__experimentalIsRenderedInSidebar
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export function useBorderControlDropdown(
onChange,
previousStyleSelection,
size = 'default',
__experimentalHasMultipleOrigins = false,
__experimentalIsRenderedInSidebar = false,
...otherProps
} = useContextSystem( props, 'BorderControlDropdown' );
Expand Down Expand Up @@ -95,7 +94,6 @@ export function useBorderControlDropdown(
popoverContentClassName,
popoverControlsClassName,
resetButtonClassName,
__experimentalHasMultipleOrigins,
__experimentalIsRenderedInSidebar,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const UnconnectedBorderControl = (
widthUnit,
widthValue,
withSlider,
__experimentalHasMultipleOrigins,
__experimentalIsRenderedInSidebar,
...otherProps
} = useBorderControl( props );
Expand All @@ -83,9 +82,6 @@ const UnconnectedBorderControl = (
onChange={ onBorderChange }
previousStyleSelection={ previousStyleSelection }
showDropdownHeader={ showDropdownHeader }
__experimentalHasMultipleOrigins={
__experimentalHasMultipleOrigins
}
__experimentalIsRenderedInSidebar={
__experimentalIsRenderedInSidebar
}
Expand Down
2 changes: 0 additions & 2 deletions packages/components/src/border-control/border-control/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export function useBorderControl(
size = 'default',
value: border,
width,
__experimentalHasMultipleOrigins = false,
__experimentalIsRenderedInSidebar = false,
...otherProps
} = useContextSystem( props, 'BorderControl' );
Expand Down Expand Up @@ -156,7 +155,6 @@ export function useBorderControl(
widthUnit,
widthValue,
size,
__experimentalHasMultipleOrigins,
__experimentalIsRenderedInSidebar,
};
}
1 change: 0 additions & 1 deletion packages/components/src/border-control/stories/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ export const WithMultipleOrigins = Template.bind( {} );
WithMultipleOrigins.args = {
...Default.args,
colors: multipleOriginColors,
__experimentalHasMultipleOrigins: true,
};

/**
Expand Down
5 changes: 1 addition & 4 deletions packages/components/src/border-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ export type Border = {

export type ColorProps = Pick<
ColorPaletteProps,
| 'colors'
| 'enableAlpha'
| '__experimentalHasMultipleOrigins'
| '__experimentalIsRenderedInSidebar'
'colors' | 'enableAlpha' | '__experimentalIsRenderedInSidebar'
> & {
/**
* This toggles the ability to choose custom colors.
Expand Down
Loading

1 comment on commit 8468806

@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.
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/3750031359
📝 Reported issues:

Please sign in to comment.