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

FontSizePicker : Deprecate 36px default size #66920

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -24,6 +24,7 @@

- `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)).
- `FontSizePicker`: Deprecate 36px default size ([#66920](https://github.com/WordPress/gutenberg/pull/66920)).
PARTHVATALIYA marked this conversation as resolved.
Show resolved Hide resolved

### Bug Fixes

Expand Down
1 change: 1 addition & 0 deletions packages/components/src/font-size-picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const MyFontSizePicker = () => {

return (
<FontSizePicker
__next40pxDefaultSize
fontSizes={ fontSizes }
value={ fontSize }
fallbackFontSize={ fallbackFontSize }
Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/font-size-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { Spacer } from '../spacer';
import FontSizePickerSelect from './font-size-picker-select';
import FontSizePickerToggleGroup from './font-size-picker-toggle-group';
import { T_SHIRT_NAMES } from './constants';
import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';

const DEFAULT_UNITS = [ 'px', 'em', 'rem', 'vw', 'vh' ];

Expand Down Expand Up @@ -123,6 +124,12 @@ const UnforwardedFontSizePicker = (
!! valueUnit && [ 'em', 'rem', 'vw', 'vh' ].includes( valueUnit );
const isDisabled = value === undefined;

maybeWarnDeprecated36pxSize( {
componentName: 'FontSizePicker',
__next40pxDefaultSize,
size: undefined,
PARTHVATALIYA marked this conversation as resolved.
Show resolved Hide resolved
} );

return (
<Container ref={ ref } className="components-font-size-picker">
<VisuallyHidden as="legend">{ __( 'Font size' ) }</VisuallyHidden>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const TwoFontSizePickersWithState: StoryFn< typeof FontSizePicker > = ( {
export const Default: StoryFn< typeof FontSizePicker > =
FontSizePickerWithState.bind( {} );
Default.args = {
__next40pxDefaultSize: true,
disableCustomFontSizes: false,
fontSizes: [
{
Expand Down
6 changes: 5 additions & 1 deletion packages/components/src/font-size-picker/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
onChange={ ( newFontSize ) => {
setFontSize( newFontSize );
onChange?.( newFontSize );
} }

Check failure on line 32 in packages/components/src/font-size-picker/test/index.tsx

View workflow job for this annotation

GitHub Actions / JavaScript (Node.js 20) 1/4

Error: expect(jest.fn()).not.toHaveWarned(expected) Expected mock function not to be called but it was called with: ["36px default size for wp.components.FontSizePicker is deprecated since version 6.8 and will be removed in version 7.1. Note: Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version."] console.warn() should not be used unless explicitly expected See https://www.npmjs.com/package/@wordpress/jest-console for details. at Object.assertExpectedCalls (/home/runner/work/gutenberg/gutenberg/packages/jest-console/src/index.js:32:40) at Promise.then.completed (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/utils.js:300:28) at new Promise (<anonymous>) at callAsyncCircusFn (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/utils.js:233:10) at _callCircusHook (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:280:40) at _runTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:253:5) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:125:9) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:120:9) at run (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:70:3) at runAndTransformResultsToJestFormat (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21) at jestAdapter (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19) at runTestInternal (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/runTest.js:367:16) at runTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/runTest.js:444:34) at Object.worker (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/testWorker.js:106:12)

Check failure on line 32 in packages/components/src/font-size-picker/test/index.tsx

View workflow job for this annotation

GitHub Actions / JavaScript (Node.js 22) 1/4

Error: expect(jest.fn()).not.toHaveWarned(expected) Expected mock function not to be called but it was called with: ["36px default size for wp.components.FontSizePicker is deprecated since version 6.8 and will be removed in version 7.1. Note: Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version."] console.warn() should not be used unless explicitly expected See https://www.npmjs.com/package/@wordpress/jest-console for details. at Object.assertExpectedCalls (/home/runner/work/gutenberg/gutenberg/packages/jest-console/src/index.js:32:40) at Promise.then.completed (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/utils.js:300:28) at new Promise (<anonymous>) at callAsyncCircusFn (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/utils.js:233:10) at _callCircusHook (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:280:40) at _runTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:253:5) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:125:9) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:120:9) at run (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:70:3) at runAndTransformResultsToJestFormat (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21) at jestAdapter (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19) at runTestInternal (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/runTest.js:367:16) at runTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/runTest.js:444:34) at Object.worker (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/testWorker.js:106:12)
/>
);
};
Expand All @@ -46,7 +46,11 @@
const user = userEvent.setup();
const onChange = jest.fn();
await render(
<FontSizePicker value={ value } onChange={ onChange } />
<FontSizePicker
__next40pxDefaultSize
PARTHVATALIYA marked this conversation as resolved.
Show resolved Hide resolved
value={ value }
onChange={ onChange }
/>
);
const input = screen.getByLabelText( 'Custom' );
await user.clear( input );
Expand Down
Loading