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

BorderBoxControl: Deprecate 36px default size #65752

Merged
merged 5 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
### Deprecations

- `__experimentalBorderBoxControl` can now be imported as a stable `BorderBoxControl` ([#65586](https://github.com/WordPress/gutenberg/pull/65586)).
- `BorderBoxControl`: Deprecate 36px default size ([#65752](https://github.com/WordPress/gutenberg/pull/65752)).

### Enhancements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const MyBorderBoxControl = () => {

return (
<BorderBoxControl
__next40pxDefaultSize
colors={ colors }
label={ __( 'Borders' ) }
onChange={ onChange }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ const UnconnectedBorderBoxControl = (
*
* return (
* <BorderBoxControl
* __next40pxDefaultSize
* colors={ colors }
* label={ __( 'Borders' ) }
* onChange={ onChange }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import type { WordPressComponentProps } from '../../context';
import { useContextSystem } from '../../context';
import { useCx } from '../../utils/hooks/use-cx';
import { maybeWarnDeprecated36pxSize } from '../../utils/deprecated-36px-size';

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

maybeWarnDeprecated36pxSize( {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use this new utility for any existing component?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything except for FormFileUpload and Button, which will need more specific conditional logic.

componentName: 'BorderBoxControl',
__next40pxDefaultSize,
size,
} );

const computedSize =
size === 'default' && __next40pxDefaultSize ? '__unstable-large' : size;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ Default.args = {
colors,
label: 'Borders',
enableStyle: true,
__next40pxDefaultSize: true,
};
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const props = {
props.value = newValue;
} ),
value: undefined,
__next40pxDefaultSize: true,
};

const toggleLabelRegex = /Border color( and style)* picker/;
Expand Down
24 changes: 24 additions & 0 deletions packages/components/src/utils/deprecated-36px-size.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';

export function maybeWarnDeprecated36pxSize( {
componentName,
__next40pxDefaultSize,
size,
}: {
componentName: string;
__next40pxDefaultSize: boolean | undefined;
size: string;
} ) {
if ( __next40pxDefaultSize || size !== 'default' ) {
return;
}

deprecated( `36px default size for wp.components.${ componentName }`, {
since: '6.7',
version: '7.0',
hint: 'Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version.',
} );
}
Loading