Skip to content

Commit

Permalink
FontSizePicker : Deprecate 36px default size (WordPress#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

0 comments on commit 9f0e2d3

Please sign in to comment.