diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 4152b3c654bab..ba0629eff7f37 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -37,6 +37,7 @@ - `Tooltip`: no-op when nested inside other `Tooltip` components ([#57202](https://github.com/WordPress/gutenberg/pull/57202)). - `PaletteEdit`: improve unit tests ([#57645](https://github.com/WordPress/gutenberg/pull/57645)). - `ColorPalette` and `CircularOptionPicker`: improve unit tests ([#57809](https://github.com/WordPress/gutenberg/pull/57809)). +- `BoxControl`, `BorderControl`, `BorderBoxControl`: Add opt-in prop for 40px default size ([#56185](https://github.com/WordPress/gutenberg/pull/56185)). ### Experimental diff --git a/packages/components/src/border-box-control/border-box-control/component.tsx b/packages/components/src/border-box-control/border-box-control/component.tsx index 4f3517937f204..e329ac7c647cd 100644 --- a/packages/components/src/border-box-control/border-box-control/component.tsx +++ b/packages/components/src/border-box-control/border-box-control/component.tsx @@ -89,7 +89,6 @@ const UnconnectedBorderBoxControl = ( ); const mergedRef = useMergeRefs( [ setPopoverAnchor, forwardedRef ] ); - return ( & { diff --git a/packages/components/src/border-control/border-control/component.tsx b/packages/components/src/border-control/border-control/component.tsx index 960be4bf171ea..197067c684373 100644 --- a/packages/components/src/border-control/border-control/component.tsx +++ b/packages/components/src/border-control/border-control/component.tsx @@ -38,6 +38,7 @@ const UnconnectedBorderControl = ( forwardedRef: React.ForwardedRef< any > ) => { const { + __next40pxDefaultSize = false, colors, disableCustomColors, disableUnits, @@ -112,6 +113,7 @@ const UnconnectedBorderControl = ( step={ [ 'px', '%' ].includes( widthUnit ) ? 1 : 0.1 } value={ widthValue || undefined } withInputField={ false } + __next40pxDefaultSize={ __next40pxDefaultSize } /> ) } diff --git a/packages/components/src/border-control/border-control/hook.ts b/packages/components/src/border-control/border-control/hook.ts index 63034527cfa1a..8a291c4112d91 100644 --- a/packages/components/src/border-control/border-control/hook.ts +++ b/packages/components/src/border-control/border-control/hook.ts @@ -41,9 +41,13 @@ export function useBorderControl( value: border, width, __experimentalIsRenderedInSidebar = false, + __next40pxDefaultSize, ...otherProps } = useContextSystem( props, 'BorderControl' ); + const computedSize = + size === 'default' && __next40pxDefaultSize ? '__unstable-large' : size; + const [ widthValue, originalWidthUnit ] = parseQuantityAndUnitFromRawValue( border?.width ); @@ -130,10 +134,10 @@ export function useBorderControl( } const innerWrapperClassName = useMemo( () => { const widthStyle = !! wrapperWidth && styles.wrapperWidth; - const heightStyle = styles.wrapperHeight( size ); + const heightStyle = styles.wrapperHeight( computedSize ); return cx( styles.innerWrapper(), widthStyle, heightStyle ); - }, [ wrapperWidth, cx, size ] ); + }, [ wrapperWidth, cx, computedSize ] ); const sliderClassName = useMemo( () => { return cx( styles.borderSlider() ); @@ -155,7 +159,8 @@ export function useBorderControl( value: border, widthUnit, widthValue, - size, + size: computedSize, __experimentalIsRenderedInSidebar, + __next40pxDefaultSize, }; } diff --git a/packages/components/src/border-control/types.ts b/packages/components/src/border-control/types.ts index 470b75df7c182..7752d9760ffe5 100644 --- a/packages/components/src/border-control/types.ts +++ b/packages/components/src/border-control/types.ts @@ -99,6 +99,12 @@ export type BorderControlProps = ColorProps & * `RangeControl` for additional control over a border's width. */ withSlider?: boolean; + /** + * Start opting into the larger default height that will become the default size in a future version. + * + * @default false + */ + __next40pxDefaultSize?: boolean; }; export type DropdownProps = ColorProps & diff --git a/packages/components/src/box-control/all-input-control.tsx b/packages/components/src/box-control/all-input-control.tsx index 9c18694bbd0b6..fb65014dfaf0f 100644 --- a/packages/components/src/box-control/all-input-control.tsx +++ b/packages/components/src/box-control/all-input-control.tsx @@ -25,6 +25,7 @@ import { const noop = () => {}; export default function AllInputControl( { + __next40pxDefaultSize, onChange = noop, onFocus = noop, values, @@ -74,6 +75,7 @@ export default function AllInputControl( { {}; export default function BoxInputControls( { + __next40pxDefaultSize, onChange = noop, onFocus = noop, values, @@ -107,6 +108,7 @@ export default function BoxInputControls( {