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

BorderControl: Deprecate 36px default size #65755

Merged
merged 8 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 2 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
### 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)).
- `BorderControl`: Deprecate 36px default size ([#65755](https://github.com/WordPress/gutenberg/pull/65755)).

### 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( {
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,
};
1 change: 1 addition & 0 deletions packages/components/src/border-box-control/test/index.tsx
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const MyBorderControl = () => {

return (
<BorderControl
__next40pxDefaultSize
colors={ colors }
label={ __( 'Border' ) }
onChange={ setBorder }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ const UnconnectedBorderControl = (
*
* return (
* <BorderControl
* __next40pxDefaultSize
* colors={ colors }
* label={ __( 'Border' ) }
* onChange={ onChange }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { parseQuantityAndUnitFromRawValue } from '../../unit-control/utils';
import type { WordPressComponentProps } from '../../context';
import { useContextSystem } from '../../context';
import { useCx } from '../../utils/hooks/use-cx';

import type { Border, BorderControlProps } from '../types';
import { maybeWarnDeprecated36pxSize } from '../../utils/deprecated-36px-size';

// If either width or color are defined, the border is considered valid
// and a border style can be set as well.
Expand Down Expand Up @@ -41,6 +41,12 @@ export function useBorderControl(
...otherProps
} = useContextSystem( props, 'BorderControl' );

maybeWarnDeprecated36pxSize( {
componentName: 'BorderControl',
__next40pxDefaultSize,
size,
} );

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const Default = Template.bind( {} );
Default.args = {
colors,
label: 'Border',
__next40pxDefaultSize: true,
};

/**
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/border-control/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function createProps( customProps ) {
props.value = newValue;
} ),
value: defaultBorder,
__next40pxDefaultSize: true,
...customProps,
};
return props;
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