Skip to content

Commit

Permalink
BorderControl: Deprecate 36px default size (#65755)
Browse files Browse the repository at this point in the history
* Add utility function

* BorderBoxControl: Deprecate 36px default size

* Fix naming

* Add changelog

* BorderControl: Deprecate 36px default size

* Add changelog

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
  • Loading branch information
3 people authored Oct 26, 2024
1 parent 76a5ba1 commit bf84ac6
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Deprecations

- `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)).

### Bug Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,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 @@ -154,6 +154,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,
enableAlpha: true,
enableStyle: true,
shouldSanitizeBorder: 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
4 changes: 2 additions & 2 deletions packages/components/src/utils/deprecated-36px-size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export function maybeWarnDeprecated36pxSize( {
}

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

0 comments on commit bf84ac6

Please sign in to comment.