Skip to content

Commit 76a5ba1

Browse files
mirkaciampoDaniGuardiola
authored
BorderBoxControl: Deprecate 36px default size (#65752)
* Add utility function * BorderBoxControl: Deprecate 36px default size * Fix naming * Add changelog Co-authored-by: mirka <[email protected]> Co-authored-by: ciampo <[email protected]> Co-authored-by: DaniGuardiola <[email protected]>
1 parent 0466f7d commit 76a5ba1

File tree

7 files changed

+39
-0
lines changed

7 files changed

+39
-0
lines changed

packages/components/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Deprecations
6+
7+
- `BorderBoxControl`: Deprecate 36px default size ([#65752](https://github.com/WordPress/gutenberg/pull/65752)).
8+
59
### Bug Fixes
610

711
- `ColorPalette`: prevent overflow of custom color button background ([#66152](https://github.com/WordPress/gutenberg/pull/66152)).

packages/components/src/border-box-control/border-box-control/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const MyBorderBoxControl = () => {
4747

4848
return (
4949
<BorderBoxControl
50+
__next40pxDefaultSize
5051
colors={ colors }
5152
label={ __( 'Borders' ) }
5253
onChange={ onChange }

packages/components/src/border-box-control/border-box-control/component.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ const UnconnectedBorderBoxControl = (
175175
*
176176
* return (
177177
* <BorderBoxControl
178+
* __next40pxDefaultSize
178179
* colors={ colors }
179180
* label={ __( 'Borders' ) }
180181
* onChange={ onChange }

packages/components/src/border-box-control/border-box-control/hook.ts

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
import type { WordPressComponentProps } from '../../context';
2020
import { useContextSystem } from '../../context';
2121
import { useCx } from '../../utils/hooks/use-cx';
22+
import { maybeWarnDeprecated36pxSize } from '../../utils/deprecated-36px-size';
2223

2324
import type { Border } from '../../border-control/types';
2425
import type { Borders, BorderSide, BorderBoxControlProps } from '../types';
@@ -39,6 +40,12 @@ export function useBorderBoxControl(
3940
...otherProps
4041
} = useContextSystem( props, 'BorderBoxControl' );
4142

43+
maybeWarnDeprecated36pxSize( {
44+
componentName: 'BorderBoxControl',
45+
__next40pxDefaultSize,
46+
size,
47+
} );
48+
4249
const computedSize =
4350
size === 'default' && __next40pxDefaultSize ? '__unstable-large' : size;
4451

packages/components/src/border-box-control/stories/index.story.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,5 @@ Default.args = {
8484
colors,
8585
label: 'Borders',
8686
enableStyle: true,
87+
__next40pxDefaultSize: true,
8788
};

packages/components/src/border-box-control/test/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const props = {
4444
props.value = newValue;
4545
} ),
4646
value: undefined,
47+
__next40pxDefaultSize: true,
4748
};
4849

4950
const toggleLabelRegex = /Border color( and style)* picker/;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* WordPress dependencies
3+
*/
4+
import deprecated from '@wordpress/deprecated';
5+
6+
export function maybeWarnDeprecated36pxSize( {
7+
componentName,
8+
__next40pxDefaultSize,
9+
size,
10+
}: {
11+
componentName: string;
12+
__next40pxDefaultSize: boolean | undefined;
13+
size: string;
14+
} ) {
15+
if ( __next40pxDefaultSize || size !== 'default' ) {
16+
return;
17+
}
18+
19+
deprecated( `36px default size for wp.components.${ componentName }`, {
20+
since: '6.7',
21+
version: '7.0',
22+
hint: 'Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version.',
23+
} );
24+
}

0 commit comments

Comments
 (0)