Skip to content

Commit

Permalink
FontSizePicker : Deprecate 36px default size (#66920)
Browse files Browse the repository at this point in the history
* Add the console warning for 36px size variation

* Add the changelog for the deprecation

* Update: changelog and test for all tests need to pass

---------

Co-authored-by: PARTHVATALIYA <[email protected]>
Co-authored-by: mirka <[email protected]>
  • Loading branch information
3 people authored Nov 20, 2024
1 parent 0587619 commit 9f0e2d3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- `DimensionControl`: Deprecate 36px default size ([#66705](https://github.com/WordPress/gutenberg/pull/66705)).
- `TextControl`: Deprecate 36px default size ([#66745](https://github.com/WordPress/gutenberg/pull/66745).
- `FontSizePicker`: Deprecate 36px default size ([#66920](https://github.com/WordPress/gutenberg/pull/66920)).
- `ComboboxControl`: Deprecate 36px default size ([#66900](https://github.com/WordPress/gutenberg/pull/66900)).

### Bug Fixes

Expand All @@ -30,7 +32,6 @@
### Deprecations

- `Radio`: Deprecate 36px default size ([#66572](https://github.com/WordPress/gutenberg/pull/66572)).
- `ComboboxControl`: Deprecate 36px default size ([#66900](https://github.com/WordPress/gutenberg/pull/66900)).

### 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,
} );

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 @@ -8,13 +8,17 @@ import { render } from '@ariakit/test/react';
/**
* Internal dependencies
*/
import FontSizePicker from '../';
import _FontSizePicker from '../';
import type { FontSize } from '../types';
/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';

const FontSizePicker = (
props: React.ComponentProps< typeof _FontSizePicker >
) => <_FontSizePicker __next40pxDefaultSize { ...props } />;

const ControlledFontSizePicker = ( {
onChange,
...props
Expand Down

1 comment on commit 9f0e2d3

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in 9f0e2d3.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11924681333
📝 Reported issues:

Please sign in to comment.